/// <summary> /// Create and show a Modern Messagebox /// </summary> /// <param name="parentWindow">the owner of the messagebox window</param> /// <param name="msg">Message</param> /// <param name="title">Title</param> /// <param name="btns"> /// The bottons to show /// </param> /// <param name="icon"> /// The icon to show /// </param> /// <param name="playSound">play the system sound when the messageBox show</param> public static ModernMessageboxResult Show(Window parentWindow, string msg, string title, QModernMessageBoxButtons btns, ModernMessageboxIcons icon = ModernMessageboxIcons.None, bool playSound = true) { var msgBox = new ModernMessageBox(msg, title, icon) { Background = GlobalBackground, Foreground = GlobalForeground, Owner = parentWindow, }; switch (btns) { case QModernMessageBoxButtons.Ok: msgBox.Button1Text = MainLang.Ok; msgBox.Button1Key = Key.Enter; break; case QModernMessageBoxButtons.OkCancel: msgBox.Button1Text = MainLang.Ok; msgBox.Button1Key = Key.Enter; msgBox.Button2Status = ModernMessageboxButtonStatus.Normal; msgBox.Button2Text = MainLang.Cancel; msgBox.Button2Key = Key.Escape; break; case QModernMessageBoxButtons.YesNo: msgBox.Button1Text = MainLang.Yes; msgBox.Button1Key = Key.Y; msgBox.Button2Status = ModernMessageboxButtonStatus.Normal; msgBox.Button2Text = MainLang.No; msgBox.Button2Key = Key.N; msgBox.CloseCaptionButtonEnabled = false; break; case QModernMessageBoxButtons.YesNoCancel: msgBox.Button1Text = MainLang.Yes; msgBox.Button1Key = Key.Y; msgBox.Button2Status = ModernMessageboxButtonStatus.Normal; msgBox.Button2Text = MainLang.No; msgBox.Button2Key = Key.N; msgBox.Button3Status = ModernMessageboxButtonStatus.Normal; msgBox.Button3Text = MainLang.Cancel; msgBox.Button3Key = Key.Escape; break; case QModernMessageBoxButtons.AbortRetryIgnore: msgBox.Button1Text = MainLang.Abort; msgBox.Button1Key = Key.A; msgBox.Button2Status = ModernMessageboxButtonStatus.Normal; msgBox.Button2Text = MainLang.Retry; msgBox.Button2Key = Key.R; msgBox.Button3Status = ModernMessageboxButtonStatus.Normal; msgBox.Button3Text = MainLang.Ignore; msgBox.Button3Key = Key.I; msgBox.CloseCaptionButtonEnabled = false; break; default: throw new ArgumentOutOfRangeException(nameof(btns), btns, null); } msgBox.ShowDialog(); return(msgBox.Result); }
/// <summary> /// Create and show a Modern Messagebox /// </summary> /// <param name="msg">Message</param> /// <param name="title">Title</param> /// <param name="btns"> /// The bottons to show /// </param> /// <param name="icon"> /// The icon to show /// </param> /// <param name="playSound">play the system sound when the messageBox show</param> public static ModernMessageboxResult Show(string msg, string title, QModernMessageBoxButtons btns, ModernMessageboxIcons icon = ModernMessageboxIcons.None, bool playSound = true) => Show(GlobalParentWindow, msg, title, btns, icon, playSound);