Esempio n. 1
0
        /// <summary>
        /// 显示消息框
        /// </summary>
        /// <param name="metromessageBoxText">消息内容</param>
        /// <param name="caption">消息标题</param>
        /// <param name="metroMessageBoxButton">消息框按钮</param>
        /// <param name="metroMessageBoxImage">消息框图标</param>
        /// <returns></returns>
        public static MetroMessageBoxResult Show(string metromessageBoxText, string caption, MetroMessageBoxButton metroMessageBoxButton, MetroMessageBoxImage metroMessageBoxImage)
        {
            var window = new MessageBoxView
            {
                MessageBoxText  = metromessageBoxText,
                MessageBoxTitle = caption
            };


            switch (metroMessageBoxButton)
            {
            case MetroMessageBoxButton.OK:
            {
                window.OKButtonVisibility = Visibility.Visible;
                break;
            }

            case MetroMessageBoxButton.OKCancel:
            {
                window.OKButtonVisibility     = Visibility.Visible;
                window.CancelButtonVisibility = Visibility.Visible;
                break;
            }

            case MetroMessageBoxButton.YesNO:
            {
                window.YesButtonVisibility = Visibility.Visible;
                window.NoButtonVisibility  = Visibility.Visible;
                break;
            }

            case MetroMessageBoxButton.YesNoCancel:
            {
                window.YesButtonVisibility    = Visibility.Visible;
                window.NoButtonVisibility     = Visibility.Visible;
                window.CancelButtonVisibility = Visibility.Visible;
                break;
            }

            default:
            {
                window.OKButtonVisibility = Visibility.Visible;
                break;
            }
            }

            try
            {
                window.ShowDialog();
            }
            catch (Exception)
            {
            }

            return(window.Result);
        }
Esempio n. 2
0
        /// <summary>
        /// 显示消息框
        /// </summary>
        /// <param name="cmessageBoxText">消息内容</param>
        public static MetroMessageBoxResult Show(string cmessageBoxText)
        {
            var window = new MessageBoxView
            {
                MessageBoxText     = cmessageBoxText,
                OKButtonVisibility = Visibility.Visible
            };

            try
            {
                window.ShowDialog();
            }
            catch (Exception)
            {
            }

            return(window.Result);
        }
Esempio n. 3
0
        /// <summary>
        /// 显示消息框
        /// </summary>
        /// <param name="metromessageBoxText">消息内容</param>
        /// <param name="caption">消息标题</param>
        /// <param name="metroMessageBoxButton">消息框按钮</param>
        /// <param name="metroMessageBoxImage">消息框图标</param>
        /// <param name="metroMessageBoxDefaultButton">消息框默认按钮</param>
        /// <returns></returns>
        public static MetroMessageBoxResult Show(string metromessageBoxText, string caption,
                                                 MetroMessageBoxButton metroMessageBoxButton,
                                                 MetroMessageBoxImage metroMessageBoxImage,
                                                 MetroMessageBoxDefaultButton metroMessageBoxDefaultButton)
        {
            var window = new MessageBoxView
            {
                MessageBoxText  = metromessageBoxText,
                MessageBoxTitle = caption
            };

            #region  钮
            switch (metroMessageBoxButton)
            {
            case MetroMessageBoxButton.OK:
            {
                window.OKButtonVisibility = Visibility.Visible;
                break;
            }

            case MetroMessageBoxButton.OKCancel:
            {
                window.OKButtonVisibility     = Visibility.Visible;
                window.CancelButtonVisibility = Visibility.Visible;
                break;
            }

            case MetroMessageBoxButton.YesNO:
            {
                window.YesButtonVisibility = Visibility.Visible;
                window.NoButtonVisibility  = Visibility.Visible;
                break;
            }

            case MetroMessageBoxButton.YesNoCancel:
            {
                window.YesButtonVisibility    = Visibility.Visible;
                window.NoButtonVisibility     = Visibility.Visible;
                window.CancelButtonVisibility = Visibility.Visible;
                break;
            }

            default:
            {
                window.OKButtonVisibility = Visibility.Visible;
                break;
            }
            }
            #endregion

            #region 默认按钮
            switch (metroMessageBoxDefaultButton)
            {
            case MetroMessageBoxDefaultButton.OK:
            {
                window.OKButtonStyle     = MessageBoxView.ButtonStyle.NormalButtonStyle;
                window.CancelButtonStyle = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.YesButtonStyle    = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.NoButtonStyle     = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                break;
            }

            case MetroMessageBoxDefaultButton.Cancel:
            {
                window.OKButtonStyle     = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.CancelButtonStyle = MessageBoxView.ButtonStyle.NormalButtonStyle;
                window.YesButtonStyle    = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.NoButtonStyle     = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                break;
            }

            case MetroMessageBoxDefaultButton.Yes:
            {
                window.OKButtonStyle     = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.CancelButtonStyle = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.YesButtonStyle    = MessageBoxView.ButtonStyle.NormalButtonStyle;
                window.NoButtonStyle     = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                break;
            }

            case MetroMessageBoxDefaultButton.No:
            {
                window.OKButtonStyle     = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.CancelButtonStyle = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.YesButtonStyle    = MessageBoxView.ButtonStyle.NotNormalButtonStyle;
                window.NoButtonStyle     = MessageBoxView.ButtonStyle.NormalButtonStyle;
                break;
            }

            case MetroMessageBoxDefaultButton.None:
            {
                break;
            }

            default:
            {
                break;
            }
            }
            #endregion

            #region 图标

            switch (metroMessageBoxImage)
            {
            case MetroMessageBoxImage.None:
                window.ImagePath = "/SimulaDesign.WPFCustomUI;component/Resource/MsgBox/none.png";
                break;

            case MetroMessageBoxImage.Info:
                window.ImagePath = "/SimulaDesign.WPFCustomUI;component/Resource/MsgBox/info.png";
                break;

            case MetroMessageBoxImage.Question:
                window.ImagePath = "/SimulaDesign.WPFCustomUI;component/Resource/MsgBox/question.png";
                break;

            case MetroMessageBoxImage.Warning:
                window.ImagePath = "/SimulaDesign.WPFCustomUI;component/Resource/MsgBox/warning.png";
                break;

            case MetroMessageBoxImage.Error:
                window.ImagePath = "/SimulaDesign.WPFCustomUI;component/Resource/MsgBox/error.png";
                break;

            default:
                break;
            }
            #endregion

            try
            {
                window.ShowDialog();
            }
            catch (Exception)
            {
            }

            return(window.Result);
        }