/// <summary> /// Displays an error task dialog. /// </summary> /// <param name="mainInstruction">Main instruction of the error dialog.</param> /// <param name="explanation">Detailed informations about the error.</param> /// <param name="errorMessage">Expanded error codes/messages.</param> private void ShowErrorDialog(string mainInstruction, string explanation, string errorMessage) { TaskDialog dlg = new TaskDialog(mainInstruction, Strings.ErrorGenericTitle, explanation) { CommonIcon = TaskDialogIcon.Stop, IsExpanded = false }; if (!string.IsNullOrEmpty(errorMessage)) { dlg.ExpandedInformation = Strings.ErrorGenericInfoText + errorMessage; dlg.ExpandedControlText = Strings.ErrorGenericInfoButton; } dlg.Show(this); }
/// <summary> /// Opens a confirmation dialog to confirm whether to reset the main form or not. /// </summary> public void ResetMainFormWithConfirmation() { var dlg = new TaskDialog(Strings.AskReset, Strings.AskResetTitle, Strings.AskResetContent); dlg.UseCommandLinks = true; dlg.CustomButtons = new CustomButton[] { new CustomButton(Result.OK, Strings.AskResetButtonOk), new CustomButton(Result.Cancel, Strings.ButtonCancel) }; dlg.CommonIcon = TaskDialogIcon.Information; if (dlg.Show(this).CommonButton == Result.OK) { ResetMainForm(); } }
/// <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); }
/// <summary> /// Displays info. Called from GUI thread. /// </summary> private void DisplayInfoCore() { //No updates, but need to inform the user var dlg = new TaskDialog { Title = Strings.UpdateTitle, Instruction = Strings.UpdateInfoInstruction, Content = Strings.UpdateInfoContent, EnableHyperlinks = true, CommonButtons = TaskDialogButton.Close, AllowDialogCancellation = true, CommonIcon = TaskDialogIcon.Information, Footer = string.Format(Strings.UpdateInfoFooter, LastInformation.LatestVersionRelease.ToLongDateString()) }; dlg.HyperlinkClick += delegate(object sender, HyperlinkEventArgs args) { Process.Start("http://ontopreplica.codeplex.com"); }; dlg.Show(AttachedForm); }
/// <summary> /// Core delegate that asks for update confirmation and installs. Must be called from GUI thread. /// </summary> private void ConfirmAndInstallCore() { var 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), }; if (updateDialog.Show(AttachedForm).CommonButton == Result.OK) { Shell.Execute(LastInformation.DownloadPage); } }
private void tskDlgMarquee(object sender, EventArgs e) { TaskDialog dlg = new TaskDialog("This dialog displays a progress bar", "Marquee Progress Bar", "The progress bar below is in 'marquee' mode, that is it will not show the exact percentage of the work done, but it will show that some work is being done.", TaskDialogButton.Close); dlg.SetMarqueeProgressBar(true, 30); dlg.Show(this); }
private void tskDlgComplex(object sender, EventArgs e) { TaskDialog dlg = new TaskDialog("This is the main instruction", "Complex Task Dialog"); dlg.CommonIcon = TaskDialogIcon.SecurityShieldBlue; dlg.Content = "You may write long and informative messages, with <a href=\"http://www.google.com\">hyperlinks</a> and linebreaks.\nButtons can also be shaped as Command Link buttons instead of standard buttons. You may also use radio buttons or add a progress bar."; dlg.UseCommandLinks = true; dlg.EnableHyperlinks = true; dlg.CustomButtons = new CustomButton[] { new CustomButton(9, "Upload\nShows a fake upload task dialog."), new CustomButton(Result.Cancel, "Close") }; dlg.RadioButtons = new CustomButton[] { new CustomButton(1, "First radio button"), new CustomButton(2, "Second radio button"), new CustomButton(3, "Third radio button") }; dlg.ExpandedControlText = "Details"; dlg.ExpandedInformation = "Place some \"expanded information\" here..."; dlg.EnableRadioButton(3, false); //Evt registration dlg.ButtonClick += new EventHandler<ClickEventArgs>(dlg_ButtonClick); Results results = dlg.Show(this.Handle); }
/// <summary> /// Opens a confirmation dialog to confirm whether to reset the main form or not. /// </summary> public void ResetMainFormWithConfirmation() { var dlg = new TaskDialog("Reset the mainform?", "reset preseria-preview dialog", "Do you want to reset the mainform to default values?"); dlg.UseCommandLinks = true; dlg.CustomButtons = new CustomButton[] { new CustomButton(Result.OK, "OK"), new CustomButton(Result.Cancel, "Cancel") }; dlg.CommonIcon = TaskDialogIcon.Information; if (dlg.Show(this).CommonButton == Result.OK) { ResetMainForm(); } }
/// <summary> /// Displays an error task dialog. /// </summary> /// <param name="mainInstruction">Main instruction of the error dialog.</param> /// <param name="explanation">Detailed informations about the error.</param> /// <param name="errorMessage">Expanded error codes/messages.</param> private void ShowErrorDialog(string mainInstruction, string explanation, string errorMessage) { TaskDialog dlg = new TaskDialog(mainInstruction, "Error Preseria-Preview", explanation) { CommonIcon = TaskDialogIcon.Stop, IsExpanded = false }; if (!string.IsNullOrEmpty(errorMessage)) { dlg.ExpandedInformation = "Error: " + errorMessage; dlg.ExpandedControlText = "OK"; } dlg.Show(this); }