Пример #1
0
        public MessageBoxEx(EnumNotifyType type, string message)
        {
            InitializeComponent();
            CommonInit();

            label_title.Text   = type.GetDescription(); //标题
            label_message.Text = message;               //内容
            btn_cancel.Visible = false;                 //隐藏取消按钮

            //type
            switch (type)
            {
            case EnumNotifyType.Error:
                label_image.Text = NotifyIconError;
                _labelImgFont    = 68;
                break;

            case EnumNotifyType.Warning:
                label_image.Text = NotifyIconWarning;
                _labelImgFont    = 68;
                break;

            case EnumNotifyType.Info:
                label_image.Text = NotifyIconInfo;
                _labelImgFont    = 75;
                break;

            case EnumNotifyType.Question:
                label_image.Text   = NotifyIconQuestion;
                _labelImgFont      = 75;
                btn_cancel.Visible = true;
                break;
            }
        }
Пример #2
0
        public MessageBoxEx(EnumNotifyType type, string message)
        {
            InitializeComponent();
            CommonInit();

            this.label_title.Text   = type.GetDescription(); //标题
            this.label_message.Text = message;               //内容
            this.btn_cancel.Visible = false;                 //隐藏取消按钮
            this.Text = this.label_title.Text;               //将标题与label_title绑定

            //type
            switch (type)
            {
            case EnumNotifyType.Error:
                this.label_image.Text = NotifyIconError;
                LabelImgFont          = 60;
                break;

            case EnumNotifyType.Warning:
                this.label_image.Text = NotifyIconWarning;
                LabelImgFont          = 58;
                break;

            case EnumNotifyType.Info:
                this.label_image.Text = NotifyIconInfo;
                LabelImgFont          = 65;
                break;

            case EnumNotifyType.Question:
                this.label_image.Text   = NotifyIconQuestion;
                LabelImgFont            = 65;
                this.btn_cancel.Visible = true;
                break;
            }
        }
Пример #3
0
        /// <summary>
        /// 显示提示消息框,owner默认参数值为null,则当前顶层窗体为父窗体。
        /// </summary>
        private static bool Show(EnumNotifyType type, string mes, Window owner = null)
        {
            var res = true;

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                MessageBoxX nb = new MessageBoxX(type, mes)
                {
                    Title = type.GetDescription()
                };
                nb.Owner = owner ?? ControlHelper.GetTopWindow();
                nb.ShowDialog();
                res = nb.Result;
            }));
            return(res);
        }