/// <summary> /// 弹出消息框 /// </summary> /// <param name="message">消息</param> /// <param name="owner">父级窗体</param> public static void ShowDialog(string message, Grid owner) { //蒙板 Grid layer = new Grid() { Background = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)) }; //在上面放一层蒙板 owner.Children.Add(layer); //弹出消息框 MessageWindow box = new MessageWindow(); box.Tag = owner; box.Title = message; box.Closed += Window_Closed; FButton f = new FButton(); f.Content = "确定"; f.Margin = new Thickness(0, 0, 20, 0); //f.Style = f.FindResource("S.FButton.Default") as Style; //f.Style = myResourceDictionary["FButton_LinkButton"] as Style; f.Style = Application.Current.FindResource("S.FButton.Style.Default") as Style; f.Click += (object sender, RoutedEventArgs e) => { box.CloseAnimation(box); }; box.actionPanel.Children.Add(f); box.ShowDialog(); }
/// <summary> 显示窗口 </summary> public static bool ShowDialog(string messge, string title = null, int closeTime = -1, bool showEffect = true, params Tuple <string, Action>[] acts) { if (showEffect) { MessageService.BeginDefaultBlurEffect(true); } MessageWindow m = new MessageWindow(); m.messageText.Text = messge; var array = messge.ToArray(); var c = array.ToList().Count(l => l == '\r'); m.Height += c * 30; if (!string.IsNullOrEmpty(title)) { m.Title = title; } if (acts == null || acts.Length == 0) { } else { m.actionPanel.Children.Clear(); foreach (var item in acts) { FButton f = new FButton(); f.Content = item.Item1; f.Margin = new Thickness(0, 0, 0, 0); //f.Style = f.FindResource("S.FButton.Default") as Style; f.Style = Application.Current.FindResource("S.FButton.Style.Default") as Style; f.Click += (object sender, RoutedEventArgs e) => { m.CloseAnimation(m); if (item.Item2 != null) { item.Item2.Invoke(); } }; m.actionPanel.Children.Add(f); } } if (closeTime != -1) { Action action = () => { for (int i = closeTime; i > 0; i--) { Thread.Sleep(1000); m.Dispatcher.Invoke(() => m.Title = title + " 关闭倒计时(" + i + ")秒"); } m.Dispatcher.Invoke(() => m.CloseAnimation(m)); }; Task task = new Task(action); task.Start(); } m.ShowDialog(); if (showEffect) { MessageService.BeginDefaultBlurEffect(false); } return(m._result); }
/// <summary> 显示窗口 </summary> public static bool ShowDialog(string messge, string title = null, int closeTime = -1, params Tuple <string, Action>[] acts) { MessageWindow m = new MessageWindow(); // Todo :消息 2017-07-28 10:46:24 m.messageText.Text = messge; var array = messge.ToArray(); var c = array.ToList().Count(l => l == '\r'); m.Height += c * 30; if (!string.IsNullOrEmpty(title)) { m.Title = title; } if (acts == null || acts.Length == 0) { } else { m.actionPanel.Children.Clear(); // Todo :根据事件加载按钮 2017-07-28 10:46:07 foreach (var item in acts) { FButton f = new FButton(); f.Content = item.Item1; //f.MinWidth = 300; //f.Width = 300; //f.Height = 80; f.Margin = new Thickness(0, 0, 20, 0); f.Style = f.FindResource("S.FButton.Style.Default") as Style; //f.Style = myResourceDictionary["S.FButton.Style.Link"] as Style; f.Click += (object sender, RoutedEventArgs e) => { m.BegionStoryClose(); if (item.Item2 != null) { item.Item2.Invoke(); } }; m.actionPanel.Children.Add(f); } } if (closeTime != -1) { Action action = () => { for (int i = closeTime; i > 0; i--) { Thread.Sleep(1000); m.Dispatcher.Invoke(() => m.Title = title + " 关闭倒计时(" + i + ")秒"); } m.Dispatcher.Invoke(() => m.BegionStoryClose()); }; Task task = new Task(action); task.Start(); } m.ShowDialog(); return(m._result); }
/// <summary> 显示窗口 </summary> public static int ShowDialogWith(string messge, string title = null, bool showEffect = false, params Tuple <string, Action <MessageWindow> >[] acts) { if (showEffect) { MessageService.BeginDefaultBlurEffect(true); } int result = -1; MessageWindow m = new MessageWindow(); // Todo :消息 2017-07-28 10:46:24 m.messageText.Text = messge; var array = messge.ToArray(); var c = array.ToList().Count(l => l == '\r'); m.Height += c * 30; List <Label> ls = new List <Label>(); if (!string.IsNullOrEmpty(title)) { m.Title = title; } if (acts == null || acts.Length == 0) { } else { m.actionPanel.Children.Clear(); // Todo :根据事件加载按钮 2017-07-28 10:46:07 foreach (var item in acts) { FButton f = new FButton(); f.Content = item.Item1; //f.Width = double.NaN; f.Margin = new Thickness(0, 0, 10, 0); //f.FIcon = ""; //f.SetPressed(false); f.Style = Application.Current.FindResource("S.FButton.Style.Default") as Style; f.Click += (object sender, RoutedEventArgs e) => { if (item.Item2 != null) { item.Item2(m); } result = acts.ToList().IndexOf(item); m.CloseAnimation(m); }; m.actionPanel.Children.Add(f); } } m.ShowDialog(); if (showEffect) { MessageService.BeginDefaultBlurEffect(false); } return(result); }
/// <summary> 显示窗口 </summary> public static int ShowDialogWith(string messge, string title = null, params Tuple <string, Action <MessageWindow> >[] acts) { int result = -1; MessageWindow m = new MessageWindow(); // Todo :消息 2017-07-28 10:46:24 m.messageText.Text = messge; var array = messge.ToArray(); var c = array.ToList().Count(l => l == '\r'); m.Height += c * 30; List <Label> ls = new List <Label>(); if (!string.IsNullOrEmpty(title)) { m.Title = title; } if (acts == null || acts.Length == 0) { } else { m.actionPanel.Children.Clear(); // Todo :根据事件加载按钮 2017-07-28 10:46:07 foreach (var item in acts) { FButton f = new FButton(); f.Content = item.Item1; f.MinWidth = 300; f.Width = double.NaN; f.Height = 80; f.Margin = new Thickness(0, 0, 20, 0); f.FIcon = ""; //f.SetPressed(false); f.Click += (object sender, RoutedEventArgs e) => { if (item.Item2 != null) { item.Item2(m); } result = acts.ToList().IndexOf(item); m.BegionStoryClose(); }; m.actionPanel.Children.Add(f); } } m.ShowDialog(); return(result); }