public static void UpdateAvailable() { bool OldGitUpdateAvailable = GitData.UpdateAvailable; string[] UpdateArray = { GitData.UpdateName, GitData.UpdateBody, GitData.UpdateVersion }; GitData.UpdateAvailable = true; GitData.UpdateName = "An update"; GitData.UpdateBody = "A new update is available. Not really.\nNew line escape sequence works! Use \\n\n\nhello world"; GitData.UpdateVersion = "1.0"; using (frmUpdateAvailable Update = new frmUpdateAvailable()) { Update.ShowDialog(); } GitData.UpdateAvailable = OldGitUpdateAvailable; GitData.UpdateName = UpdateArray[0]; GitData.UpdateBody = UpdateArray[1]; GitData.UpdateVersion = UpdateArray[2]; }
public static void CheckForUpdate(bool ForceCheck = false) { if (Program.IsDebug && !ForceCheck) { Debug.Print("-version " + GitData.UpdateVersion + " -name " + System.AppDomain.CurrentDomain.FriendlyName); } else { if (!General.Default.CheckForUpdatesOnLaunch && !ForceCheck) { return; } if (GitData.UpdateAvailable) { using (frmUpdateAvailable Update = new frmUpdateAvailable()) { Update.BlockSkip = GitData.UpdateAvailable; switch (Update.ShowDialog()) { case DialogResult.Yes: try { UpdateApplication(); } catch (Exception ex) { ErrorLog.ReportException(ex); return; } break; } } } else { Thread checkUpdates = new Thread(() => { if (GitData.UpdateVersion == "-1" || ForceCheck) { decimal GitVersion = UpdateChecker.GetGitVersion(0); if (UpdateChecker.IsUpdateAvailable(GitVersion)) { if (GitVersion != Properties.Settings.Default.SkippedVersion || ForceCheck) { using (frmUpdateAvailable Update = new frmUpdateAvailable()) { Update.BlockSkip = ForceCheck; switch (Update.ShowDialog()) { case DialogResult.Yes: try { UpdateApplication(); } catch (Exception ex) { ErrorLog.ReportException(ex); return; } break; case DialogResult.Ignore: Properties.Settings.Default.SkippedVersion = GitVersion; Properties.Settings.Default.Save(); break; } } } } else if (ForceCheck) { MessageBox.Show("No updates available."); } } }); checkUpdates.Start(); } } }