Exemplo n.º 1
0
        /// <summary> 显示窗口 </summary>
        public static bool ShowDialog(string messge, string title = null, int closeTime = -1, bool isuseBlur = false, params Tuple <string, Action>[] acts)
        {
            if (isuseBlur)
            {
                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 (isuseBlur)
            {
                MessageService.BeginDefaultBlurEffect(false);
            }


            return(m._result);
        }
Exemplo n.º 2
0
        /// <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("DefaultFButtonStyle") as Style;

                    //f.Style = myResourceDictionary["FButton_LinkButton"] 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);
        }
Exemplo n.º 3
0
        /// <summary> 显示窗口 </summary>
        public static int ShowDialogWith(string messge, string title = null, bool isuseBlur = false, params Tuple <string, Action <MessageWindow> >[] acts)
        {
            if (isuseBlur)
            {
                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 (isuseBlur)
            {
                MessageService.BeginDefaultBlurEffect(false);
            }


            return(result);
        }
Exemplo n.º 4
0
        /// <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);
        }