private void DisplayButtons(CustomMessageBoxButton button) { switch (button) { case CustomMessageBoxButton.OKCancel: // Hide all but OK, Cancel Button_OK.Visibility = System.Windows.Visibility.Visible; Button_OK.Focus(); Button_Cancel.Visibility = System.Windows.Visibility.Visible; Button_Yes.Visibility = System.Windows.Visibility.Collapsed; Button_No.Visibility = System.Windows.Visibility.Collapsed; break; case CustomMessageBoxButton.YesNo: // Hide all but Yes, No Button_Yes.Visibility = System.Windows.Visibility.Visible; Button_Yes.Focus(); Button_No.Visibility = System.Windows.Visibility.Visible; Button_OK.Visibility = System.Windows.Visibility.Collapsed; Button_Cancel.Visibility = System.Windows.Visibility.Collapsed; break; case CustomMessageBoxButton.YesNoCancel: // Hide only OK Button_Yes.Visibility = System.Windows.Visibility.Visible; Button_Yes.Focus(); Button_No.Visibility = System.Windows.Visibility.Visible; Button_Cancel.Visibility = System.Windows.Visibility.Visible; Button_OK.Visibility = System.Windows.Visibility.Collapsed; break; case CustomMessageBoxButton.OKYesNoCancel: // Don't hide anything Button_OK.Visibility = System.Windows.Visibility.Visible; Button_OK.Focus(); Button_Yes.Visibility = System.Windows.Visibility.Visible; Button_No.Visibility = System.Windows.Visibility.Visible; Button_Cancel.Visibility = System.Windows.Visibility.Visible; break; default: // Hide all but OK Button_OK.Visibility = System.Windows.Visibility.Visible; Button_OK.Focus(); Button_Yes.Visibility = System.Windows.Visibility.Collapsed; Button_No.Visibility = System.Windows.Visibility.Collapsed; Button_Cancel.Visibility = System.Windows.Visibility.Collapsed; break; } }
private void DisplayButtons(AltMessageBoxButton button) { Button_OK.Visibility = button.useOK ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; Button_Yes.Visibility = button.useYes ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; Button_No.Visibility = button.useNo ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; Button_Cancel.Visibility = button.useCancel ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; Button_Abort.Visibility = button.useAbort ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; Button_Retry.Visibility = button.useRetry ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; Button_YesToAll.Visibility = button.useYesToAll ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; Button_NoToAll.Visibility = button.useNoToAll ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed; switch (button.Default) { case AltMessageBoxResult.None: break; case AltMessageBoxResult.OK: Button_OK.Focus(); break; case AltMessageBoxResult.Cancel: Button_Cancel.Focus(); break; case AltMessageBoxResult.Yes: Button_Yes.Focus(); break; case AltMessageBoxResult.No: Button_No.Focus(); break; case AltMessageBoxResult.Abort: Button_Abort.Focus(); break; case AltMessageBoxResult.Retry: Button_Retry.Focus(); break; case AltMessageBoxResult.YesToAll: Button_YesToAll.Focus(); break; case AltMessageBoxResult.NoToAll: Button_NoToAll.Focus(); break; default: break; } }
private void DisplayButtons(MessageBoxButton button) { switch (button) { case MessageBoxButton.OKCancel: // Hide all but OK, Cancel MsBox.Icon = (DrawingImage)MsBox.FindResource("quest"); Button_OK.Visibility = System.Windows.Visibility.Visible; Button_OK.Focus(); Button_Cancel.Visibility = System.Windows.Visibility.Visible; Button_Yes.Visibility = System.Windows.Visibility.Collapsed; Button_No.Visibility = System.Windows.Visibility.Collapsed; break; case MessageBoxButton.YesNo: // Hide all but Yes, No Button_Yes.Visibility = System.Windows.Visibility.Visible; Button_Yes.Focus(); Button_No.Visibility = System.Windows.Visibility.Visible; Button_OK.Visibility = System.Windows.Visibility.Collapsed; Button_Cancel.Visibility = System.Windows.Visibility.Collapsed; break; case MessageBoxButton.YesNoCancel: // Hide only OK Button_Yes.Visibility = System.Windows.Visibility.Visible; Button_Yes.Focus(); Button_No.Visibility = System.Windows.Visibility.Visible; Button_Cancel.Visibility = System.Windows.Visibility.Visible; Button_OK.Visibility = System.Windows.Visibility.Collapsed; break; default: // Hide all but OK MsBox.Icon = (DrawingImage)MsBox.FindResource("Iserror"); Button_OK.Visibility = System.Windows.Visibility.Visible; Button_OK.Focus(); Button_Yes.Visibility = System.Windows.Visibility.Collapsed; Button_No.Visibility = System.Windows.Visibility.Collapsed; Button_Cancel.Visibility = System.Windows.Visibility.Collapsed; break; } }
private void DisplayButtons(MessageBoxButton button) { switch (button) { case MessageBoxButton.OKCancel: // Hide all but OK, Cancel Button_OK.Visibility = Visibility.Visible; Button_OK.Focus(); Button_Cancel.Visibility = Visibility.Visible; Button_Yes.Visibility = Visibility.Collapsed; Button_No.Visibility = Visibility.Collapsed; break; case MessageBoxButton.YesNo: // Hide all but Yes, No Button_Yes.Visibility = Visibility.Visible; Button_Yes.Focus(); Button_No.Visibility = Visibility.Visible; Button_OK.Visibility = Visibility.Collapsed; Button_Cancel.Visibility = Visibility.Collapsed; break; case MessageBoxButton.YesNoCancel: // Hide only OK Button_Yes.Visibility = Visibility.Visible; Button_Yes.Focus(); Button_No.Visibility = Visibility.Visible; Button_Cancel.Visibility = Visibility.Visible; Button_OK.Visibility = Visibility.Collapsed; break; default: // Hide all but OK Button_OK.Visibility = Visibility.Visible; Button_OK.Focus(); Button_Yes.Visibility = Visibility.Collapsed; Button_No.Visibility = Visibility.Collapsed; Button_Cancel.Visibility = Visibility.Collapsed; break; } }
internal MessageBoxWindow(string message, string caption, MessageBoxButton button, MessageBoxImage icon) { InitializeComponent(); // Imposta testo Message.Text = message; Title = caption ?? Process.GetCurrentProcess().ProcessName; // Imposta bottoni switch (button) { case MessageBoxButton.OKCancel: Button_Yes.Visibility = Visibility.Collapsed; Button_No.Visibility = Visibility.Collapsed; Button_OK.Content = Helper.GetOk(); Button_Cancel.Content = Helper.GetCancel(); Button_OK.Focus(); Theming.SetAccented(Button_OK, true); break; case MessageBoxButton.YesNo: Button_OK.Visibility = Visibility.Collapsed; Button_Cancel.Visibility = Visibility.Collapsed; Button_Yes.Content = Helper.GetYes(); Button_No.Content = Helper.GetNo(); Button_Yes.Focus(); Theming.SetAccented(Button_Yes, true); break; case MessageBoxButton.YesNoCancel: Button_OK.Visibility = Visibility.Collapsed; Button_Yes.Content = Helper.GetYes(); Button_No.Content = Helper.GetNo(); Button_Cancel.Content = Helper.GetCancel(); Button_Yes.Focus(); break; case MessageBoxButton.OK: Button_Yes.Visibility = Visibility.Collapsed; Button_No.Visibility = Visibility.Collapsed; Button_Cancel.Visibility = Visibility.Collapsed; Button_OK.Content = Helper.GetOk(); Button_OK.Focus(); break; } // Imposta icona switch (icon) { case MessageBoxImage.Exclamation: // Enumeration value 48 - also covers "Warning" Image.Content = "\uE7BA"; Image.Visibility = Visibility.Visible; break; case MessageBoxImage.Error: // Enumeration value 16, also covers "Hand" and "Stop" Image.Content = "\uEA39"; Image.Visibility = Visibility.Visible; break; case MessageBoxImage.Information: // Enumeration value 64 - also covers "Asterisk" Image.Content = "\uE946"; Image.Visibility = Visibility.Visible; break; case MessageBoxImage.Question: Image.Content = "\uE9CE"; Image.Visibility = Visibility.Visible; break; } }