/// <summary> /// Opens a message box window and returns only when a newly opened window is closed. /// </summary> /// <param name="text"> /// Specify the text of the window. /// </param> /// <param name="header"> /// Specify the header text of the window. /// </param> /// <param name="buttonType"> /// Specify what buttons will be on the window. /// </param> /// <returns> /// A <see cref="System.Nullable"/> value of type <see cref="Boolean"/> that specifies whether the activity was accepted (true) or canceled (false). /// <para/> /// The return value is the value of the <see cref="System.Windows.Window.DialogResult"/> property before a window closes. /// </returns> /// <exception cref="InvalidOperationException"> /// Throws when message box is not registered. /// </exception> /// <exception cref="InvalidCastException"> /// Throws when registered dialog does not inherit default interface /// </exception> public bool?ShowMessageWindow(string text, string header, MessageBoxButton buttonType) { // make default instance IMessageBox messageBox = MakeInstance(initializerBase.MessageBoxName) as IMessageBox; // throw exception if not the message box if (messageBox == null) { throw new InvalidCastException(string.Concat(Core.Messages.Error.View.WINDOW_MANAGER_DIALOG_DOES_NOT_INHERIT_DEFAULT_INTERFACE_FORMAT, nameof(IMessageBox))); } // sets up all values messageBox.Header = header; messageBox.Text = text; // show window and return result return(messageBox.ShowDialog(buttonType)); }
public bool?ShowMessageBoxWindow(string text, string header, MessageBoxButton buttonType) { // make default instance IMessageBox messageBox = MakeInstance(initializerBase.MessageBoxName) as IMessageBox; // throw exception if not the message box if (messageBox == null) { throw new InvalidCastException($"Dialog does not inherit default interface {nameof(IMessageBox)}"); } // sets up all values messageBox.Header = header; messageBox.Text = text; // show window and return result return(messageBox.ShowDialog(buttonType)); }
public bool MyMethod(string arg) { var result = _MessageBox.ShowDialog(); return(result == DialogResult.Ok); }