void dlg_ButtonClick(object sender, ClickEventArgs e) { if (e.ButtonID == 9) { e.PreventClosing = true; WindowsFormsAero.TaskDialog.TaskDialog newDlg = new TaskDialog("Uploading...", "Upload"); newDlg.ShowProgressBar = true; newDlg.EnableCallbackTimer = true; newDlg.ProgressBarMaxRange = 90; newDlg.CustomButtons = new CustomButton[] { new CustomButton(Result.Cancel, "Abort transfer") }; newDlg.Footer = "Elapsed time: 0s."; newDlg.FooterCommonIcon = TaskDialogIcon.Information; WindowsFormsAero.TaskDialog.TaskDialog dlg = (WindowsFormsAero.TaskDialog.TaskDialog)sender; dlg.Navigate(newDlg); tickHandler = new EventHandler <TimerEventArgs>(dlg_Tick); dlg.Tick += tickHandler; } }
void dlg_Tick(object sender, TimerEventArgs e) { WindowsFormsAero.TaskDialog.TaskDialog dlg = (WindowsFormsAero.TaskDialog.TaskDialog)sender; cTicks += (int)e.Ticks; dlg.Footer = "Elapsed time: " + cTicks / 1000 + "s."; if (dlg.ProgressBarState == WindowsFormsAero.ProgressBar.States.Normal) { dlg.ProgressBarPosition += (int)e.Ticks / 100; e.ResetCount = true; } if (dlg.ProgressBarPosition >= 90) { WindowsFormsAero.TaskDialog.TaskDialog newDlg = new TaskDialog("Upload complete.", "Upload", "Thank you!"); newDlg.CustomButtons = new CustomButton[] { new CustomButton(Result.Cancel, "Close") }; dlg.Navigate(newDlg); dlg.Tick -= tickHandler; } }
/// <summary> /// Core delegate that asks for update confirmation and installs. Must be called from GUI thread. /// </summary> private void ConfirmAndInstallCore() { _updateDialog = new TaskDialog { Title = Strings.UpdateTitle, Instruction = string.Format(Strings.UpdateAvailableInstruction, LastInformation.LatestVersion), Content = Strings.UpdateAvailableContent, CustomButtons = new CustomButton[] { new CustomButton(Result.OK, string.Format(Strings.UpdateAvailableCommandOk, LastInformation.LatestVersion)), new CustomButton(Result.Cancel, Strings.UpdateAvailableCommandCancel) }, UseCommandLinks = true, CommonIcon = TaskDialogIcon.Information, ExpandedInformation = string.Format(Strings.UpdateAvailableExpanded, LastInformation.CurrentVersion, LastInformation.LatestVersion), }; _updateDialog.ButtonClick += delegate(object sender, ClickEventArgs args) { if (args.ButtonID == (int)Result.OK) { args.PreventClosing = true; if (_updateDownloaded) { //Terminate application AttachedForm.Close(); //Launch updater Process.Start(UpdateInstallerPath); } else { var downDlg = new TaskDialog { Title = Strings.UpdateTitle, Instruction = Strings.UpdateDownloadingInstruction, ShowProgressBar = true, ProgressBarMinRange = 0, ProgressBarMaxRange = 100, ProgressBarPosition = 0, CommonButtons = TaskDialogButton.Cancel }; _updateDialog.Navigate(downDlg); _downloadRequest = (HttpWebRequest)HttpWebRequest.Create(LastInformation.DownloadInstaller); _downloadRequest.BeginGetResponse(DownloadAsyncCallback, null); } } }; _updateDialog.Show(AttachedForm); }