public MessageResult NotifyUserOfMistake(string summaryText, string detailText, string captionAfterPrefix, Object parent) #endif { //TODO: May want to provide for the possibility of having other buttons for this type of message-box. ? // Use the default options for everything except that which is explicitly set for this instance. var options = new MessageBoxConfiguration(this.Configuration); // Derive a timeout value.. int timeout = 0; if (_defaultConfiguration != null) { timeout = DefaultConfiguration.GetDefaultTimeoutValueFor(MessageBoxType.UserMistake); } if (timeout == 0) { timeout = DefaultConfiguration.GetDefaultTimeoutValueFor(MessageBoxType.UserMistake); } // Derive a suitable text to use for the message-box caption if none was specified.. string whatToUseForCaptionAfterPrefix = captionAfterPrefix; if (StringLib.HasNothing(whatToUseForCaptionAfterPrefix)) { if (DefaultConfiguration.DefaultCaptionForUserMistakes != null) { whatToUseForCaptionAfterPrefix = DefaultConfiguration.DefaultCaptionForUserMistakes; } else { //TODO: May want to be a little more creative here. whatToUseForCaptionAfterPrefix = "Oops!"; } } #if SILVERLIGHT return NotifyUser(summaryText, detailText, whatToUseForCaptionAfterPrefix, MessageBoxButtons.Ok, MessageBoxType.UserMistake, timeout); #else options.SummaryText = summaryText; options.DetailText = detailText; options.CaptionAfterPrefix = whatToUseForCaptionAfterPrefix; options.ButtonFlags = MessageBoxButtons.Ok; options.MessageType = MessageBoxType.UserMistake; options.ParentElement = (FrameworkElement)parent; options.TimeoutPeriodInSeconds = timeout; return NotifyUser(options); #endif }
/// <summary> /// Display a message-box to the user. Wait for his response or else close itself after the timeout has expired. /// This is the overload that has all of the options, which the other methods call. /// </summary> /// <param name="summaryText">the summary text to show in the upper area</param> /// <param name="detailText">the detail text to show in the lower area</param> /// <param name="buttons">which buttons to show</param> /// <param name="messageType">the basic type of message-box to show (optional - default is Information)</param> /// <param name="captionAfterPrefix">what to show in the titlebar of this message-box, after the standard prefix (optional)</param> /// <param name="isTopmostWindow">whether to force this message-box to be over top of all other windows (optional - default is null which means DefaultConfiguration.IsTopmostByDefault dictates)</param> /// <param name="timeoutInSeconds">the maximum time to show it, in seconds (optional)</param> /// <param name="parent">the visual-element to consider as the parent, or owner, of this message-box (optional)</param> /// <returns>a MessageResult indicating which action the user took, or TimedOut if the user took no action before the timeout expired</returns> public void NotifyUserAsync(string summaryText, string detailText, MessageBoxButtons buttons, MessageBoxType messageType = MessageBoxType.Information, string captionAfterPrefix = null, bool? isTopmostWindow = null, int timeoutInSeconds = 0, // Assume zero for the timeout value, which invokes the default value. Object parent = null) { // Use the default options for everything except that which is explicitly set for this instance. var options = new MessageBoxConfiguration(this.Configuration) .SetButtonFlags(buttons) .SetCaptionAfterPrefix(captionAfterPrefix) .SetDetailText(detailText) .SetSummaryText(summaryText) .SetIsAsynchronous(true) .SetMessageType(messageType) .SetTimeoutPeriod(timeoutInSeconds) .SetParent((FrameworkElement)parent); if (isTopmostWindow.HasValue) { options.SetToBeTopmostWindow(isTopmostWindow.Value); } else { options.SetToBeTopmostWindow(MessageBox.DefaultConfiguration.IsTopmostWindowByDefault); } NotifyUser(options); }
/// <summary> /// Display a message-box to the user as a non-modal dialog window, and return immediately. /// The message-type is assumed to be MessageBoxType.Information /// </summary> /// <param name="summaryText">the summary text to show in the upper area</param> /// <param name="detailText">the detail text to show in the lower area</param> /// <param name="captionAfterPrefix">what to show in the titlebar of this message-box, after the standard prefix (set to null to accept default)</param> /// <param name="parent">the visual-element to consider as the parent, or owner, of this message-box (optional)</param> public void NotifyUserAsync(string summaryText, string detailText, string captionAfterPrefix, Object parent = null) { var options = new MessageBoxConfiguration(this.Configuration) .SetButtonFlags(MessageBoxButtons.Ok) .SetCaptionAfterPrefix(captionAfterPrefix) .SetDetailText(detailText) .SetSummaryText(summaryText) .SetIsAsynchronous(true) .SetMessageType(MessageBoxType.Information) .SetParent((FrameworkElement)parent) .SetTimeoutPeriod(0); NotifyUser(options); }
/// <summary> /// Display a message-box to the user. Wait for his response or else close itself after the timeout has expired. /// This is the overload that has all of the options, which the other methods call. /// </summary> /// <param name="summaryText">the summary text to show in the upper area</param> /// <param name="detailText">the detail text to show in the lower area</param> /// <param name="buttons">which buttons to show</param> /// <param name="messageType">which basic type of message this is</param> /// <param name="captionAfterPrefix">what to show in the titlebar of this message-box, after the standard prefix (may be null)</param> /// <param name="isTopmostWindow">whether to make the message-box the top-most window on the user's desktop (may be null to just accept the default)</param> /// <param name="timeout">the maximum time to show it, in seconds (make this zero to accept the default)</param> /// <param name="parent">the visual-element to consider as the parent, or owner, of this message-box (may be null)</param> /// <returns>a MessageResult indicating which action the user took, or TimedOut if the user took no action before the timeout expired</returns> public MessageResult NotifyUser(string summaryText, string detailText, MessageBoxButtons buttons, MessageBoxType messageType, string captionAfterPrefix, bool? isTopmostWindow, int timeout, // Assume zero for the timeout value, which invokes the default value. Object parent) { // Use the default options for everything except that which is explicitly set for this instance. var options = new MessageBoxConfiguration(this.Configuration); options.SummaryText = summaryText; options.DetailText = detailText; options.CaptionAfterPrefix = captionAfterPrefix; options.ButtonFlags = buttons; options.MessageType = messageType; if (isTopmostWindow.HasValue) { options.IsToBeTopmostWindow = isTopmostWindow.Value; } else { options.IsToBeTopmostWindow = DefaultConfiguration.IsTopmostWindowByDefault; } #if !SILVERLIGHT options.ParentElement = (FrameworkElement)parent; #endif options.TimeoutPeriodInSeconds = timeout; return NotifyUser(options); }
public MessageResult WarnUser(string summaryText, string detailText, string captionAfterPrefix, Object parent) #endif { // Use the default options for everything except that which is explicitly set for this instance. var options = new MessageBoxConfiguration(this.Configuration); options.SummaryText = summaryText; options.DetailText = detailText; options.CaptionAfterPrefix = captionAfterPrefix; options.ButtonFlags = MessageBoxButtons.Ok; options.MessageType = MessageBoxType.Warning; options.IsToBeTopmostWindow = DefaultConfiguration.IsTopmostWindowByDefault; #if !SILVERLIGHT options.ParentElement = (FrameworkElement)parent; #endif options.TimeoutPeriodInSeconds = 0; // Assume zero for the timeout value, which invokes the default value. return NotifyUser(options); }
/// <summary> /// Set the options to use for message-boxes. /// </summary> /// <param name="options">The MessageBoxConfiguration that contains the options you want to set (the MessageType property is ignored)</param> public void SetConfiguration(MessageBoxConfiguration options) { this.Configuration = options; }