/// <summary>
        /// Plays system sound on displaying messagebox.
        /// </summary>
        /// <param name="type">The type of messagebox being displayed.</param>
        public void PlaySound(KryptonMessageBoxIcon type, string customSoundLocation = null)
        {
            switch (type)
            {
            case KryptonMessageBoxIcon.HAND:
                SystemSounds.Hand.Play();
                break;

            case KryptonMessageBoxIcon.QUESTION:
                SystemSounds.Question.Play();
                break;

            case KryptonMessageBoxIcon.EXCLAMATION:
                SystemSounds.Exclamation.Play();
                break;

            case KryptonMessageBoxIcon.ASTERISK:
                SystemSounds.Asterisk.Play();
                break;

            case KryptonMessageBoxIcon.STOP:
                SystemSounds.Asterisk.Play();
                break;

            case KryptonMessageBoxIcon.ERROR:
                SystemSounds.Asterisk.Play();
                break;

            case KryptonMessageBoxIcon.INFORMATION:

                break;

            case KryptonMessageBoxIcon.CUSTOM:
                try
                {
                    SoundPlayer sound = new SoundPlayer();

                    sound.SoundLocation = customSoundLocation;

                    sound.Play();
                }
                catch (Exception e)
                {
                    exceptionHandler.ShowException(e.Message, true);
                }
                break;

            case KryptonMessageBoxIcon.CRITICAL:
                SystemSounds.Asterisk.Play();
                break;

            case KryptonMessageBoxIcon.NONE:
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Displays a message box in front+center of the application and with the specified text, caption, buttons, icon, default button, and options.
 /// </summary>
 /// <param name="text">The text to display in the message box.</param>
 /// <param name="caption" default="string.Empty">The text to display in the title bar of the message box. default="string.Empty"</param>
 /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
 /// <param name="icon" >One of the KryptonMessageBoxIcon values that specifies which icon to display in the message box.</param>
 /// <param name="defaultButton" default="MessageBoxDefaultButton.Button1">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
 /// <param name="options" default="0">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
 /// <param name="displayHelpButton" default="false">Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button.</param>
 /// <param name="showCtrlCopy">Show extraText in title. If null(default) then only when Warning or Error icon is used.</param>
 /// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
 public static DialogResult Show(string text,
                                 string caption,
                                 MessageBoxButtons buttons,
                                 KryptonMessageBoxIcon icon,
                                 MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1,
                                 MessageBoxOptions options             = 0,
                                 bool displayHelpButton = false,
                                 bool?showCtrlCopy      = null)
 =>
 InternalShow(null, text, caption, buttons, icon, defaultButton, options, displayHelpButton ? new HelpInfo() : null, showCtrlCopy);
Ejemplo n.º 3
0
        /// <summary>
        /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file, HelpNavigator, and Help topic.
        /// </summary>
        /// <param name="owner">Owner of the modal dialog box.</param>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The text to display in the title bar of the message box.</param>
        /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
        /// <param name="icon">One of the KryptonMessageBoxIcon values that specifies which icon to display in the message box.</param>
        /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
        /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
        /// <param name="helpInfo">Contains the help data of the <see cref="KryptonMessageBox"/>.</param>
        /// <param name="showCtrlCopy">Show extraText in title. If null(default) then only when Warning or Error icon is used.</param>
        /// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
        private static DialogResult InternalShow(IWin32Window owner,
                                                 string text, string caption,
                                                 MessageBoxButtons buttons,
                                                 KryptonMessageBoxIcon icon,
                                                 MessageBoxDefaultButton defaultButton,
                                                 MessageBoxOptions options,
                                                 HelpInfo helpInfo, bool?showCtrlCopy)
        {
            caption = string.IsNullOrEmpty(caption) ? @" " : caption;

            IWin32Window showOwner = ValidateOptions(owner, options, helpInfo);

            // Show message box window as a modal dialog and then dispose of it afterwards
            using KryptonMessageBoxForm kmb = new(showOwner, text, caption, buttons, icon, defaultButton, options, helpInfo, showCtrlCopy);
            kmb.StartPosition = showOwner == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent;

            return(kmb.ShowDialog(showOwner));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file, HelpNavigator, and Help topic.
 /// </summary>
 /// <param name="owner">Owner of the modal dialog box.</param>
 /// <param name="text">The text to display in the message box.</param>
 /// <param name="caption">The text to display in the title bar of the message box.</param>
 /// <param name="buttons">One of the System.Windows.Forms.MessageBoxButtons values that specifies which buttons to display in the message box.</param>
 /// <param name="icon">One of the KryptonMessageBoxIcon values that specifies which icon to display in the message box.</param>
 /// <param name="defaultButton">One of the System.Windows.Forms.MessageBoxDefaultButton values that specifies the default button for the message box.</param>
 /// <param name="options">One of the System.Windows.Forms.MessageBoxOptions values that specifies which display and association options will be used for the message box. You may pass in 0 if you wish to use the defaults.</param>
 /// <param name="helpFilePath">The path and name of the Help file to display when the user clicks the Help button.</param>
 /// <param name="navigator">One of the System.Windows.Forms.HelpNavigator values.</param>
 /// <param name="param">The numeric ID of the Help topic to display when the user clicks the Help button.</param>
 /// <param name="showCtrlCopy">Show extraText in title. If null(default) then only when Warning or Error icon is used.</param>
 /// <returns>One of the System.Windows.Forms.DialogResult values.</returns>
 public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, KryptonMessageBoxIcon icon, MessageBoxDefaultButton defaultButton,
                                 MessageBoxOptions options, string helpFilePath, HelpNavigator navigator, object param, bool?showCtrlCopy = null)
 => InternalShow(owner, text, caption, buttons, icon, defaultButton, options, new HelpInfo(helpFilePath, navigator, param), showCtrlCopy);
 /// <summary>Captures the exception.</summary>
 /// <param name="exception">The exception.</param>
 /// <param name="title">The title.</param>
 /// <param name="buttons">The buttons.</param>
 /// <param name="icon">The icon.</param>
 /// <param name="className">Name of the class.</param>
 /// <param name="methodSignature">The method signature.</param>
 public static void CaptureException(Exception exception, string title = @"Exception Caught", MessageBoxButtons buttons = MessageBoxButtons.OK, KryptonMessageBoxIcon icon = KryptonMessageBoxIcon.ERROR, string className = "", string methodSignature = "")
 {
     if (className != "")
     {
         KryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in class: '{ className }.cs'.", title, buttons, icon);
     }
     else if (methodSignature != "")
     {
         KryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in method: '{ methodSignature }'.", title, buttons, icon);
     }
     else if (className != "" && methodSignature != "")
     {
         KryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.\n\nError in class: '{ className }.cs'.\n\nError in method: '{ methodSignature }'.", title, buttons, icon);
     }
     else
     {
         KryptonMessageBox.Show($"An unexpected error has occurred: { exception.Message }.", title, buttons, icon);
     }
 }