示例#1
0
 /// <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;
 }
        public void TC01_NotifyUser_VerifyTextWithinSummaryAndDetail()
        {
            using (var testMessageBox = JhMessageBox.BeginTest())
            {
                // Emulate the action of the user selecting "Cancel".
                testMessageBox.TestFacility.SetButtonToSelect(JhDialogResult.Cancel);

                // Show the message-box.
                var options = new JhMessageBoxOptions(JhMessageBoxType.UserMistake);
                options.SummaryText = "Oh geez";
                options.DetailText = "detail text";
                options.ButtonFlags = JhMessageBoxButtons.Ok | JhMessageBoxButtons.Cancel;

                var r = testMessageBox.NotifyUser(options);

                // Check that it displayed okay..
                Assert.AreEqual(JhDialogResult.Cancel, r, "The JhMessageBoxWindow failed to return the correct result!");
                testMessageBox.TestFacility.AssertAMessageBoxHasBeenShown();
                testMessageBox.TestFacility.AssertWasWithinDetailText("detail");
                testMessageBox.TestFacility.AssertWasWithinSummaryText("geez");
            }
        }
 /// <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 as a non-modal dialog window, and return immediately.
 /// The message-type is assumed to be JhMessageBoxType.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 (optional)</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 = null, FrameworkElement parent = null)
 {
     var options = new JhMessageBoxOptions(this.DefaultOptions)
         .SetButtonFlags(JhMessageBoxButtons.Ok)
         .SetCaptionAfterPrefix(captionAfterPrefix)
         .SetDetailText(detailText)
         .SetSummaryText(summaryText)
         .SetIsAsynchronous(true)
         .SetMessageType(JhMessageBoxType.Information)
         .SetParent(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 (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>
 /// Display a message-box to the user. Wait for his response or else close itself after the timeout has expired.
 /// The message-type is assumed to be JhMessageBoxType.Information
 /// </summary>
 /// <param name="ofWhat">The text message to display to the user</param>
 /// <param name="parent">the visual-element to consider as the parent, or owner, of this message-box (optional)</param>
 /// <returns>A JhDialogResult that indicates the user's response</returns>
 public JhDialogResult NotifyUser(string ofWhat, 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 = ofWhat;
     options.DetailText = null;
     options.CaptionAfterPrefix = null;
     options.ButtonFlags = JhMessageBoxButtons.Ok;
     options.MessageType = JhMessageBoxType.Information;
     options.IsToBeTopmostWindow = false;
     #if !SILVERLIGHT
     options.ParentElement = parent;
     #endif
     options.TimeoutPeriodInSeconds = 0;  // Assume zero for the timeout value, which invokes the default value.
     return NotifyUser(options);
 }
        /// <summary>
        /// Display a message-box to the user, based upon the given options.
        /// This particular method is the one that all of the other Notify methods invoke to do the actual work.
        /// </summary>
        /// <param name="options">a JhMessageBoxOptions object that fully specifies everything about the message-box</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(JhMessageBoxOptions options)
        {
            var messageBoxWindow = new JhMessageBoxWindow(this, options);

            // If we are doing testing, and have specified that a specific button is to be emulated as having been selected by the user,
            // then verify that that button is indeed present..
            if (IsTesting)
            {
                if (TestFacility.ButtonResultToSelect.HasValue)
                {
                    string complaint;
                    if (!GetWhetherButtonIsIncluded(options.ButtonFlags, out complaint))
                    {
                        // Announce the error
                        throw new ArgumentOutOfRangeException(complaint);
                    }
                }
            }

            //TODO: The following should not be needed for Silverlight..
            // Try to give it a parent-window to position itself relative to.
            #if !SILVERLIGHT
            FrameworkElement parentElement = options.ParentElement;
            Window parentWindow = null;
            if (parentElement == null)
            {
                // When running unit-tests, Application.Current might be null.
                if (Application.Current != null)
                {
                    parentWindow = Application.Current.MainWindow;
                    messageBoxWindow.Owner = parentWindow;
                }
            }
            else if (parentElement.IsLoaded)
            {
                parentWindow = parentElement as Window;
                if (parentWindow != null)
                {
                    messageBoxWindow.Owner = parentWindow;
                }
            }
            #endif

            // Finally, show the message-box.
            //TODO: for Silverlight, need to prepare to receive the result asynchronously!!!
            #if SILVERLIGHT
            messageBox.Show();
            #else
            _messageBoxWindow = messageBoxWindow;
            if (options.IsAsynchronous)
            {
                messageBoxWindow.Show();
            }
            else
            {
                messageBoxWindow.ShowDialog();
            }
            #endif
            return messageBoxWindow.Result;
        }
 /// <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;
 }
        public void TC05_NotifyUser_CustomButton1_CorrectResults()
        {
            using (var testMessageBox = JhMessageBox.BeginTest())
            {
                var options = new JhMessageBoxOptions()
                    .SetButtonFlags(JhMessageBoxButtons.Yes | JhMessageBoxButtons.No | JhMessageBoxButtons.Cancel)
                    .SetButtonText(JhDialogResult.Yes, "Absolutely!")
                    .SetSummaryText("The Summary Text")
                    .SetIsAsynchronous(true);

                // We're going to test the event mechanism as well.
                options.Completed += new System.EventHandler<MessageBoxCompletedArgs>(OnCompleted);
                _isCompletedEventRaised = false;
                // Set this to any value other than what we are going to expect it to be.
                _theResult = JhDialogResult.Ignore;

                testMessageBox.TestFacility.SetToWaitForExplicitClose();

                // Show the message-box.
                testMessageBox.NotifyUser(options);

                testMessageBox.TestFacility.AssertAMessageBoxIsBeingShown();
                testMessageBox.TestFacility.AssertNoButtonIsPresent();
                testMessageBox.TestFacility.AssertCancelButtonIsPresent();

                testMessageBox.TestFacility.AssertButtonIsPresent("Absolutely!");

                testMessageBox.TestFacility.SimulateClosing(JhDialogResult.Ok);

                testMessageBox.TestFacility.AssertAMessageBoxHasBeenShown();

                Assert.IsTrue(_isCompletedEventRaised, "Why did the Completed event not get raised?");
                Assert.AreEqual(JhDialogResult.Ok, _theResult, "The result did not get set correctly!");
            }
        }
示例#10
0
        /// <summary>
        /// Create a new JhMessageBoxWindow, with the given options if non-null - otherwise use the DefaultOptions.
        /// </summary>
        /// <param name="options">The options to use for this particular message-box invocation. Leave this null to use the DefaultOptions.</param>
        public JhMessageBoxWindow(JhMessageBox mgr, JhMessageBoxOptions options = null)
        {
            //Console.WriteLine("JhMessageBoxWindow ctor, with options.BackgroundTexture = " + options.BackgroundTexture.ToString());
            _manager = mgr;
            // _options has to be set before InitializeComponent, since that causes properties to be bound, and hence the DataContext creates it's view-model.
            if (options == null)
            {
                _options = mgr.DefaultOptions;
            }
            else
            {
                _options = options;
            }
            _viewModel = JhMessageBoxViewModel.GetInstance(mgr, _options);

            InitializeComponent();

            // Ensure the timeout value isn't ridiculously high (as when the caller mistakenly thinks it's in milliseconds).
            // Use the constant upper-limit value to test it against.
            if (_options.TimeoutPeriodInSeconds > JhMessageBoxOptions.MaximumTimeoutPeriodInSeconds)
            {
                _options.TimeoutPeriodInSeconds = JhMessageBoxOptions.GetDefaultTimeoutValueFor(_options.MessageType);
            }

            if (_options.IsToCenterOverParent)
            {
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            }

            // If the option to use custom styles for the buttons is turned off, then set these button styles to null
            // so that they do not inherit the styles of the parent application.
            if (!_options.IsCustomButtonStyles)
            {
                btnCancel.Style = btnClose.Style = btnNo.Style = btnOk.Style = btnRetry.Style = btnYes.Style = btnIgnore.Style = null;
            }

#if SILVERLIGHT
            _viewModel.CopyCommand = new RelayCommand(
                () => OnCopyCommandExecuted()
                );
            _viewModel.StayCommand = new RelayCommand(
                () => OnStayCommandExecuted(),
                () => StayCommand_CanExecute()
                );
#else
            _viewModel.CopyCommand = new RelayCommand(
                (x) => OnCopyCommandExecuted()
                );
            _viewModel.StayCommand = new RelayCommand(
                (x) => OnStayCommandExecuted(),
                (x) => StayCommand_CanExecute()
                );
#endif

            Loaded += OnLoaded;
#if SILVERLIGHT
            Closing += new EventHandler <System.ComponentModel.CancelEventArgs>(OnClosing);
#else
            ContentRendered += OnContentRendered;
            Closing         += new System.ComponentModel.CancelEventHandler(OnClosing);
#endif
        }
 public static JhMessageBoxViewModel GetInstance(JhMessageBox manager, JhMessageBoxOptions options)
 {
     _theInstance = new JhMessageBoxViewModel(manager, options);
     return _theInstance;
 }
 public JhMessageBoxViewModel(JhMessageBox manager, JhMessageBoxOptions options)
 {
     _options = options;
     DetailText = options.DetailText;
     SummaryText = options.SummaryText;
     // If there is no caption, then just put the caption-prefix without the spacer.
     if (String.IsNullOrWhiteSpace(options.CaptionAfterPrefix))
     {
         if (String.IsNullOrWhiteSpace(options.CaptionPrefix))
         {
             Title = manager.CaptionPrefix;
         }
         else
         {
             Title = options.CaptionPrefix;
         }
     }
     else
     {
         if (String.IsNullOrWhiteSpace(options.CaptionPrefix))
         {
             Title = manager.CaptionPrefix + ": " + options.CaptionAfterPrefix;
         }
         else
         {
             Title = options.CaptionPrefix + ": " + options.CaptionAfterPrefix;
         }
     }
 }
 public JhMessageBoxViewModel()
 {
     if (this.IsInDesignMode)
     {
         _options = new JhMessageBoxOptions(JhMessageBoxType.Error);
         Options.ButtonFlags = JhMessageBoxButtons.Yes | JhMessageBoxButtons.No | JhMessageBoxButtons.Ok | JhMessageBoxButtons.Cancel
             | JhMessageBoxButtons.Close | JhMessageBoxButtons.Ignore | JhMessageBoxButtons.Retry;
         Title = "Vendor Product: Caption";
         string summaryTextPattern = "The Summary Text";
         SummaryText = summaryTextPattern.ExpandTo(20);
         string detailTextPattern = "The Details Texts. X";
         DetailText = detailTextPattern.ExpandTo(63);
         //DetailText = "The Details Texts. XThe Details Texts. XThe Details Texts._XThe Details Texts._XThe Details Texts._XThe";
         //DetailText = "The Details Text";
         Options.BackgroundTexture = JhMessageBoxBackgroundTexture.None;
         Options.IsUsingNewerIcons = false;
     }
 }
        /// <summary>
        /// Create a new JhMessageBoxWindow, with the given options if non-null - otherwise use the DefaultOptions.
        /// </summary>
        /// <param name="options">The options to use for this particular message-box invocation. Leave this null to use the DefaultOptions.</param>
        public JhMessageBoxWindow(JhMessageBox mgr, JhMessageBoxOptions options = null)
        {
            //Console.WriteLine("JhMessageBoxWindow ctor, with options.BackgroundTexture = " + options.BackgroundTexture.ToString());
            _manager = mgr;
            // _options has to be set before InitializeComponent, since that causes properties to be bound, and hence the DataContext creates it's view-model.
            if (options == null)
            {
                _options = mgr.DefaultOptions;
            }
            else
            {
                _options = options;
            }
            _viewModel = JhMessageBoxViewModel.GetInstance(mgr, _options);

            InitializeComponent();

            // Ensure the timeout value isn't ridiculously high (as when the caller mistakenly thinks it's in milliseconds).
            // Use the constant upper-limit value to test it against.
            if (_options.TimeoutPeriodInSeconds > JhMessageBoxOptions.MaximumTimeoutPeriodInSeconds)
            {
                _options.TimeoutPeriodInSeconds = JhMessageBoxOptions.GetDefaultTimeoutValueFor(_options.MessageType);
            }

            if (_options.IsToCenterOverParent)
            {
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            }

            // If the option to use custom styles for the buttons is turned off, then set these button styles to null
            // so that they do not inherit the styles of the parent application.
            if (!_options.IsCustomButtonStyles)
            {
                btnCancel.Style = btnClose.Style = btnNo.Style = btnOk.Style = btnRetry.Style = btnYes.Style = btnIgnore.Style = null;
            }

            #if SILVERLIGHT
            _viewModel.CopyCommand = new RelayCommand(
                () => OnCopyCommandExecuted()
            );
            _viewModel.StayCommand = new RelayCommand(
                () => OnStayCommandExecuted(),
                () => StayCommand_CanExecute()
            );
            #else
            _viewModel.CopyCommand = new RelayCommand(
                (x) => OnCopyCommandExecuted()
            );
            _viewModel.StayCommand = new RelayCommand(
                (x) => OnStayCommandExecuted(),
                (x) => StayCommand_CanExecute()
            );
            #endif

            Loaded += OnLoaded;
            #if SILVERLIGHT
            Closing += new EventHandler<System.ComponentModel.CancelEventArgs>(OnClosing);
            #else
            ContentRendered += OnContentRendered;
            Closing += new System.ComponentModel.CancelEventHandler(OnClosing);
            #endif
        }
 /// <summary>
 /// Show a message-box to notify the user of a mistake that he has made in his operation of this program.
 /// </summary>
 /// <param name="summaryText">the text that goes in the upper, basic-message area</param>
 /// <param name="detailText">the more detailed text that goes in the lower area</param>
 /// <param name="captionAfterPrefix">what to put in the title-bar of the message-box - after the prefix that would contain the vendor and program-name</param>
 /// <param name="parent">the user-interface element to serve as the parent of the message-box, so that it can center itself over that</param>
 /// <returns>a JhDialogResult indicating what the user clicked on to close the message-box</returns>
 public JhDialogResult NotifyUserOfMistake(string summaryText, string detailText = null, string captionAfterPrefix = null, FrameworkElement parent = null)
 {
     //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 JhMessageBoxOptions(DefaultOptions);
     // Derive a timeout value..
     int timeout = 0;
     if (_defaultOptions != null)
     {
         timeout = DefaultOptions.TimeoutPeriodForUserMistakes;
     }
     if (timeout == 0)
     {
         timeout = JhMessageBoxOptions.GetDefaultTimeoutValueFor(JhMessageBoxType.UserMistake);
     }
     // Derive a suitable text to use for the message-box caption if none was specified..
     string whatToUseForCaptionAfterPrefix = captionAfterPrefix;
     if (String.IsNullOrWhiteSpace(whatToUseForCaptionAfterPrefix))
     {
         if (DefaultOptions.CaptionForUserMistakes != null)
         {
             whatToUseForCaptionAfterPrefix = DefaultOptions.CaptionForUserMistakes;
         }
         else
         {
             //TODO: May want to be a little more creative here.
             whatToUseForCaptionAfterPrefix = "Oops!";
         }
     }
     #if SILVERLIGHT
     return NotifyUser(summaryText, detailText, whatToUseForCaptionAfterPrefix, JhMessageBoxButtons.Ok, JhMessageBoxType.UserMistake, timeout);
     #else
     options.SummaryText = summaryText;
     options.DetailText = detailText;
     options.CaptionAfterPrefix = whatToUseForCaptionAfterPrefix;
     options.ButtonFlags = JhMessageBoxButtons.Ok;
     options.MessageType = JhMessageBoxType.UserMistake;
     options.ParentElement = parent;
     options.TimeoutPeriodInSeconds = timeout;
     return NotifyUser(options);
     #endif
 }
示例#16
0
        /// <summary>
        /// Handle the ContentRendered event, which occurrs after the UI elements have been rendered on-screen.
        /// </summary>
        void OnContentRendered(object sender, EventArgs e)
        {
            #region Make me the top-most window.

            if (!this.IsTesting)
            {
                if (_options.IsToBeTopmostWindow)
                {
#if !SILVERLIGHT
                    this.Topmost = true;
                    this.Focus();
#endif
                }
            }
            #endregion

            #region Audial effects

            if (!this.IsTesting && _options.IsSoundEnabled)
            {
                if (!_options.IsUsingNewerSoundScheme)
                {
                    JhMessageBoxWindow.MessageBeep(_options.MessageType);
                }
                else
                {
                    //TODO: How to implement this in SL?
#if !SILVERLIGHT
                    switch (_options.MessageType)
                    {
                    case JhMessageBoxType.Information:
                        AudioLib.PlaySoundResourceEvenIfNotPCM(_informationSoundResource);
                        break;

                    case JhMessageBoxType.Question:
                        AudioLib.PlaySoundResourceEvenIfNotPCM(_questionSoundResource);
                        break;

                    case JhMessageBoxType.UserMistake:
                        AudioLib.PlaySoundResource(_userMistakeSoundResource);
                        break;

                    case JhMessageBoxType.Warning:
                        AudioLib.PlaySoundResource(_warningSoundResource);
                        break;

                    case JhMessageBoxType.Error:
                        AudioLib.PlaySoundResource(_errorSoundResource);
                        break;

                    case JhMessageBoxType.SecurityIssue:
                        AudioLib.PlaySoundResource(_securityIssueSoundResource);
                        break;

                    case JhMessageBoxType.Stop:
                        AudioLib.PlaySoundResource(_stopSoundResource);
                        break;
                    }
#endif
                }
            }
            #endregion Audial effects

            #region Timeout

            if (!IsTesting || (IsTesting && !TestFacility.IsToWaitForExplicitClose))
            {
                // Set the timer that will close this message-box.
                int timeoutPeriodToSet = _options.TimeoutPeriodInSeconds;
                if (timeoutPeriodToSet == 0)
                {
                    // If the default value of zero was indicated, that means to use the default value.
                    timeoutPeriodToSet = JhMessageBoxOptions.GetDefaultTimeoutValueFor(_options.MessageType);
                    _options.TimeoutPeriodInSeconds = timeoutPeriodToSet;
                }
                // If we are running tests and this option is set -- limit the timeout to our special, brief time-period.
                if (_manager._testFacility != null && TestFacility.IsTimeoutsFast)
                {
                    if (timeoutPeriodToSet > 1)
                    {
                        timeoutPeriodToSet = 1;
                    }
                }
                StartTimer(timeoutPeriodToSet);
            }

            #endregion Timeout
        }
 /// <summary>
 /// Set the options to use by default for subsequent invocations of a message-box.
 /// </summary>
 /// <param name="options">The options to set (the MessageType property is ignored)</param>
 public void SetDefaultOptions(JhMessageBoxOptions options)
 {
     DefaultOptions = options;
 }
        private void btnJhMessageBox_Click(object sender, RoutedEventArgs e)
        {
            _viewModel.MessageBoxType = this.JhMessageBoxTypeToUse;
            JhMessageBoxOptions options = new JhMessageBoxOptions(_viewModel.MessageBoxType);

            if (_viewModel.IsUsingDefaultTimeoutValue)
            {
                options.TimeoutPeriodInSeconds = 0;
            }
            else
            {
                options.TimeoutPeriodInSeconds = this.TimeToDisplayIt;
                _viewModel.TimeoutValue = options.TimeoutPeriodInSeconds;
            }
            string timeoutValueText = txtTime.Text;
            //var result = ParseLib.ParseForTimeInterval(timeoutValueText);
            //if (result.IsOk)
            //{
            //    _viewModel.TimeoutValue = (int)result.ValueInSeconds.Value;
            //}
            //else
            //{
            //    Console.WriteLine("What you put for TimeoutValue doesn't look valid to me. What-up-widat?");
            //    return;
            //}
            //options.TimeoutPeriodInSeconds = _viewModel.TimeoutValue;

            if (_viewModel.IsIncludingParentWindow)
            {
                options.ParentElement = this;
            }

            options.BackgroundTexture = _viewModel.BackgroundTexture;
            options.ButtonFlags = GetButtonsToShow();
            options.CaptionAfterPrefix = _viewModel.CaptionAfterPrefix;
            if (!String.IsNullOrWhiteSpace(_viewModel.CompanyName) || !String.IsNullOrWhiteSpace(_viewModel.ApplicationName))
            {
                options.CaptionPrefix = _viewModel.CompanyName + " " + _viewModel.ApplicationName;
            }
            options.DetailText = _viewModel.DetailText;
            options.SummaryText = _viewModel.SummaryText;
            options.IsCustomButtonStyles = _viewModel.IsCustomButtonStyles;
            options.IsSoundEnabled = _viewModel.IsSoundEnabled;
            options.IsToCenterOverParent = _viewModel.IsToCenterOverParent;
            options.IsToBeTopmostWindow = _viewModel.IsTopmostWindow;
            options.IsUsingAeroGlassEffect = _viewModel.IsUsingAeroGlassEffect;
            options.IsUsingNewerSoundScheme = _viewModel.IsUsingNewerSoundScheme;
            options.IsUsingNewerIcons = _viewModel.IsUsingNewerIcons;

            JhDialogResult r = _messageBoxManager.NotifyUser(options);

            txtResult.Text = "JhDialogResult." + r.ToString();
            borderResult.Visibility = System.Windows.Visibility.Visible;
            lblResult.Visibility = System.Windows.Visibility.Visible;
        }