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; } }
public MessageBoxX(EnumNotifyType type, string mes, string title = "系统提示") { InitializeComponent(); this.Title = title; this.txtMessage.Text = mes; //type btnCancel.Visibility = Visibility.Collapsed; this.SetForeground(type); switch (type) { case EnumNotifyType.Error: this.ficon.Text = "\ue644"; break; case EnumNotifyType.Warning: this.ficon.Text = "\ue60b"; break; case EnumNotifyType.Info: this.ficon.Text = "\ue659"; break; case EnumNotifyType.Question: this.ficon.Text = "\ue60e"; this.btnCancel.Visibility = Visibility.Visible; break; } }
public MessageBoxX(EnumNotifyType type, string mes) { InitializeComponent(); this.txtMessage.Text = mes; //type btnCancel.Visibility = Visibility.Collapsed; this.SetForeground(type); switch (type) { case EnumNotifyType.Success: this.ficon.Text = "\xe66a"; break; case EnumNotifyType.Error: this.ficon.Text = "\xe669"; break; case EnumNotifyType.Warning: this.ficon.Text = "\xe603"; break; case EnumNotifyType.Info: this.ficon.Text = "\xe605"; break; case EnumNotifyType.Question: this.ficon.Text = "\xe606"; this.btnCancel.Visibility = Visibility.Visible; break; } }
public MessageBoxz(EnumNotifyType type, string msg) { InitializeComponent(); this.TxtMessage.Text = msg; BtnCancel.Visibility = Visibility.Collapsed; this.SetForeground(type); switch (type) { case EnumNotifyType.Error: this.txtIcon.Text = "\ue083"; break; case EnumNotifyType.Warning: this.txtIcon.Text = "\ue209"; break; case EnumNotifyType.Info: this.txtIcon.Text = "\ue209"; break; case EnumNotifyType.Question: this.txtIcon.Text = "\ue085"; this.BtnCancel.Visibility = Visibility.Visible; break; } }
public MessageBoxX(EnumNotifyType type, string mes) { InitializeComponent(); txtMessage.Text = mes; //type btnCancel.Visibility = Visibility.Collapsed; switch (type) { case EnumNotifyType.Error: tishi.Text = "!"; break; case EnumNotifyType.Warning: tishi.Text = "!"; break; case EnumNotifyType.Info: tishi.Text = "!"; break; case EnumNotifyType.Question: tishi.Text = "?"; btnCancel.Visibility = Visibility.Visible; break; } }
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; } }
private static bool Show(EnumNotifyType type, string mes, Form owner = null) { var mb = new MessageBoxEx(type, mes) { Owner = owner }; mb.ShowDialog(); return(mb.Result); }
private void SetForeground(EnumNotifyType type) { string key = type.ToSafeString() + "Foreground"; if (!_Brushes.ContainsKey(key)) { var b = this.TryFindResource(key) as Brush; _Brushes.Add(key, b); } this.Foreground = _Brushes[key]; }
private static bool Show(EnumNotifyType type, string mes, Form owner = null) { var res = true; MessageBoxEx mb = new MessageBoxEx(type, mes); mb.Owner = owner; mb.TopMost = owner == null ? true : owner.TopMost; mb.ShowDialog(); res = mb.Result; return(res); }
/// <summary> /// 显示提示消息框,owner指定所属父窗体,不指定则默认值为null。 /// </summary> private static bool Show(EnumNotifyType type, string msg, Window owner = null) { var result = true; Application.Current.Dispatcher.Invoke(() => { MessageBoxz nb = new MessageBoxz(type, msg) { Owner = owner ?? ControlHelper.GetTopWindow() }; nb.ShowDialog(); result = nb.Result; }); return(result); }
/// <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); }
public static string GetDescription(EnumNotifyType en) { Type type = en.GetType(); //获取类型 MemberInfo[] memberInfos = type.GetMember(en.ToString()); //获取成员 if (memberInfos != null && memberInfos.Length > 0) { DescriptionAttribute[] attrs = memberInfos[0].GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[]; //获取描述特性 if (attrs != null && attrs.Length > 0) { return(attrs[0].Description); //返回当前描述 } } return(en.ToString()); }
/// <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 = MessageBoxX.GetDescription(type) }; //nb.Width = SystemParameters.WorkArea.Size.Width * 0.277; // nb.Height = nb.Width / 2.2; nb.Owner = owner ?? Application.Current.MainWindow; //nb.AllowsTransparency = false; nb.ShowDialog(); res = nb.Result; })); return(res); }
public MessageBoxX(EnumNotifyType type, string mes) { InitializeComponent(); this.Width = SystemParameters.WorkArea.Size.Width * 0.277; this.Height = this.Width / 2.2; this.WindowStartupLocation = WindowStartupLocation.CenterScreen; this.txtMessage.Text = mes; this.txtMessage.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0)); //type btnCancel.Visibility = Visibility.Collapsed; //Console.WriteLine(type); this.SetForeground(type); switch (type) { case EnumNotifyType.Error: this.ficon.Text = "\ue644"; this.ficon.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); break; case EnumNotifyType.Warning: this.ficon.Text = "\ue60b"; this.ficon.Foreground = new SolidColorBrush(Color.FromRgb(255, 215, 0)); break; case EnumNotifyType.Info: this.ficon.Text = "\ue659"; this.ficon.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0)); break; case EnumNotifyType.Question: this.ficon.Text = "\ue60e"; this.ficon.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255)); this.btnCancel.Visibility = Visibility.Visible; break; } }