private void btnTaskDialog_Click(object sender, RoutedEventArgs e) { uint iTimeout = (uint)this.TimeToDisplayIt; Window parentWindow = null; if (_viewModel.IsIncludingParentWindow) { parentWindow = this; } JhMessageBoxButtons buttons = GetButtonsToShow(); //TaskDialogIcon iconToShow = TaskDialogIconToUse; string summary = _viewModel.SummaryText; string sText = _viewModel.DetailText; //string sCaption = CaptionAfterPrefix; //TaskDialogs.NotifyUser(sMessage: MessageToUser, sMessageAdditional: "additional stuff", sCaption: CaptionAfterPrefix, icon: iconToShow, timeout: iTimeout); }
/// <summary> /// See whether the TestFacility.ButtonResultToSelect is present amongst the given JhMessageBoxButtons /// and return true if it is. /// </summary> /// <param name="buttonFlags">the buttons to check against, to see whether the one that is required is present</param> /// <returns>true if the ButtonResultToSelect is included within the given buttonFlags, false otherwise</returns> internal bool GetWhetherButtonIsIncluded(JhMessageBoxButtons buttonFlags, out string complaint) { complaint = String.Empty; bool isOkay = true; if (_testFacility != null) { JhDialogResult? desiredResult = _testFacility.ButtonResultToSelect; if (desiredResult.HasValue) { switch (desiredResult) { case JhDialogResult.Abort: if ((buttonFlags & JhMessageBoxButtons.Cancel) == 0) { // If testing, and the test calls for this button to be selected - complain that it won't be possible. complaint = "You want the Cancel button to be selected, but that button is not being shown!"; isOkay = false; } break; case JhDialogResult.Cancel: if ((buttonFlags & JhMessageBoxButtons.Cancel) == 0) { // If testing, and the test calls for this button to be selected - complain that it won't be possible. complaint = "You want the Cancel button to be selected, but that button is not being shown!"; isOkay = false; } break; case JhDialogResult.Close: if ((buttonFlags & JhMessageBoxButtons.Close) == 0) { // If testing, and the test calls for this button to be selected - complain that it won't be possible. complaint = "You want the Close button to be selected, but that button is not being shown!"; isOkay = false; } break; case JhDialogResult.Ignore: if ((buttonFlags & JhMessageBoxButtons.Ignore) == 0) { // If testing, and the test calls for this button to be selected - complain that it won't be possible. complaint = "You want the Ignore button to be selected, but that button is not being shown!"; isOkay = false; } break; case JhDialogResult.No: if ((buttonFlags & JhMessageBoxButtons.No) == 0) { // If testing, and the test calls for this button to be selected - complain that it won't be possible. complaint = "You want the No button to be selected, but that button is not being shown!"; isOkay = false; } break; case JhDialogResult.Ok: if ((buttonFlags & JhMessageBoxButtons.Ok) == 0) { // If testing, and the test calls for this button to be selected - complain that it won't be possible. complaint = "You want the Ok button to be selected, but that button is not being shown!"; isOkay = false; } break; case JhDialogResult.Retry: if ((buttonFlags & JhMessageBoxButtons.Retry) == 0) { // If testing, and the test calls for this button to be selected - complain that it won't be possible. complaint = "You want the Retry button to be selected, but that button is not being shown!"; isOkay = false; } break; case JhDialogResult.Yes: if ((buttonFlags & JhMessageBoxButtons.Yes) == 0) { // If testing, and the test calls for this button to be selected - complain that it won't be possible. complaint = "You want the Yes button to be selected, but that button is not being shown!"; isOkay = false; } break; default: break; } } } return isOkay; }
public JhDialogResult Show(string messageBoxText, string caption, JhMessageBoxButtons buttons, JhMessageBoxType messageType, JhDialogResult defaultResult, FrameworkElement owner) { int defaultTimeout = JhMessageBoxOptions.GetDefaultTimeoutValueFor(messageType); #if !SILVERLIGHT JhDialogResult r = NotifyUser(summaryText: messageBoxText, detailText: "", buttons: buttons, messageType: messageType, captionAfterPrefix: caption, timeout: defaultTimeout, parent: owner); #else JhDialogResult r = NotifyUser(messageBoxText, "", caption, buttons, messageType, defaultTimeout); #endif // In this library, we ordinarily consider the TimedOut result to be the default result, // but here the caller of this method has specified a specific defaultResult. if (r == JhDialogResult.TimedOut) { r = defaultResult; } return r; }
public JhDialogResult Show(string messageBoxText, string caption, JhMessageBoxButtons buttons, FrameworkElement owner) { return Show(messageBoxText, caption, buttons, JhMessageBoxType.None, _defaultResult, owner); }
public JhDialogResult Show(string messageBoxText, string caption, JhMessageBoxButtons buttons, JhMessageBoxType messageType, JhDialogResult defaultResult) { #if !SILVERLIGHT FrameworkElement owner = Application.Current.MainWindow; return Show(messageBoxText, caption, buttons, messageType, _defaultResult, owner); #else return Show(messageBoxText, caption, buttons, messageType, _defaultResult); #endif }
public JhDialogResult Show(string messageBoxText, string caption, JhMessageBoxButtons buttons, JhMessageBoxType messageType) { return Show(messageBoxText, caption, buttons, messageType, _defaultResult); }
/// <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 false)</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 JhDialogResult 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, JhMessageBoxButtons buttons, JhMessageBoxType messageType = JhMessageBoxType.Information, string captionAfterPrefix = null, bool isTopmostWindow = false, int timeoutInSeconds = 0, // Assume zero for the timeout value, which invokes the default value. FrameworkElement parent = null) { // Use the default options for everything except that which is explicitly set for this instance. var options = new JhMessageBoxOptions(DefaultOptions) .SetButtonFlags(buttons) .SetCaptionAfterPrefix(captionAfterPrefix) .SetDetailText(detailText) .SetSummaryText(summaryText) .SetIsAsynchronous(true) .SetToBeTopmostWindow(isTopmostWindow) .SetMessageType(messageType) .SetTimeoutPeriod(timeoutInSeconds) .SetParent(parent); 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 (optional - defaults to 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 make the message-box the top-most window on the user's desktop (optional - defaults to false)</param> /// <param name="timeout">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 JhDialogResult indicating which action the user took, or TimedOut if the user took no action before the timeout expired</returns> public JhDialogResult NotifyUser(string summaryText, string detailText, JhMessageBoxButtons buttons, JhMessageBoxType messageType = JhMessageBoxType.Information, string captionAfterPrefix = null, bool isTopmostWindow = false, int timeout = 0, // Assume zero for the timeout value, which invokes the default value. FrameworkElement parent = null) { // Use the default options for everything except that which is explicitly set for this instance. var options = new JhMessageBoxOptions(DefaultOptions); options.SummaryText = summaryText; options.DetailText = detailText; options.CaptionAfterPrefix = captionAfterPrefix; options.ButtonFlags = buttons; options.MessageType = messageType; options.IsToBeTopmostWindow = isTopmostWindow; #if !SILVERLIGHT options.ParentElement = parent; #endif options.TimeoutPeriodInSeconds = timeout; return NotifyUser(options); }
/// <summary> /// The Copy-Constructor. This does NOT copy the SummaryText or DetailText. /// </summary> /// <param name="source">the JhMessageBoxOptions object to copy the values from</param> public JhMessageBoxOptions(JhMessageBoxOptions source) { this._backgroundTexture = source.BackgroundTexture; this._buttonFlags = source._buttonFlags; // this._captionPrefix = source.CaptionPrefix; this._captionAfterPrefix = source.CaptionAfterPrefix; this._captionForUserMistakes = source.CaptionForUserMistakes; this._isCustomButtonStyles = source.IsCustomButtonStyles; this._isSoundEnabled = source.IsSoundEnabled; this._isToCenterOverParent = source.IsToCenterOverParent; this._isToBeTopmostWindow = source.IsToBeTopmostWindow; this._isTouch = source.IsTouch; this._isUsingAeroGlassEffect = source.IsUsingAeroGlassEffect; this._isUsingNewerIcons = source.IsUsingNewerIcons; this._isUsingNewerSoundScheme = source.IsUsingNewerSoundScheme; this._messageType = source.MessageType; this._timeoutPeriodInSeconds = source.TimeoutPeriodInSeconds; this._timeoutPeriodForUserMistakes = source.TimeoutPeriodForUserMistakes; }
/// <summary> /// Set the flags that dictate which buttons to show. The default is to just show the "Ok" button. /// </summary> /// <param name="buttons">A bitwise-combination of the enum flags defining which buttons to show</param> /// <returns>a reference to this same object such that other method-calls may be chained</returns> public JhMessageBoxOptions SetButtonFlags(JhMessageBoxButtons buttons) { _buttonFlags = buttons; return(this); }