private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args.IsUpdateAvailable == true) { //Обновляем if (AutoUpdater.DownloadUpdate()) { Application.Exit(); } } else { string request = ApiRequest.Login(login.Text, password.Text); if (request.Contains("Login error")) { login.ForeColor = System.Drawing.Color.Red; password.ForeColor = System.Drawing.Color.Red; } else { ApiRequest.GetAllAddres(); ApiRequest.GetAllBalance(); ApiRequest.GetAllCursAndFee(); this.Hide(); new Main().Show(); } } }
/// <summary> /// Executes a delegate method /// </summary> /// <param name="form">System.Windows.Forms</param> /// <param name="strInfo">To update the information</param> /// <param name="exFlag">Whether for error message</param> public void Executes(Form form, string strInfo, bool exFlag) { UpdateInfoEventArgs e = new UpdateInfoEventArgs(strInfo, exFlag); OnUpdateInfo(form, e); e = null; }
/// <summary> /// Can be overridden execute method /// </summary> /// <param name="wid">System.Windows.Window</param> /// <param name="e">The delegate event</param> protected virtual void OnUpdateInfo(Window wid, UpdateInfoEventArgs e) { if (UpdateInfo != null && wid != null) { wid.Dispatcher.Invoke(UpdateInfo, this, e); } }
bool CheckUpdateInfoArgs(UpdateInfoEventArgs args) { if (args != null && args.IsUpdateAvailable) { return(true); } if (!flagShowErrorWithMsgbox) { setting.SendLog( args == null ? I18N.FetchUpdateInfoFail : I18N.NoUpdateTryLater); return(false); } if (args == null) { MessageBox.Show( I18N.FetchUpdateInfoFail, I18N.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(I18N.NoUpdateTryLater); } return(false); }
void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (!CheckUpdateInfoArgs(args) || !ConfirmUpdate()) { updateBar.Remove(); return; } try { if (AutoUpdater.DownloadUpdate()) { setting.ShutdownReason = VgcApis.Models.Datas.Enums.ShutdownReasons.CloseByUser; Application.Exit(); } } catch (Exception exception) { MessageBox.Show( exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Executes a delegate method /// </summary> /// <param name="wid">System.Windows.Window</param> /// <param name="strInfo">To update the information</param> public void Executes(Window wid, string strInfo) { UpdateInfoEventArgs e = new UpdateInfoEventArgs(strInfo); OnUpdateInfo(wid, e); e = null; }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args.Error == null) { if (args.IsUpdateAvailable) { var msg = "Update terbaru versi {0} sudah tersedia. Saat ini Anda sedang menggunakan Versi {1}\n\nApakah Anda ingin memperbarui aplikasi ini sekarang ?"; var dialogResult = MessageBox.Show(string.Format(msg, args.CurrentVersion, args.InstalledVersion), "Update Tersedia", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult.Equals(DialogResult.Yes)) { try { AutoUpdater.DownloadUpdate(args); Application.Exit(); } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Tidak ada update yang tersedia, silahkan dicoba lagi nanti.", "Update belum tersedia", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Gagal melakukan koneksi ke server, silahkan dicoba lagi nanti.", "Cek update terbaru gagal", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { AutoUpdater.CheckForUpdateEvent -= AutoUpdaterOnCheckForUpdateEvent; AutoUpdater.Start(Settings.Default.AutoUpdateAddress); } else { Dispatcher.Invoke(() => { Title += " (" + args.CurrentVersion + ")"; Initialize(); }); } } else { Dispatcher.Invoke(() => { Title += " (" + MFUtilities.ClientVersion + ")"; Initialize(); }); } }
private void CheckUpdate_Event(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { try { if (AutoUpdater.DownloadUpdate(args)) { XmlDocument xmldoc = new XmlDocument(); XmlNodeList xmlnode; xmldoc.Load(Options.appUpdateURL); xmlnode = xmldoc.GetElementsByTagName("version"); string foundNewVersionApp = xmlnode[0].InnerText; EvntStatus?.Invoke(this, new TextEventArgs($"Программа будет обновлена до версии: {foundNewVersionApp}")); CommonExtensions.Logger(LogTypes.Info, $"Программа будет обновлена до версии: {foundNewVersionApp}"); ApplicationExit(); } } catch (Exception exception) { EvntStatus?.Invoke(this, new TextEventArgs($"Ошибка проверки обновлений: {exception.Message} | {exception.GetType().ToString()}")); CommonExtensions.Logger(LogTypes.Info, $"Ошибка проверки обновлений: {exception.Message} | {exception.GetType().ToString()}"); } // Uncomment the following line if you want to show standard update dialog instead. // AutoUpdater.ShowUpdateForm(args); } } }
void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (!CheckUpdateInfoArgs(args) || !ConfirmUpdate()) { // must confirm first updateBar.Remove(); return; } // if download file failed or cancelled, user can try again updateBar.Remove(); try { if (AutoUpdater.DownloadUpdate()) { setting.SetShutdownReason(VgcApis.Models.Datas.Enums.ShutdownReasons.CloseByUser); Application.Exit(); } } catch (Exception exception) { MessageBox.Show( exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { var dialogResult = MessageBox.Show( string.Format( "({1}->{0})CareAgent有新的版本了,请及时更新!", args.CurrentVersion, args.InstalledVersion), @"CareAgent更新", MessageBoxButton.OKCancel, MessageBoxImage.Information, MessageBoxResult.Cancel, MessageBoxOptions.DefaultDesktopOnly); if (dialogResult.Equals(MessageBoxResult.OK)) { try { AutoUpdater.DownloadUpdate(); } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Error); } } } } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { var msg = "Update terbaru versi {0} sudah tersedia. Saat ini Anda sedang menggunakan Versi {1}\n\nApakah Anda ingin memperbarui aplikasi ini sekarang ?"; var installedVersion = string.Format("{0}.{1}.{2}", args.InstalledVersion.Major, args.InstalledVersion.Minor, args.InstalledVersion.Build); var currentVersion = string.Format("{0}.{1}.{2}", args.CurrentVersion.Major, args.CurrentVersion.Minor, args.CurrentVersion.Build); var dialogResult = MessageBox.Show(string.Format(msg, currentVersion, installedVersion), "Update Tersedia", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult.Equals(DialogResult.Yes)) { try { //You can use Download Update dialog used by AutoUpdater.NET to download the update. AutoUpdater.DownloadUpdate(); } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
/// <summary> /// Function to implement a custom message for a update /// </summary> /// <param name="args">Arguments of the event</param> private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null && args.IsUpdateAvailable) { MetroDialogOptions.AffirmativeButtonText = "Ja"; MetroDialogOptions.NegativeButtonText = "Nein"; var result = this.ShowModalMessageExternal( @"Update", @"Sie benutzen die Version " + args.InstalledVersion.Major + "." + args.InstalledVersion.Minor + " Möchten Sie auf Version " + args.CurrentVersion.Major + "." + args.CurrentVersion.Minor + " updaten?", MessageDialogStyle.AffirmativeAndNegative); if (result == MessageDialogResult.Affirmative) { Process.Start("https://github.com/GlaTEC/SongFinder/releases"); Application.Current.Shutdown(); } else { MetroDialogOptions.AffirmativeButtonText = "Ok"; } } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { if (args.Mandatory) { IUpdateText.Text = $"There is a new version ({args.CurrentVersion}) available. You are using version {args.InstalledVersion}. \nThis is a required update. Press Ok to begin the update."; IUpdateBtnCancel.Visibility = Visibility.Hidden; IUpdateBtnOK.Content = "OK"; } else { IUpdateText.Text = $"There is a new version ({args.CurrentVersion}) available. You are using version {args.InstalledVersion}. \nDo you want to update the application now?"; IUpdateBtnCancel.Content = "No"; IUpdateBtnOK.Content = "Yes"; IUpdateBtnCancel.Visibility = Visibility.Visible; } IUpdateDialog.IsOpen = true; } else { IMessageText.Text = "There is no update available please try again later."; IMessageDialog.IsOpen = true; } } else { IMessageText.Text = "There is a problem reaching update server please check your internet connection and try again later."; IMessageDialog.IsOpen = true; } }
private static void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { DialogResult dialogResult = MessageBox.Show( string.Format("There is new version {0} available. You are using version {1}. Do you want to update the application now?", args.CurrentVersion, args.InstalledVersion), "ConfigMgr Quick Tools Update Available", MessageBoxButtons.YesNo, MessageBoxIcon.Information ); if (dialogResult.Equals(DialogResult.Yes)) { try { if (AutoUpdater.DownloadUpdate()) { Process.GetCurrentProcess().Kill(); } } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { // 有可用更新 if (args.IsUpdateAvailable) { try { if (AutoUpdater.DownloadUpdate()) { Application.Exit(); } } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show( @"未能连接到更新服务器,请检查您的网络连接或稍后重试", @"检查更新失败", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static void AutoUpdater_ParseUpdateInfoEvent(ParseUpdateInfoEventArgs args) { GitHubClient client = new GitHubClient(new ProductHeaderValue("workspacer")); Release release = null; switch (_branch) { case Branch.Stable: release = client.Repository.Release.GetLatest("workspacer", "workspacer").Result; break; case Branch.Unstable: release = client.Repository.Release.Get("workspacer", "workspacer", "unstable").Result; break; case Branch.Beta: IReadOnlyList <Release> releases = client.Repository.Release.GetAll("workspacer", "workspacer").Result; // Latest published beta release release = releases.Where(r => r.TagName.Contains("-beta")) .OrderByDescending(r => r.PublishedAt) .First(); break; } string currentVersion = release.Name.Split(' ').Skip(1).FirstOrDefault(); // If workspacer is installed and the current application is running on the install location, then use the MSI. string fileExtension = GetInstallLocation("workspacer", "Rick Button") == AppContext.BaseDirectory ? "msi" : "zip"; UpdateInfoEventArgs updateInfo = new UpdateInfoEventArgs { CurrentVersion = currentVersion }; switch (_branch) { case Branch.Stable: updateInfo.ChangelogURL = "https://www.workspacer.org/changelog"; updateInfo.DownloadURL = release.Assets .First(a => a.Name == $"workspacer-{currentVersion}-stable.{fileExtension}").BrowserDownloadUrl; break; case Branch.Unstable: updateInfo.ChangelogURL = "https://github.com/workspacer/workspacer/releases/tag/unstable"; updateInfo.DownloadURL = release.Assets .First(a => a.Name == $"workspacer-latest-unstable.{fileExtension}").BrowserDownloadUrl; break; case Branch.Beta: updateInfo.ChangelogURL = $"https://github.com/workspacer/workspacer/releases/tag/v{currentVersion}"; updateInfo.DownloadURL = release.Assets .First(a => a.Name == $"workspacer-{currentVersion}.{fileExtension}").BrowserDownloadUrl; break; } args.UpdateInfo = updateInfo; }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { Dispatcher.Invoke(() => { if (args.IsUpdateAvailable) { if (args.CurrentVersion == Settings.Default.SkippedUpdate && !_isManualUpdate) { return; } _updatePage.SetInfo(args); var x = Properties.Settings.Default.SkippedUpdate; Console.WriteLine(x); PageControl.TransitionType = PageTransitionType.Fade; PageControl.ShowPage(_updatePage); } else if (_isManualUpdate) { MessageBox.Show(Loc.GetString("updater_noupdate"), Loc.GetString("updater_noupdate_title"), MessageBoxButton.OK, MessageBoxImage.Information); } _isManualUpdate = false; }); }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { Dispatcher.Invoke(() => { if (args.IsUpdateAvailable) { if (args.CurrentVersion == Properties.Settings.Default.SkippedUpdate && !_isManualUpdate) { return; } _updatePage.SetInfo(args); var x = Properties.Settings.Default.SkippedUpdate; Console.WriteLine(x); PageControl.TransitionType = PageTransitionType.Fade; PageControl.ShowPage(_updatePage); } else if (_isManualUpdate) { /*SWMessageWindow w = new SWMessageWindow("No updates are available at the moment.\n" + * "Please try again later or check and subscribe the GitHub page for updates.") * { * OptionsLabel = {Visibility = Visibility.Hidden} * }; * w.ShowDialog();*/ MessageBox.Show("No updates are available at the moment.\n" + "Please try again later or check and subscribe the GitHub page for updates.", "No updates", MessageBoxButton.OK, MessageBoxImage.Information); } _isManualUpdate = false; }); }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { AutoUpdater.CheckForUpdateEvent -= AutoUpdaterOnCheckForUpdateEvent; if (args != null) { if (args.IsUpdateAvailable) { AutoUpdater.ShowUpdateForm(); /*DialogResult dialogResult; * if (args.Mandatory) * { * dialogResult = * MessageBox.Show( * $@"There is new version {args.CurrentVersion} available. You are using version {args.InstalledVersion}. This is required update. Press Ok to begin updating the application.", @"Update Available", * MessageBoxButtons.OK, * MessageBoxIcon.Information); * } * else * { * dialogResult = * MessageBox.Show( * $@"There is new version {args.CurrentVersion} available. You are using version { * args.InstalledVersion * }. Do you want to update the application now?", @"Update Available", * MessageBoxButtons.YesNo, * MessageBoxIcon.Information); * } * * // Uncomment the following line if you want to show standard update dialog instead. * AutoUpdater.ShowUpdateForm(); * * if (dialogResult.Equals(DialogResult.Yes) || dialogResult.Equals(DialogResult.OK)) * { * try * { * if (AutoUpdater.DownloadUpdate()) * { * //Application.Exit(); * Close(); * } * } * catch (Exception exception) * { * MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, * MessageBoxIcon.Error); * } * }*/ } else { new BoxMsg(@"已是最新版本", @"提示").ShowDialog(); } } else { new BoxMsg(@"伺服器無回應,請稍後再試!", @"錯誤").ShowDialog(); } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs _args) { CurrentWindow.Dispatcher.Invoke(new Action <UpdateInfoEventArgs>((args) => { if (args != null) { if (args.IsUpdateAvailable) { Confirm.ShowMessage(string.Format("发现新版本{0},程序当前版本{1},是否更新到最新版本?", args.CurrentVersion, args.InstalledVersion), CurrentWindow, (o) => { if (o == ConfirmMode.Confirmed) { try { AutoUpdater.DownloadUpdate(); } catch (Exception exception) { throw exception; } } }); } else { Toast.ShowMessage("未发现新版本,无需更新!", CurrentWindow); } } else { Toast.ShowMessage("程序更新发生问题,请检查是否联网!", CurrentWindow); } }), _args); }
void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (!CheckUpdateInfoArgs(args) || !ConfirmUpdate()) { updateBar.Remove(); return; } try { if (AutoUpdater.DownloadUpdate()) { setting.isShutdown = true; Application.Exit(); } } catch (Exception exception) { MessageBox.Show( exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static void AutoUpdater_CheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { System.Windows.Forms.DialogResult dialogResult; if (args.Mandatory.Value) { dialogResult = System.Windows.Forms.MessageBox.Show( $@"There is new version {args.CurrentVersion} available. You are using version {args.InstalledVersion}. This is required update. Press Ok to begin updating the application.", @"Update Available", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } else { dialogResult = System.Windows.Forms.MessageBox.Show( $@"There is new version {args.CurrentVersion} available. You are using version { args.InstalledVersion }. Do you want to update the application now?", @"Update Available", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information); } // Uncomment the following line if you want to show standard update dialog instead. // AutoUpdater.ShowUpdateForm(args); if (dialogResult.Equals(System.Windows.Forms.DialogResult.Yes) || dialogResult.Equals(System.Windows.Forms.DialogResult.OK)) { try { if (AutoUpdater.DownloadUpdate(args)) { System.Windows.Application.Current.Shutdown(); //Application.Exit(); } } catch (Exception exception) { System.Windows.Forms.MessageBox.Show(exception.Message, exception.GetType().ToString(), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } } else { System.Windows.Forms.MessageBox.Show(@"You are running the latest version of this application.", @"No update available", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } } else { System.Windows.Forms.MessageBox.Show( @"There is a problem reaching update server please check your internet connection and try again later.", @"Update check failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
private void AutoUpdater_CheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null && args.IsUpdateAvailable) { UpdateWindow window = new UpdateWindow(args); window.Show(); } }
/// <summary> /// Can be overridden execute method /// </summary> /// <param name="form">System.Windows.Forms</param> /// <param name="e">The delegate event</param> protected virtual void OnUpdateInfo(Form form, UpdateInfoEventArgs e) { //if (UpdateInfo != null && form != null) form.Invoke(UpdateInfo, this, e);//会造成阻塞[即假死] if (UpdateInfo != null && form != null) { form.BeginInvoke(UpdateInfo, this, e); } }
public UpdateWindow(UpdateInfoEventArgs updateArgs) { this.updateArgs = updateArgs; InitializeComponent(); this.Initialize(this.StatusBar); }
public static void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { MessageBoxResult dialogResult; if (args.Mandatory) { dialogResult = DarkMessageBox.ShowOK( $"FModel {args.CurrentVersion} is available. You are using version {args.InstalledVersion}. This is a required update. Press Ok to begin updating the application.", "Update Available", "OK", MessageBoxImage.Information); } else { dialogResult = DarkMessageBox.ShowYesNoCancel( $"FModel {args.CurrentVersion} is available. You are using version {args.InstalledVersion}. Do you want to update the application now?", "Update Available", "Yes (See the changelog)", "Yes", "No"); } if (dialogResult == MessageBoxResult.Yes) { Process.Start(args.ChangelogURL); } //yes if clicked on changelog (show changelog + update kthx) //no if clicked on ShowYesNoCancel Yes (do not show changelog but update kthx) //ok if force update if (dialogResult == MessageBoxResult.Yes || dialogResult == MessageBoxResult.No || dialogResult == MessageBoxResult.OK) { try { if (AutoUpdater.DownloadUpdate()) { System.Windows.Application.Current.Shutdown(); } } catch (Exception exception) { DarkMessageBox.ShowOK(exception.Message, exception.GetType().ToString(), "OK", MessageBoxImage.Error); } } } } else { DarkMessageBox.ShowOK( "There is a problem reaching update server please check your internet connection and try again later.", "Update check failed", "OK", MessageBoxImage.Error); } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { DialogResult dialogResult; if (args.Mandatory) { dialogResult = MessageBox.Show( $@"There is new version {args.CurrentVersion} available. You are using version {args.InstalledVersion}. This is required update. Press Ok to begin updating the application.", @"Update Available", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { dialogResult = MessageBox.Show( $@"There is new version {args.CurrentVersion} available. You are using version { args.InstalledVersion }. Do you want to update the application now?", @"Update Available", MessageBoxButtons.YesNo, MessageBoxIcon.Information); } if (dialogResult.Equals(DialogResult.Yes) || dialogResult.Equals(DialogResult.OK)) { try { //You can use Download Update dialog used by AutoUpdater.NET to download the update. if (AutoUpdater.DownloadUpdate()) { Application.Exit(); } } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show(@"There is no update available. Please try again later.", @"Update Unavailable", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show( @"There is a problem reaching update server. Please check your internet connection and try again later.", @"Update Check Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { DialogResult dialogResult; if (args.Mandatory) { dialogResult = MessageBox.Show( $@"There is new version {args.CurrentVersion} available. You are using version {args.InstalledVersion}. This is required update. Press Ok to begin updating the application. You may have to close the current version to complete the install process.", @"Update Available", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } else { dialogResult = MessageBox.Show( $@"There is new version {args.CurrentVersion} available. You are using version { args.InstalledVersion }. Do you want to update the application now?", @"Update Available", MessageBoxButtons.YesNo, MessageBoxIcon.Information); } // Uncomment the following line if you want to show standard update dialog instead. // AutoUpdater.ShowUpdateForm(); if (dialogResult.Equals(DialogResult.Yes) || dialogResult.Equals(DialogResult.OK)) { try { if (AutoUpdater.DownloadUpdate()) { Application.Exit(); } } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { //MessageBox.Show(@"There is no update available please try again later.", @"No update available", // MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show( @"There is a problem reaching update server please check your internet connection and try again later.", @"Update check failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AutoUpdaterOnCheckForUpdateEvent(UpdateInfoEventArgs args) { if (args != null) { if (args.IsUpdateAvailable) { Addlog($@"发现更新!建议随时保持最新版本,新版本为{args.CurrentVersion}!", Color.Red); DialogResult dialogResult; if (args.Mandatory) { dialogResult = MessageBox.Show( $@"检查到新版本:{args.CurrentVersion}可用,您当前的版本为:{args.InstalledVersion}. " + "\n" + "由于安全和稳定性等原因,该版本不可跳过.请按“确定”按钮开始更新.", @"发现重要更新", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { dialogResult = MessageBox.Show( $@"检查到新版本 {args.CurrentVersion}" + "\n" + $@"您当前的版本 { args.InstalledVersion }" + "\n" + "请问您需要更新吗?", @"发现可用更新", MessageBoxButtons.YesNo, MessageBoxIcon.Information); } // Uncomment the following line if you want to show standard update dialog instead. // AutoUpdater.ShowUpdateForm(); if (dialogResult.Equals(DialogResult.Yes) || dialogResult.Equals(DialogResult.OK)) { try { if (AutoUpdater.DownloadUpdate()) { Application.Exit(); } } catch (Exception exception) { MessageBox.Show(exception.Message, exception.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { Addlog("版本检查完成,当前已经是最新版本!", Color.Blue); } } else { Addlog("版本信息检查失败,请检查网络!", Color.Blue); } }