/// <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); }
/// <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 }