/// <summary> /// Shows a message box with a message, title, standard buttons, and a standard icon. /// </summary> /// <param name="message">Text to display in the dialog box</param> /// <param name="title">Title of the dialog box</param> /// <param name="type">A standard <see cref="MessageBoxExType" /> value</param> /// <param name="icon">A standard <see cref="MessageBoxExIcons" /> value.</param> /// <returns>A <see cref="MessageBoxExResult" /> value</returns> public static MessageBoxExResult Show(string message, string title, MessageBoxExType type, MessageBoxExIcons icon) { var cfg = new MessageBoxExConfig() { Message = message, Title = title, Icon = icon, MessageBoxType = type }; return(Show(cfg)); }
private static List <MessageBoxExButton> MakeButtons(MessageBoxExType b) { if (ResourceTextConfig == null) { ResourceTextConfig = new ResourceTextConfig("DataTools.MessageBoxEx.Resources.AppResources", Assembly.GetCallingAssembly()); } var rtc = ResourceTextConfig; var btnOut = new List <MessageBoxExButton>(); switch (b) { case MessageBoxExType.AbortRetryIgnore: btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Abort), MessageBoxExResult.Abort)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Retry), MessageBoxExResult.Retry, true)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Ignore), MessageBoxExResult.Ignore)); break; case MessageBoxExType.OK: btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.OK), MessageBoxExResult.OK, true)); break; case MessageBoxExType.OKCancel: btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.OK), MessageBoxExResult.OK, true)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Cancel), MessageBoxExResult.Cancel, false)); break; case MessageBoxExType.YesNo: btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Yes), MessageBoxExResult.Yes, true)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.No), MessageBoxExResult.No, false)); break; case MessageBoxExType.YesNoCancel: btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Yes), MessageBoxExResult.Yes, true)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.No), MessageBoxExResult.No, false)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Cancel), MessageBoxExResult.Cancel, false)); break; case MessageBoxExType.YesNoAll: btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Yes), MessageBoxExResult.Yes, true)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.YesToAll), MessageBoxExResult.YesToAll, false)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.No), MessageBoxExResult.No, false)); break; case MessageBoxExType.YesNoAllCancel: btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Yes), MessageBoxExResult.Yes, true)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.YesToAll), MessageBoxExResult.YesToAll, false)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.No), MessageBoxExResult.No, false)); btnOut.Add(new MessageBoxExButton(rtc.GetText(MessageBoxExResult.Cancel), MessageBoxExResult.Cancel, false)); break; } return(btnOut); }
/// <summary> /// Shows a message box with a message, title, standard buttons, a standard icon, and an option toggle. /// </summary> /// <param name="message">Text to display in the dialog box</param> /// <param name="title">Title of the dialog box</param> /// <param name="optionText">Option toggle button message</param> /// <param name="type">A standard <see cref="MessageBoxExType" /> value</param> /// <param name="icon">A standard <see cref="MessageBoxExIcons" /> value</param> /// <param name="optionResult">The result of the option toggle button</param> /// <returns>A <see cref="MessageBoxExResult" /> value</returns> public static MessageBoxExResult Show(string message, string title, string optionText, MessageBoxExType type, MessageBoxExIcons icon, out bool optionResult) { var cfg = new MessageBoxExConfig() { Message = message, Title = title, OptionText = optionText, OptionMode = OptionTextMode.Checkbox, Icon = icon, MessageBoxType = type }; var ret = Show(cfg); optionResult = cfg.OptionResult; return(ret); }