/// <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.Style.Default") as Style; //f.Style = myResourceDictionary["S.FButton.Style.Link"] as Style; f.Click += (object sender, RoutedEventArgs e) => { box.BegionStoryClose(); }; box.actionPanel.Children.Add(f); box.ShowDialog(); }
/// <summary> 显示窗口 </summary> public static void ShowDialogWith(Action <ProgressWindow> action, string title = null, params Tuple <string, Action>[] acts) { ProgressWindow p = new ProgressWindow(); if (!string.IsNullOrEmpty(title)) { p.Title = title; } if (acts == null || acts.Length == 0) { } else { p.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.Style = f.FindResource("DefaultFButtonStyle") as Style; f.Click += (object sender, RoutedEventArgs e) => { p.BegionStoryClose(); if (item.Item2 != null) { item.Item2.Invoke(); } }; p.actionPanel.Children.Add(f); } } Task t = new Task(() => action(p)); t.Start(); p.ShowDialog(); }
/// <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, params Tuple <string, Action <MessageWindow> >[] acts) { int result = -1; MessageWindow m = new MessageWindow(); if (messge.Contains('B')) { //// Todo :消息 2017-07-28 10:46:24 //m.messageText.Text = messge; m.messageText.Text = messge.Split('B')[0]; m.messageText1.Text = "B" + messge.Split('B')[1]; } else { // Todo :消息 2017-07-28 10:46:24 m.messageText.Text = messge; m.messageText1.Text = string.Empty; } 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.Style = f.FindResource("DefaultFButtonStyle") as Style; f.FIcon = ""; 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); }