예제 #1
0
 /// <summary>
 /// 显示消息框
 /// </summary>
 /// <param name="Message">消息内容</param>
 /// <param name="Title">标题</param>
 /// <param name="Btns">按钮类型</param>
 /// <param name="Icon">图标类型</param>
 /// <param name="PlaySound">播放声音</param>
 /// <returns></returns>
 public static ModernMessageboxResult ShowMessageBox(
     string Message,
     string Title,
     QModernMessageBoxButtons Btns = QModernMessageBoxButtons.Ok,
     ModernMessageboxIcons Icon    = ModernMessageboxIcons.None,
     bool PlaySound = true)
 => ShowMessageBox(GlobalParentWindow, Message, Title, Btns, Icon, PlaySound);
        /// <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);