ComponentFactory.Krypton.Toolkit.KryptonMessageBox.InternalShow C# (CSharp) Method

InternalShow() private static method

private static InternalShow ( IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, System.Windows.Forms.HelpInfo helpInfo ) : DialogResult
owner IWin32Window
text string
caption string
buttons MessageBoxButtons
icon MessageBoxIcon
defaultButton MessageBoxDefaultButton
options MessageBoxOptions
helpInfo System.Windows.Forms.HelpInfo
return DialogResult
        private static DialogResult InternalShow(IWin32Window owner,
                                                 string text, string caption,
                                                 MessageBoxButtons buttons, 
                                                 MessageBoxIcon icon,
                                                 MessageBoxDefaultButton defaultButton, 
                                                 MessageBoxOptions options,
                                                 HelpInfo helpInfo)
        {
            // Check if trying to show a message box from a non-interactive process, this is not possible
            if (!SystemInformation.UserInteractive && ((options & (MessageBoxOptions.ServiceNotification | MessageBoxOptions.DefaultDesktopOnly)) == 0))
                throw new InvalidOperationException("Cannot show modal dialog when non-interactive");

            // Check if trying to show a message box from a service and the owner has been specified, this is not possible
            if ((owner != null) && ((options & (MessageBoxOptions.ServiceNotification | MessageBoxOptions.DefaultDesktopOnly)) != 0))
                throw new ArgumentException("Cannot show message box from a service with an owner specified", "options");

            // Check if trying to show a message box from a service and help information is specified, this is not possible
            if ((helpInfo != null) && ((options & (MessageBoxOptions.ServiceNotification | MessageBoxOptions.DefaultDesktopOnly)) != 0))
                throw new ArgumentException("Cannot show message box from a service with help specified", "options");

            // If help information provided or we are not a service/default desktop application then grab an owner for showing the message box
            IWin32Window showOwner = null;
            if ((helpInfo != null) || ((options & (MessageBoxOptions.ServiceNotification | MessageBoxOptions.DefaultDesktopOnly)) == 0))
            {
                // If do not have an owner passed in then get the active window and use that instead
                if (owner == null)
                    showOwner = Control.FromHandle(PI.GetActiveWindow());
                else
                    showOwner = owner;
            }

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

                return kmb.ShowDialog(showOwner);
            }
        }