Пример #1
0
        /// <summary>
        /// Sets the default button.
        /// </summary>
        /// <param name="defaultButton">The default button.</param>
        private void SetDefaultButton(KryptonMessageBoxExtendedDefaultButton defaultButton)
        {
            switch (defaultButton)
            {
            case KryptonMessageBoxExtendedDefaultButton.BUTTON1:
                AcceptButton = kbtnButton1;
                break;

            case KryptonMessageBoxExtendedDefaultButton.BUTTON2:
                AcceptButton = kbtnButton2;
                break;

            case KryptonMessageBoxExtendedDefaultButton.BUTTON3:
                AcceptButton = kbtnButton3;
                break;

            default:
                break;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="showOwner"></param>
        /// <param name="messageContent"></param>
        /// <param name="caption"></param>
        /// <param name="iconVisibility"></param>
        /// <param name="borderType"></param>
        /// <param name="buttonCount"></param>
        /// <param name="buttons"></param>
        /// <param name="options"></param>
        /// <param name="helpInfo"></param>
        /// <param name="defaultButton"></param>
        /// <param name="icon"></param>
        /// <param name="buttonTextCollection"></param>
        /// <param name="checkBoxText"></param>
        /// <param name="customIcon"></param>
        private ExtendedKryptonMessageboxOld(IWin32Window showOwner, string messageContent, string caption, KryptonMessageBoxExtendedApplicationIconVisibility iconVisibility, KryptonMessageBoxExtendedBorderType borderType, KryptonMessageBoxExtendedBoxButtonCount buttonCount, KryptonMessageBoxExtendedButtons buttons, KryptonMessageBoxExtendedBoxOptions options, HelpInformation helpInfo, KryptonMessageBoxExtendedDefaultButton defaultButton, KryptonMessageBoxExtendedIcon icon, string[] buttonTextCollection, string checkBoxText, Image customIcon)
        {
            this.showOwner            = showOwner;
            this.messageContent       = messageContent;
            this.caption              = caption;
            this.iconVisibility       = iconVisibility;
            this.borderType           = borderType;
            this.buttonCount          = buttonCount;
            this.buttons              = buttons;
            this.options              = options;
            this.helpInfo             = helpInfo;
            this.defaultButton        = defaultButton;
            this.icon                 = icon;
            this.buttonTextCollection = buttonTextCollection;
            this.checkBoxText         = checkBoxText;
            this.customIcon           = customIcon;

            InitializeComponent();

            UpdateText();

            UpdateCheckBox();

            UpdateBorderStyle();

            UpdateIconVisibility();

            UpdateIconType();

            UpdateButtonCount();

            UpdateButtons();

            UpdateMessageboxDefaultButton();

            UpdateHelp();

            UpdateTextExtra();

            UpdateSizing(showOwner);
        }
        /// <summary>
        /// Internals the show.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="messageContent">Content of the message.</param>
        /// <param name="caption">The caption.</param>
        /// <param name="iconVisibility">The icon visibility.</param>
        /// <param name="borderType">Type of the border.</param>
        /// <param name="buttonCount">The button count.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="options">The options.</param>
        /// <param name="helpInfo">The help information.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="result">The result.</param>
        /// <param name="buttonTextCollection">The button text collection.</param>
        /// <param name="customIcon">The custom icon.</param>
        /// <returns></returns>
        /// <exception cref="InvalidOperationException">Cannot show modal dialog when non-interactive</exception>
        /// <exception cref="ArgumentException">
        /// Cannot show message box from a service with an owner specified - options
        /// or
        /// Cannot show message box from a service with help specified - options
        /// </exception>
        private static KryptonMessageBoxExtendedResult InternalShow(IWin32Window owner, string messageContent, string caption, KryptonMessageBoxExtendedApplicationIconVisibility iconVisibility, KryptonMessageBoxExtendedBorderType borderType, KryptonMessageBoxExtendedBoxButtonCount buttonCount, KryptonMessageBoxExtendedButtons buttons, KryptonMessageBoxExtendedBoxOptions options, HelpInformation helpInfo = null, KryptonMessageBoxExtendedDefaultButton defaultButton = KryptonMessageBoxExtendedDefaultButton.BUTTON1, KryptonMessageBoxExtendedIcon icon = KryptonMessageBoxExtendedIcon.NONE, string[] buttonTextCollection = null, string checkBoxText = null, Image customIcon = null) // KryptonMessageBoxExtendedResult result = KryptonMessageBoxExtendedResult.OK,
        {
            // Check if trying to show a message box from a non-interactive process, this is not possible
            if (!SystemInformation.UserInteractive && ((options & (KryptonMessageBoxExtendedBoxOptions.SERVICENOTIFICATION | KryptonMessageBoxExtendedBoxOptions.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 & (KryptonMessageBoxExtendedBoxOptions.SERVICENOTIFICATION | KryptonMessageBoxExtendedBoxOptions.DEFAULTDESKTOPONLY)) != 0))
            {
                throw new ArgumentException(@"Cannot show message box from a service with an owner specified", nameof(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 & (KryptonMessageBoxExtendedBoxOptions.SERVICENOTIFICATION | KryptonMessageBoxExtendedBoxOptions.DEFAULTDESKTOPONLY)) != 0))
            {
                throw new ArgumentException(@"Cannot show message box from a service with help specified", nameof(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 & (KryptonMessageBoxExtendedBoxOptions.SERVICENOTIFICATION | KryptonMessageBoxExtendedBoxOptions.DEFAULTDESKTOPONLY)) == 0))
            {
                // If do not have an owner passed in then get the active window and use that instead
                showOwner = owner ?? FromHandle(PI.GetActiveWindow());
            }

            using (ExtendedKryptonMessageboxOld ekmb = new ExtendedKryptonMessageboxOld(showOwner, messageContent, caption, iconVisibility, borderType, buttonCount, buttons, options, helpInfo, defaultButton, icon, buttonTextCollection, checkBoxText, customIcon))
            {
                ekmb.StartPosition = showOwner == null ? FormStartPosition.CenterScreen : FormStartPosition.CenterParent;

                return(ekmb.ShowDialogExtended(showOwner));
            }
        }
 public static KryptonMessageBoxExtendedResult Show(IWin32Window owner, string messageContent, string caption, KryptonMessageBoxExtendedApplicationIconVisibility iconVisibility, KryptonMessageBoxExtendedBorderType borderType, KryptonMessageBoxExtendedBoxButtonCount buttonCount, KryptonMessageBoxExtendedButtons buttons, KryptonMessageBoxExtendedBoxOptions options, string helpInfoPath = null, KryptonMessageBoxExtendedDefaultButton defaultButton = KryptonMessageBoxExtendedDefaultButton.BUTTON1, KryptonMessageBoxExtendedIcon icon = KryptonMessageBoxExtendedIcon.NONE, string[] buttonTextCollection = null, string checkBoxText = null, Image customIcon = null)
 {
     return(InternalShow(owner, messageContent, caption, iconVisibility, borderType, buttonCount, buttons, options, new HelpInformation(helpInfoPath), defaultButton, icon, buttonTextCollection, checkBoxText, customIcon));
 }
 public ExtendedKryptonMessageboxOld(IWin32Window showOwner, string messageContent, string caption, KryptonMessageBoxExtendedApplicationIconVisibility iconVisibility, KryptonMessageBoxExtendedBorderType borderType, KryptonMessageBoxExtendedBoxButtonCount buttonCount, KryptonMessageBoxExtendedButtons buttons, KryptonMessageBoxExtendedBoxOptions options, KryptonMessageBoxExtendedDefaultButton defaultButton, KryptonMessageBoxExtendedIcon icon, string[] buttonTextCollection, string checkBoxText, Image customIcon)
 {
 }
Пример #6
0
        /// <summary>
        /// Shows the specified messagebox title.
        /// </summary>
        /// <param name="messageboxTitle">The messagebox title.</param>
        /// <param name="messageBoxText">The message box text.</param>
        /// <param name="buttons">The buttons.</param>
        /// <param name="icon">The icon.</param>
        /// <param name="defaultButton">The default button.</param>
        /// <param name="kryptonButtonText1">The krypton button text1.</param>
        /// <param name="kryptonButtonText2">The krypton button text2.</param>
        /// <param name="kryptonButtonText3">The krypton button text3.</param>
        public void Show(string messageboxTitle, string messageBoxText, KryptonMessageBoxExtendedButtons buttons, KryptonMessageBoxExtendedIcon icon, KryptonMessageBoxExtendedDefaultButton defaultButton = KryptonMessageBoxExtendedDefaultButton.BUTTON1, string kryptonButtonText1 = null, string kryptonButtonText2 = null, string kryptonButtonText3 = null, string iconCustomFileName = null, KryptonMessageBoxExtendedBoxButtonCount buttonCount = KryptonMessageBoxExtendedBoxButtonCount.ONE)
        {
            Text = messageboxTitle;

            klblMessage.Text = messageBoxText;

            SetButtonText(buttons, kryptonButtonText1, kryptonButtonText2, kryptonButtonText3, buttonCount);

            #region Messagebox Icons
            switch (icon)
            {
            case KryptonMessageBoxExtendedIcon.HAND:
                pbxIcon.Image = new Bitmap(Resources.if_Symbol_Stop_49267);
                break;

            case KryptonMessageBoxExtendedIcon.QUESTION:
                pbxIcon.Image = new Bitmap(Resources.if_Symbol_Help_49263);
                break;

            case KryptonMessageBoxExtendedIcon.EXCLAMATION:
                pbxIcon.Image = new Bitmap(Resources.if_Symbol_Exclamation_49262);
                break;

            case KryptonMessageBoxExtendedIcon.ASTERISK:
                pbxIcon.Image = new Bitmap(Resources.if_Symbol_Restricted_49266);
                break;

            case KryptonMessageBoxExtendedIcon.STOP:
                pbxIcon.Image = new Bitmap(Resources.if_Symbol_Stop_49267);
                break;

            case KryptonMessageBoxExtendedIcon.ERROR:
                pbxIcon.Image = new Bitmap(Resources.if_Symbol_Error_49261);
                break;

            case KryptonMessageBoxExtendedIcon.INFORMATION:
                pbxIcon.Image = new Bitmap(Resources.if_Symbol_Information_49264);
                break;

            case KryptonMessageBoxExtendedIcon.CUSTOM:
                if (iconCustomFileName != null)
                {
                    pbxIcon.Image = new Bitmap(iconCustomFileName);
                }
                else
                {
                    pbxIcon.Visible = false;

                    klblMessage.Location = new Point(12, 12);
                }
                break;

            case KryptonMessageBoxExtendedIcon.CRITICAL:
                pbxIcon.Image = new Bitmap(Resources.if_Symbol_Error_49261);
                break;

            case KryptonMessageBoxExtendedIcon.OK:
                pbxIcon.Image = new Bitmap(Resources.Check);
                break;

            case KryptonMessageBoxExtendedIcon.NONE:
                pbxIcon.Visible = false;

                klblMessage.Location = new Point(12, 12);
                break;
            }
            #endregion

            SetDefaultButton(defaultButton);
        }