Exemple #1
0
        /// <summary>
        /// Get the default value to use for the message-box timeout, in seconds, for the given type of message-box.
        /// </summary>
        public static int GetDefaultTimeoutValueFor(JhMessageBoxType forWhatTypeOfMessageBox)
        {
            int t;

            switch (forWhatTypeOfMessageBox)
            {
            case JhMessageBoxType.Warning:
                t = 15;
                break;

            case JhMessageBoxType.Error:
            case JhMessageBoxType.SecurityIssue:
                t = 30;
                break;

            case JhMessageBoxType.Question:
                t = 60;
                break;

            default:
                t = 10;
                break;
            }
            return(t);
        }
Exemple #2
0
        /// <summary>
        /// Produce an audial beep sound, which corresponds to the default system sound that (more or less)
        /// corresponds to that of the given message-box type.
        /// </summary>
        /// <param name="messageType">A JhMessageBoxType which influences the type of beep sound that is made</param>
        public static void MessageBeep(JhMessageBoxType messageType)
        {
            // Try to map the messageType to a value that corresponds to what the original Win32 icon would be..
            string soundEventName;

            switch (messageType)
            {
            case JhMessageBoxType.Information:
                soundEventName = "SystemAsterisk";
                break;

            case JhMessageBoxType.Question:
                soundEventName = "SystemQuestion";
                break;

            case JhMessageBoxType.Warning:
                soundEventName = "SystemExclamation";
                break;

            case JhMessageBoxType.Error:
            case JhMessageBoxType.UserMistake:
                soundEventName = "AppGPFault";
                break;

            case JhMessageBoxType.SecurityIssue:
                soundEventName = "WindowsUAC";
                break;

            case JhMessageBoxType.SecuritySuccess:
                soundEventName = "SystemNotification";
                break;

            case JhMessageBoxType.Stop:
                soundEventName = "SystemHand";     // Critical Stop
                break;

            default:
                soundEventName = "Default Beep";
                break;
            }
            //Console.WriteLine("soundEventName is " + soundEventName);
            AudioLib.PlaySoundEvent(soundEventName);
        }
 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, 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>
 /// Static method to display a message-box to the user. Wait for his response or else close itself after the timeout has expired.
 /// This assumes only an Ok button, that it wants to be a top-most window and a timeout of five seconds.
 /// </summary>
 /// <param name="ofWhat">the text 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="timeout">the maximum time to show it, in seconds (optional - the default is 5)</param>
 /// <param name="parent">the visual-element to consider as the parent, or owner, of this message-box (optional)</param>
 public static void AlertUser(string ofWhat,
     JhMessageBoxType messageType = JhMessageBoxType.Information,
     string captionAfterPrefix = null,
     int timeout = 5,  // Assume five seconds for the timeout value unless it is explicitly specified.
     FrameworkElement parent = null)
 {
     JhMessageBox.GetNewInstance(Application.Current).NotifyUser(summaryText: ofWhat,
                                                                 detailText: null,
                                                                 buttons: JhMessageBoxButtons.Ok,
                                                                 messageType: messageType,
                                                                 captionAfterPrefix: captionAfterPrefix,
                                                                 isTopmostWindow: true,
                                                                 timeout: timeout,
                                                                 parent: parent);
 }
 /// <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>
 /// Create a new JhMessageBoxOptions object with the given JhMessageBoxType and default values.
 /// </summary>
 public JhMessageBoxOptions(JhMessageBoxType whichType)
     : this()
 {
     this._messageType = whichType;
 }
Exemple #11
0
 /// <summary>
 /// Set the basic type of this message-box (i.e., Information, Warning, Error, etc.). Default is None.
 /// </summary>
 /// <param name="messageBoxType">an enum-type that defines the basic purpose of this message-box</param>
 /// <returns>a reference to this same object such that other method-calls may be chained</returns>
 public JhMessageBoxOptions SetMessageType(JhMessageBoxType messageBoxType)
 {
     _messageType = messageBoxType;
     return(this);
 }
Exemple #12
0
 /// <summary>
 /// Create a new JhMessageBoxOptions object with the given JhMessageBoxType and default values.
 /// </summary>
 public JhMessageBoxOptions(JhMessageBoxType whichType)
     : this()
 {
     this._messageType = whichType;
 }
 /// <summary>
 /// Produce an audial beep sound, which corresponds to the default system sound that (more or less)
 /// corresponds to that of the given message-box type.
 /// </summary>
 /// <param name="messageType">A JhMessageBoxType which influences the type of beep sound that is made</param>
 public static void MessageBeep(JhMessageBoxType messageType)
 {
     // Try to map the messageType to a value that corresponds to what the original Win32 icon would be..
     string soundEventName;
     switch (messageType)
     {
         case JhMessageBoxType.Information:
             soundEventName = "SystemAsterisk";
             break;
         case JhMessageBoxType.Question:
             soundEventName = "SystemQuestion";
             break;
         case JhMessageBoxType.Warning:
             soundEventName = "SystemExclamation";
             break;
         case JhMessageBoxType.Error:
         case JhMessageBoxType.UserMistake:
             soundEventName = "AppGPFault";
             break;
         case JhMessageBoxType.SecurityIssue:
             soundEventName = "WindowsUAC";
             break;
         case JhMessageBoxType.SecuritySuccess:
             soundEventName = "SystemNotification";
             break;
         case JhMessageBoxType.Stop:
             soundEventName = "SystemHand"; // Critical Stop
             break;
         default:
             soundEventName = "Default Beep";
             break;
     }
     //Console.WriteLine("soundEventName is " + soundEventName);
     AudioLib.PlaySoundEvent(soundEventName);
 }
        private void btnBeep_Click(object sender, RoutedEventArgs e)
        {
            JhMessageBoxType messageBoxType = this.JhMessageBoxTypeToUse;

            JhMessageBoxWindow.MessageBeep(messageBoxType);
        }