Beispiel #1
0
        /// <summary>
        /// 显示消息框
        /// </summary>
        /// <param name="cmessageBoxText">消息内容</param>
        public static CMessageBoxResult Show(string cmessageBoxText)
        {
            CMessageBoxWindow window = null;

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                window = new CMessageBoxWindow();
            }));
            window.MessageBoxText     = cmessageBoxText;
            window.OKButtonVisibility = Visibility.Visible;
            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                window.ShowDialog();
            }));
            return(window.Result);
        }
Beispiel #2
0
        /// <summary>
        /// 显示消息框
        /// </summary>
        /// <param name="cmessageBoxText">消息内容</param>
        /// <param name="caption">消息标题</param>
        /// <param name="CMessageBoxButton">消息框按钮</param>
        /// <param name="CMessageBoxImage">消息框图标</param>
        /// <param name="CMessageBoxDefaultButton">消息框默认按钮</param>
        /// <returns></returns>
        public static CMessageBoxResult Show(string cmessageBoxText, string caption, CMessageBoxButton CMessageBoxButton, CMessageBoxImage CMessageBoxImage, CMessageBoxDefaultButton CMessageBoxDefaultButton)
        {
            CMessageBoxWindow window = null;

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                window = new CMessageBoxWindow();
            }));
            window.MessageBoxText  = cmessageBoxText;
            window.MessageBoxTitle = caption;
            window.ImagePath       = BoxImageSelect(CMessageBoxImage);
            #region  钮
            switch (CMessageBoxButton)
            {
            case CMessageBoxButton.OK:
            {
                window.OKButtonVisibility = Visibility.Visible;
                break;
            }

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

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

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

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

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

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

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

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

            case CMessageBoxDefaultButton.None:
            {
                break;
            }

            default:
            {
                break;
            }
            }
            #endregion

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                window.ShowDialog();
            }));
            return(window.Result);
        }