private void DebugToolstripItem_Click(object sender, RoutedEventArgs e) { if (settings.AdvancedMode) { var parent = Application.Current.MainWindow; DebugDialog debugWnd = new DebugDialog(dramBaseAddress, modules, MEMCFG, SI, BMC, PowerTable, OPS) { Owner = parent }; debugWnd.Width = parent.Width; debugWnd.Height = parent.Height; debugWnd.Show(); } else { var messageBox = new AdonisUI.Controls.MessageBoxModel { Text = "Debug functionality requires Advanced Mode.\n\n" + "Do you want to enable it now (the application will restart automatically)?", Caption = "Debug Report", Buttons = AdonisUI.Controls.MessageBoxButtons.YesNoCancel() }; AdonisUI.Controls.MessageBox.Show(messageBox); if (messageBox.Result == AdonisUI.Controls.MessageBoxResult.Yes) { settings.AdvancedMode = true; Restart(); } } }
/// <summary> /// Displays a message box that has a message and that returns a result. /// </summary> /// <param name="text">A <see cref="String"/> that specifies the text to display.</param> /// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns> public static MessageBoxResult Show(string text) { var messageBoxModel = new MessageBoxModel { Text = text, }; return(Show(messageBoxModel)); }
/// <summary> /// Displays a message box in front of the specified window. The message box displays a message, title bar caption, button, and icon; and accepts a default message box result and returns a result. /// </summary> /// <param name="owner">A <see cref="Window"/> that represents the owner window of the message box.</param> /// <param name="text">A <see cref="String"/> that specifies the text to display.</param> /// <param name="caption">A <see cref="String"/> that specifies the title bar caption to display.</param> /// <param name="buttons">A <see cref="MessageBoxButton"/> value that specifies which button or buttons to display.</param> /// <param name="icon">A <see cref="MessageBoxImage"/> value that specifies the icon to display.</param> /// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the default result of the message box.</param> /// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns> public static MessageBoxResult Show(Window owner, string text, string caption = null, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxImage icon = MessageBoxImage.None, MessageBoxResult defaultResult = MessageBoxResult.None) { var messageBoxModel = new MessageBoxModel { Text = text, Caption = caption, Buttons = MessageBoxButtons.Create(buttons), Icon = icon, }; messageBoxModel.SetDefaultButton(defaultResult); return(Show(owner, messageBoxModel)); }