private void ButtonTaskDialogCustomButtonClose_Click(object sender, RoutedEventArgs e) { var helper = new WindowInteropHelper(this); var td = new TaskDialog {OwnerWindowHandle = helper.Handle}; var closeLink = new TaskDialogCommandLink("close", "Close", "Closes the task dialog"); closeLink.Click += (o, ev) => td.Close(TaskDialogResult.CustomButtonClicked); var closeButton = new TaskDialogButton("closeButton", "Close"); closeButton.Click += (o, ev) => td.Close(TaskDialogResult.CustomButtonClicked); // Enable one or the other; can't have both at the same time td.Controls.Add(closeLink); //td.Controls.Add(closeButton); // needed since none of the buttons currently closes the TaskDialog td.Cancelable = true; switch (td.Show()) { case TaskDialogResult.CustomButtonClicked: MessageBox.Show("The task dialog was closed by a custom button"); break; case TaskDialogResult.Cancel: MessageBox.Show("The task dialog was canceled"); break; default: MessageBox.Show("The task dialog was closed by other means"); break; } }
void Form1_FormClosing(object sender, FormClosingEventArgs e) { // If the user is closing the app, ask them if they wish to close the current tab // or all the tabs if (tabControl1 != null && tabControl1.TabPages.Count > 0) { if (tabControl1.TabPages.Count <= 1) { // close the tab and the application cancelFormClosing = false; } else { // More than 1 tab.... show the user the TaskDialog TaskDialog tdClose = new TaskDialog(); tdClose.Caption = "Tabbed Thumbnail demo (Winforms)"; tdClose.InstructionText = "Do you want to close all the tabs or the current tab?"; tdClose.Cancelable = true; tdClose.OwnerWindowHandle = this.Handle; TaskDialogButton closeAllTabsButton = new TaskDialogButton("closeAllTabsButton", "Close all tabs"); closeAllTabsButton.Default = true; closeAllTabsButton.Click += new EventHandler(closeAllTabsButton_Click); tdClose.Controls.Add(closeAllTabsButton); TaskDialogButton closeCurrentTabButton = new TaskDialogButton("closeCurrentTabButton", "Close current tab"); closeCurrentTabButton.Click += new EventHandler(closeCurrentTabButton_Click); tdClose.Controls.Add(closeCurrentTabButton); tdClose.Show(); } } e.Cancel = cancelFormClosing; }
private void _ButtonRemove_Click(object sender, EventArgs e) { TaskDialog dialog = new TaskDialog(); dialog.Caption = Resources.WindowTitle; dialog.InstructionText = Locale.Current.Labels.RemoveConfirmation; dialog.Cancelable = true; dialog.OwnerWindowHandle = base.Handle; TaskDialogButton buttonYes = new TaskDialogButton("yesButton", Locale.Current.Labels.Yes); buttonYes.Default = true; buttonYes.Click += _TaskButtonYes_Click; TaskDialogButton buttonNo = new TaskDialogButton("noButton", Locale.Current.Labels.No); buttonNo.Click += _TaskButtonNo_Click; dialog.Controls.Add(buttonYes); dialog.Controls.Add(buttonNo); dialog.Show(); }
private void t_NewFolder_Click(object sender, EventArgs e) { try { ((Folder)rightClickedNode.Tag).CreateNewFolder(GetNewFolderName((Folder)rightClickedNode.Tag)); } catch (Exception x) { if (!Aero) { MessageBox.Show("An exception was thrown: " + x.Message + "\r\n\r\nIf this appears to be a bug, press CTRL + C to copy the stack trace, then please email it to me at [email protected]:\r\n" + x.StackTrace); } else { TaskDialog td = new TaskDialog(); td.Caption = "Unhandled Exception"; td.InstructionText = "An Unhandled Exception was Thrown"; td.Text = string.Format("An exception was thrown: {0}\r\n\r\nIf this appears to be a bug, please email me at [email protected] with the details below", x.Message); td.DetailsCollapsedLabel = "Details"; td.DetailsExpandedLabel = "Details"; td.DetailsExpandedText = x.StackTrace; TaskDialogButton Copy = new TaskDialogButton("Copy", "Copy Details to Clipboard"); Copy.Click += (o, f) => { Clipboard.SetDataObject(x.Message + "\r\n\r\n" + x.StackTrace, true, 10, 200); }; TaskDialogButton Close = new TaskDialogButton("Close", "Close"); Close.Click += (o, f) => { td.Close(); }; td.Controls.Add(Copy); td.Controls.Add(Close); td.ShowDialog(this.Handle); } } }
private void tCached_Click(object sender, EventArgs e) { Forms.NewKnownFolder n = new Forms.NewKnownFolder(); if (n.ShowDialog() == DialogResult.OK) { try { Folder f = (Folder)rightClickedNode.Tag; if (!f.IsDeleted) { foreach (Folder Fol in f.Folders()) { if (Fol.Name.ToLower() == (n.Selected.ToLower())) { MessageBox.Show("Folder already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } f.CreateNewFolder(n.Selected); rightClickedNode.Tag = f; } } catch(Exception x) { if (!Aero) { MessageBox.Show("An exception was thrown: " + x.Message + "\r\n\r\nIf this appears to be a bug, press CTRL + C to copy the stack trace, then please email it to me at [email protected]:\r\n" + x.StackTrace); } else { TaskDialog td = new TaskDialog(); td.Caption = "Unhandled Exception"; td.InstructionText = "An Unhandled Exception was Thrown"; td.Text = string.Format("An exception was thrown: {0}\r\n\r\nIf this appears to be a bug, please email me at [email protected] with the details below", x.Message); td.DetailsCollapsedLabel = "Details"; td.DetailsExpandedLabel = "Details"; td.DetailsExpandedText = x.StackTrace; TaskDialogButton Copy = new TaskDialogButton("Copy", "Copy Details to Clipboard"); Copy.Click += (o, f) => { Clipboard.SetDataObject(x.StackTrace, true, 10, 200); }; TaskDialogButton Close = new TaskDialogButton("Close", "Close"); Close.Click += (o, f) => { td.Close(); }; td.Controls.Add(Copy); td.Controls.Add(Close); } Clear(); } } }
private void menuItem7_Click(object sender, EventArgs e) { string Text = "Party Buffalo was created by CLK Rebellion (Lander Griffith) with help from gabe_k. You may contact me at [email protected]\r\n\r\nThis application is not affiliated with Microsoft Corp. \"Microsoft\", \"Xbox\", \"Xbox 360\" and \"Xbox LIVE\" are registered trademarks of Microsoft Corp."; string Thanks = "skitzo, gabe_k, Cody, hippie, Rickshaw, Cheater912, unknown_v2, sonic-iso, XeNoN.7\r\n\r\nCaboose (Nyan Cat progress bar), Mathieulh (stealing credit cards), idc \"Looks like a list of attendees for a furry convention to me\", roofus & angerwound for the first Xbox 360 FATX explorer which still keeps people satisfied..."; string Version = "Version: " + Application.ProductVersion.ToString(); if (Aero) { Microsoft.WindowsAPICodePack.Dialogs.TaskDialog td = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialog(); td.Caption = "About Party Buffalo"; td.Text = Text; td.InstructionText = "About Party Buffalo"; td.DetailsCollapsedLabel = "Special Thanks To..."; td.DetailsExpandedText = Thanks; Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton Donate = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton("Donate", "Donate"); Donate.Click += (o, f) => { MessageBox.Show("Thank you for your contribution!"); System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JWATGN6RETA5Y&lc=US&item_name=Party%20Buffalo%20Drive%20Explorer¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"); }; //Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton Visit = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton("Visit", "Visit CLKXU5.com"); //Visit.Click += (o, f) => { System.Diagnostics.Process.Start("http://clkxu5.com"); }; Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton Close = new Microsoft.WindowsAPICodePack.Dialogs.TaskDialogButton("Close", "Close"); Close.Click += (o, f) => { td.Close(); }; td.HyperlinksEnabled = true; td.HyperlinkClick += (o, f) => { switch (f.LinkText) { case "Visit the Development Blog": System.Diagnostics.Process.Start("http://clkxu5.com"); break; default: System.Diagnostics.Process.Start("http://free60.org/FATX"); break; }}; td.FooterText = "Thank you for using Party Buffalo Drive Explorer\r\n" + Version + "\r\n<a href=\"http://clkxu5.com\">Visit the Development Blog</a> - <a href=\"http://free60.org/FATX\">FATX Research</a>"; td.Controls.Add(Donate); //td.Controls.Add(Visit); td.Controls.Add(Close); td.Show(); } else { if (MessageBox.Show(Text + "\r\n" + Thanks + "\r\n" + Version + "\r\nWould you like to donate?", "About Party Buffalo", MessageBoxButtons.YesNo) == DialogResult.Yes) { MessageBox.Show("Thank you for your contribution!"); System.Diagnostics.Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JWATGN6RETA5Y&lc=US&item_name=Party%20Buffalo%20Drive%20Explorer¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"); } } }
static void buttonEnableDisable_Click(object sender, EventArgs e) { // Enable/disable sample TaskDialog tdEnableDisable = new TaskDialog(); tdEnableDisable.Cancelable = true; tdEnableDisable.Caption = "Enable/Disable Sample"; tdEnableDisable.InstructionText = "Click on the buttons to enable or disable the radiobutton."; enableButton = new TaskDialogButton("enableButton", "Enable"); enableButton.Default = true; enableButton.Click += new EventHandler(enableButton_Click); disableButton = new TaskDialogButton("disableButton", "Disable"); disableButton.Click += new EventHandler(disableButton_Click); enableDisableRadioButton = new TaskDialogRadioButton("enableDisableRadioButton", "Sample Radio button"); enableDisableRadioButton.Enabled = false; tdEnableDisable.Controls.Add(enableDisableRadioButton); tdEnableDisable.Controls.Add(enableButton); tdEnableDisable.Controls.Add(disableButton); TaskDialogResult tdr = tdEnableDisable.Show(); enableDisableRadioButton = null; enableButton.Click -= new EventHandler(enableButton_Click); disableButton.Click -= new EventHandler(disableButton_Click); enableButton = null; disableButton = null; }
static void buttonCustomButtons_Click(object sender, EventArgs e) { // Custom buttons sample tdCustomButtons = new TaskDialog(); tdCustomButtons.Cancelable = true; tdCustomButtons.Caption = "Custom Buttons Sample"; tdCustomButtons.InstructionText = "Click on any of the custom buttons to get a specific message box"; TaskDialogButton button1 = new TaskDialogButton("button1", "Custom Button 1"); button1.Click += new EventHandler(button1_Click); button1.Default = true; tdCustomButtons.Controls.Add(button1); TaskDialogButton button2 = new TaskDialogButton("button2", "Custom Button 2"); button2.Click += new EventHandler(button2_Click); tdCustomButtons.Controls.Add(button2); TaskDialogButton button3 = new TaskDialogButton("button3", "Custom Close Button"); button3.Click += new EventHandler(button3_Click); tdCustomButtons.Controls.Add(button3); TaskDialogResult result = tdCustomButtons.Show(); tdCustomButtons = null; }
public void FirstInstall() { Enable(false); RegistryKey reg = ParentalControlsRegistry.GetRegistryKey(); reg.SetValue("Path", Application.StartupPath, RegistryValueKind.String); reg.SetValue("AlarmFile", Application.StartupPath + @"\" + ALARMS_FILE); TaskDialog dialog = new TaskDialog(); dialog.Caption = Application.ProductName+" Setup"; dialog.InstructionText = Application.ProductName+" is mostly setup!"; dialog.Text = "What you need to do is setup a password for any cases that you need to force close an alarm."; TaskDialogButton button = new TaskDialogButton("btnOne", "Continue"); button.Click += (aa, ab) => { TaskDialogButton tdb = (TaskDialogButton)aa; ((TaskDialog)tdb.HostingDialog).Close(TaskDialogResult.Ok); if (file2.ParentalControlsCredentials.Count > 0) { TaskDialog dadialog = new TaskDialog(); dadialog.InstructionText = "Setup Complete!"; dadialog.Text = "You are now done setting up Parental Controls!"; dadialog.StandardButtons = TaskDialogStandardButtons.Ok; dadialog.Show(); return; } NetworkCredential cred = null; WindowsSecurity.GetCredentialsVistaAndUp("Please enter new credentials for Parental Controls", "Set username and password for stopping an alarm.", out cred); while (cred == null || (string.IsNullOrWhiteSpace(cred.UserName) || string.IsNullOrWhiteSpace(cred.Password))) { WindowsSecurity.GetCredentialsVistaAndUp("Please enter new credentials for Parental Controls", "Set username and password for stopping an alarm. (Credentials must not be empty)", out cred); } ParentalControlsCredential c; try { c = (ParentalControlsCredential)cred; c.HashedPassword = SHA256Hash.Hash(c.HashedPassword); file2.Add(c); file2.Save(); } catch { } TaskDialog ndialog = new TaskDialog(); ndialog.Caption = Application.ProductName + " Setup"; ndialog.InstructionText = "Want to test your credentials?"; ndialog.FooterText = "Fun Fact: You can create as many accounts as you want!"; ndialog.FooterIcon = TaskDialogStandardIcon.Information; TaskDialogCommandLink linka = new TaskDialogCommandLink("linkA", "Test Credentials"); linka.Click += (ba, bb) => { TaskDialogButton tb = (TaskDialogButton)ba; ((TaskDialog)tb.HostingDialog).Close(TaskDialogResult.Yes); WindowsSecurity.GetCredentialsVistaAndUp("Please enter credentials for \"Parental Controls\"", "Force disabling \"TestAlarm\"", out cred); c = new ParentalControlsCredential(); try { c = (ParentalControlsCredential)cred; c.HashedPassword = SHA256Hash.Hash(c.HashedPassword); } catch { } bool wevalidated = true; while (cred == null || !file2.Validate(c) || (string.IsNullOrWhiteSpace(cred.UserName) || string.IsNullOrWhiteSpace(cred.Password))) { TaskDialog ddialog = new TaskDialog(); ddialog.InstructionText = "Credentials Invalid"; ddialog.Text = "You want to stop testing credentials?"; ddialog.StandardButtons = TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No; if (ddialog.Show() == TaskDialogResult.Yes) { wevalidated = false; break; } else WindowsSecurity.GetCredentialsVistaAndUp("Please enter credentials for \"Parental Controls\"", "Force disabling \"TestAlarm\"", out cred); } TaskDialog dadialog = new TaskDialog(); if (wevalidated) { dadialog.InstructionText = "Credentials Valid!"; } else { dadialog.InstructionText = "Setup Complete!"; } dadialog.Text = "You are now done setting up Parental Controls!"; dadialog.StandardButtons = TaskDialogStandardButtons.Ok; dadialog.Show(); }; TaskDialogCommandLink linkb = new TaskDialogCommandLink("linkB", "Skip Test"); linkb.Click += (ba, bb) => { TaskDialogButton tb = (TaskDialogButton)ba; ((TaskDialog)tb.HostingDialog).Close(TaskDialogResult.No); TaskDialog dadialog = new TaskDialog(); dadialog.InstructionText = "Setup Complete!"; dadialog.Text = "You are now done setting up Parental Controls!"; dadialog.StandardButtons = TaskDialogStandardButtons.Ok; dadialog.Show(); }; ndialog.Controls.Add(linka); ndialog.Controls.Add(linkb); ndialog.Show(); file2.Save(); }; dialog.Controls.Add(button); dialog.Show(); Enable(true); // Kind of an hacky way of making this window get focused after showing dialogs. SwitchToSelf(); }
void ExceptionHandler(Exception x) { if (!Aero) { MessageBox.Show("An exception was thrown: " + x.Message + "\r\n\r\nPress CTRL + C to copy the stack trace:\r\n" + x.StackTrace); } else { tm.SetProgressState(TaskbarProgressBarState.Error); this.Invoke((MethodInvoker)delegate { TaskDialog td = new TaskDialog(); td.Caption = "Unhandled Exception"; td.InstructionText = "An Unhandled Exception was Thrown"; td.Text = string.Format("An exception was thrown: {0}\r\n\r\nIf this appears to be a bug, please email me at [email protected] with the details below", x.Message); td.DetailsCollapsedLabel = "Details"; td.DetailsExpandedLabel = "Details"; td.DetailsExpandedText = x.StackTrace; TaskDialogButton Copy = new TaskDialogButton("Copy", "Copy Details to Clipboard"); Copy.Click += (o, f) => { this.Invoke((MethodInvoker)delegate { Clipboard.SetDataObject(x.Message + "\r\n\r\n" + x.StackTrace, true, 10, 200); }); }; TaskDialogButton Close = new TaskDialogButton("Close", "Close"); Close.Click += (o, f) => { td.Close(); }; td.Controls.Add(Copy); td.Controls.Add(Close); td.ShowDialog(this.Handle); }); } }
//タスクダイアログ private TaskDialogResult TaskDialogShow(Exception ex, bool isUnhandledException) { var dialog = new TaskDialog(); dialog.Caption = "Manage your Life"; dialog.InstructionText = "エラーが発生しました"; dialog.Text = "Manage your Lifeを終了します。"; dialog.DetailsCollapsedLabel = "エラー情報"; dialog.DetailsExpandedLabel = "エラー情報を非表示"; dialog.DetailsExpandedText = ex.GetType().ToString() + "\n" + ex.Message; dialog.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandContent; dialog.DetailsExpanded = false; dialog.Icon = TaskDialogStandardIcon.Error; dialog.Opened += dialog_Opened; /* var link2 = new TaskDialogCommandLink("link2", "プログラムを終了します"); link2.Default = true; link2.Click += (sender, e) => dialog.Close(TaskDialogResult.Cancel); dialog.Controls.Add(link2); var link1 = new TaskDialogCommandLink("link1", "プログラムを再起動します"); link1.Click += (sender, e) => dialog.Close(TaskDialogResult.Ok); dialog.Controls.Add(link1); var link3 = new TaskDialogCommandLink("link3", "無視します"); link3.Click += (sender, e) => dialog.Close(TaskDialogResult.None); dialog.Controls.Add(link3); */ var shutButton = new TaskDialogButton(); shutButton.Text = "終了"; shutButton.Default = true; shutButton.Click += (sender, e) => dialog.Close(TaskDialogResult.Cancel); dialog.Controls.Add(shutButton); var rebootButton = new TaskDialogButton(); rebootButton.Text = "再起動"; rebootButton.Click += (sender, e) => dialog.Close(TaskDialogResult.Ok); dialog.Controls.Add(rebootButton); if (!isUnhandledException) { var continueButton = new TaskDialogButton(); continueButton.Text = "続行"; continueButton.Click += (sender, e) => dialog.Close(TaskDialogResult.None); dialog.Controls.Add(continueButton); } return dialog.Show(); }
private void BuyWall(string wallName, Wall wall, int price) { if (!this.CheckMoney(price)) return; if (this.vm.Field.Walls.All(w => w != null)) { MessageBox.Show("設置できる場所がありません。", "壁を買う"); return; } var dialog = new TaskDialog(); dialog.Caption = "壁を買う"; dialog.InstructionText = wallName; dialog.Text = "設置場所を選択してください。"; dialog.Cancelable = true; dialog.OwnerWindowHandle = new WindowInteropHelper(Window.GetWindow(this)).Handle; if (this.vm.Field.Walls[2] == null) { var left = new TaskDialogButton(); left.Text = "左"; left.Click += (_, __) => { for (var i = 0; i < 3; i++) { if (this.vm.Field.Walls[i] == null) { this.vm.Field.SetWall(wall, i); break; } } dialog.Close(TaskDialogResult.Ok); }; dialog.Controls.Add(left); } if (this.vm.Field.Walls[5] == null) { var center = new TaskDialogButton(); center.Text = "中央"; center.Click += (_, __) => { for (var i = 3; i < 6; i++) { if (this.vm.Field.Walls[i] == null) { this.vm.Field.SetWall(wall, i); break; } } dialog.Close(TaskDialogResult.Ok); }; dialog.Controls.Add(center); } if (this.vm.Field.Walls[8] == null) { var right = new TaskDialogButton(); right.Text = "右"; right.Click += (_, __) => { for (var i = 6; i < 9; i++) { if (this.vm.Field.Walls[i] == null) { this.vm.Field.SetWall(wall, i); break; } } dialog.Close(TaskDialogResult.Ok); }; dialog.Controls.Add(right); } if (dialog.Show() == TaskDialogResult.Ok) this.vm.Field.Money -= price; }
// Called when a control currently in the collection // has a property changed - this handles propagating // the new property values to the Win32 API. // If there isn't a way to change the Win32 value, then we // should have already screened out the property set // in NotifyControlPropertyChanging. void IDialogControlHost.ApplyControlPropertyChange(string propertyName, DialogControl control) { // We only need to apply changes to the // native dialog when it actually exists. if (NativeDialogShowing) { if (control is TaskDialogProgressBar) { if (!progressBar.HasValidValues) { throw new ArgumentException( "Progress bar must have a value between Minimum and Maximum."); } switch (propertyName) { case "State": nativeDialog.UpdateProgressBarState(progressBar.State); break; case "Value": nativeDialog.UpdateProgressBarValue(progressBar.Value); break; case "Minimum": case "Maximum": nativeDialog.UpdateProgressBarRange(); break; default: Debug.Assert(true, "Unknown property being set"); break; } } else if (control is TaskDialogButton) { TaskDialogButton button = (TaskDialogButton)control; switch (propertyName) { case "ShowElevationIcon": nativeDialog.UpdateElevationIcon(button.Id, button.ShowElevationIcon); break; case "Enabled": nativeDialog.UpdateButtonEnabled(button.Id, button.Enabled); break; default: Debug.Assert(true, "Unknown property being set"); break; } } else if (control is TaskDialogRadioButton) { TaskDialogRadioButton button = (TaskDialogRadioButton)control; switch (propertyName) { case "Enabled": nativeDialog.UpdateRadioButtonEnabled(button.Id, button.Enabled); break; default: Debug.Assert(true, "Unknown property being set"); break; } } else { // Do nothing with property change - // note that this shouldn't ever happen, we should have // either thrown on the changing event, or we handle above. Debug.Assert(true, "Control property changed notification not handled properly - being ignored"); } } return; }