public void CheckForUpdates(bool NotifyIfNotFound)
{
var CurrentVersion = PspGlobalConfiguration.CurrentVersion;
StoredConfig.LastCheckedTime = DateTime.UtcNow;
var CheckForUpdatesThread = new Thread(() =>
{
try
{
var Request = HttpWebRequest.Create(new Uri("https://raw.github.com/soywiz/cspspemu/master/version_last.txt"));
Request.Proxy = null;
var Response = Request.GetResponse();
var Stream = Response.GetResponseStream();
var LastVersion = Stream.ReadAllContentsAsString(null, false);
//int CurrentVersionInt = int.Parse(CurrentVersion);
//int LastVersionInt = int.Parse(LastVersion);
var ComparableCurrentVersion = GetComparableVersion(LastVersion);
var ComparableLastVersion = GetComparableVersion(CurrentVersion);
Console.WriteLine("{0} -> {1}", CurrentVersion, LastVersion);
Console.WriteLine("{0} -> {1}", ComparableCurrentVersion, ComparableLastVersion);
if (String.CompareOrdinal(ComparableCurrentVersion, ComparableLastVersion) > 0)
{
if (MessageBox.Show(
String.Format("There is a new version of the emulator.\n") +
String.Format("\n") +
String.Format("Current Version: {0}\n", CurrentVersion) +
String.Format("Last Version: {0}\n", LastVersion) +
String.Format("\n") +
String.Format("Download the new version?") +
"",
"New Version", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
{
Process.Start(@"http://pspemu.soywiz.com/?rf=csp&version=" + CurrentVersion);
}
}
else
{
if (NotifyIfNotFound)
{
MessageBox.Show("You have the lastest version", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception Exception)
{
MessageBox.Show(Exception.ToString(), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
});
/*
foreach (var Embed in Assembly.GetEntryAssembly().GetManifestResourceNames())
{
Console.WriteLine(Embed);
}
*/
CheckForUpdatesThread.IsBackground = true;
CheckForUpdatesThread.Start();
}