/// <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();
        }
예제 #2
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.Width = double.NaN;
                    f.Margin = new Thickness(0, 0, 10, 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.CloseAnimation(m);
                    };

                    m.actionPanel.Children.Add(f);
                }
            }

            m.ShowDialog();


            return(result);
        }
        /// <summary>
        /// 应用样式
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            btnFirst    = GetTemplateChild(ElementFirstPageImageButton) as FButton;
            btnPrevious = GetTemplateChild(ElementPerviousPageImageButton) as FButton;
            btnNext     = GetTemplateChild(ElementNextPageImageButton) as FButton;
            btnLast     = GetTemplateChild(ElementLastPageImageButton) as FButton;
            btnRefresh  = GetTemplateChild(ElementRefreshImageButton) as FButton;

            cboPageSize  = GetTemplateChild(ElementPageSizeListComBox) as ComboBox;
            txtPageIndex = GetTemplateChild(ElementPageIndexTextBox) as TextBox;

            tbPageCount = GetTemplateChild(ElementPageCountTextBlock) as TextBlock;
            tbStart     = GetTemplateChild(ElementStartTextBlock) as TextBlock;
            tbEnd       = GetTemplateChild(ElementEndTextBlock) as TextBlock;
            tbCount     = GetTemplateChild(ElementCountTextBlock) as TextBlock;

            btnFirst.Click    += new RoutedEventHandler(btnFirst_Click);
            btnLast.Click     += new RoutedEventHandler(btnLast_Click);
            btnNext.Click     += new RoutedEventHandler(btnNext_Click);
            btnPrevious.Click += new RoutedEventHandler(btnPrevious_Click);
            btnRefresh.Click  += new RoutedEventHandler(btnRefresh_Click);

            cboPageSize.SelectionChanged += new SelectionChangedEventHandler(cboPageSize_SelectionChanged);
            txtPageIndex.PreviewKeyDown  += new KeyEventHandler(txtPageIndex_PreviewKeyDown);
            txtPageIndex.LostFocus       += new RoutedEventHandler(txtPageIndex_LostFocus);

            this.scrolls = GetTemplateChild(ElementScrollViewer) as ScrollViewer;

            this.Loaded += new RoutedEventHandler(PagingDataGrid_Loaded);
        }
예제 #4
0
        /// <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();
        }
        public void BuildButtons(params Tuple <string, Action <MessageUserControl> >[] acts)
        {
            int result = -1;

            List <Label> ls = new List <Label>();

            if (acts == null || acts.Length == 0)
            {
                return;
            }

            this.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(this);
                    }

                    result = acts.ToList().IndexOf(item);

                    this.Visibility = Visibility.Collapsed;
                };

                this.actionPanel.Children.Add(f);
            }
        }
        /// <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);
        }