private void UpdateButtonCount(KryptonMessageBoxExtendedBoxButtonCount buttonCount) { switch (buttonCount) { case KryptonMessageBoxExtendedBoxButtonCount.ONE: kbtnButton1.Visible = false; kbtnButton2.Visible = false; kbtnButton3.Visible = true; break; case KryptonMessageBoxExtendedBoxButtonCount.TWO: kbtnButton1.Visible = false; kbtnButton2.Visible = true; kbtnButton3.Visible = true; break; case KryptonMessageBoxExtendedBoxButtonCount.THREE: kbtnButton1.Visible = true; kbtnButton2.Visible = true; kbtnButton3.Visible = true; break; default: break; } }
/// <summary> /// Shows the specified messagebox title. /// </summary> /// <param name="messageboxTitle">The messagebox title.</param> /// <param name="messageboxText">The messagebox text.</param> /// <param name="buttonCount">The button count.</param> /// <param name="buttons">The buttons.</param> /// <param name="result">The result.</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, KryptonMessageBoxExtendedBoxButtonCount buttonCount = KryptonMessageBoxExtendedBoxButtonCount.ONE, KryptonMessageBoxExtendedButtons buttons = KryptonMessageBoxExtendedButtons.OK, KryptonMessageBoxExtendedResult result = KryptonMessageBoxExtendedResult.OK, string kryptonButtonText1 = null, string kryptonButtonText2 = null, string kryptonButtonText3 = null) { Text = messageboxTitle; pbxIcon.Visible = false; klblMessage.Location = new Point(12, 12); klblMessage.Text = messageboxText; AssignButtonDialogResults(result); SetButtonText(buttons, kryptonButtonText1, kryptonButtonText2, kryptonButtonText3, buttonCount); }
/// <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) { }
/// <summary> /// Sets the button text. /// </summary> /// <param name="buttons">The buttons.</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> /// <param name="buttonCount">The button count.</param> public void SetButtonText(KryptonMessageBoxExtendedButtons buttons, string kryptonButtonText1 = null, string kryptonButtonText2 = null, string kryptonButtonText3 = null, KryptonMessageBoxExtendedBoxButtonCount buttonCount = KryptonMessageBoxExtendedBoxButtonCount.THREE) { switch (buttons) { case KryptonMessageBoxExtendedButtons.OK: kbtnButton1.Visible = false; kbtnButton2.Visible = false; kbtnButton3.Text = "&Ok"; break; case KryptonMessageBoxExtendedButtons.OKCANCEL: kbtnButton1.Visible = false; kbtnButton2.Text = "&Ok"; kbtnButton3.Text = "C&ancel"; break; case KryptonMessageBoxExtendedButtons.YESNO: kbtnButton1.Visible = false; kbtnButton2.Text = "Y&es"; kbtnButton3.Text = "&No"; break; case KryptonMessageBoxExtendedButtons.YESNOCANCEL: kbtnButton1.Text = "&Yes"; kbtnButton2.Text = "N&o"; kbtnButton3.Text = "C&ancel"; break; case KryptonMessageBoxExtendedButtons.RETRY: kbtnButton1.Visible = false; kbtnButton2.Visible = false; kbtnButton3.Text = "&Retry"; break; case KryptonMessageBoxExtendedButtons.ABORT: kbtnButton1.Visible = false; kbtnButton2.Visible = false; kbtnButton3.Text = "A&bort"; break; case KryptonMessageBoxExtendedButtons.RETRYABORT: kbtnButton1.Visible = false; kbtnButton2.Text = "&Retry"; kbtnButton3.Text = "A&bort"; break; case KryptonMessageBoxExtendedButtons.RETRYABORTCANCEL: kbtnButton1.Text = "&Retry"; kbtnButton2.Text = "A&bort"; kbtnButton3.Text = "C&ancel"; break; case KryptonMessageBoxExtendedButtons.CUSTOM: kbtnButton1.Text = kryptonButtonText1; kbtnButton2.Text = kryptonButtonText2; kbtnButton3.Text = kryptonButtonText3; switch (buttonCount) { case KryptonMessageBoxExtendedBoxButtonCount.ONE: kbtnButton1.Visible = false; kbtnButton2.Visible = false; kbtnButton3.Visible = true; break; case KryptonMessageBoxExtendedBoxButtonCount.TWO: kbtnButton1.Visible = false; kbtnButton2.Visible = true; kbtnButton3.Visible = true; break; case KryptonMessageBoxExtendedBoxButtonCount.THREE: kbtnButton1.Visible = true; kbtnButton2.Visible = true; kbtnButton3.Visible = true; break; default: break; } break; default: break; } }
/// <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); }