예제 #1
0
        /// <summary>
        /// 显示确认对话框
        /// </summary>
        /// <param name="p_content">消息内容</param>
        /// <param name="p_title">标题</param>
        /// <returns>true表确认</returns>
        public Task <bool> Confirm(string p_content, string p_title)
        {
            var dlg = new Dlg {
                Title = p_title, IsPinned = true
            };

            if (Kit.IsPhoneUI)
            {
                dlg.PhonePlacement = DlgPlacement.CenterScreen;
                dlg.Width          = SysVisual.ViewWidth - 40;
            }
            else
            {
                dlg.WinPlacement = DlgPlacement.CenterScreen;
                dlg.MinWidth     = 300;
                dlg.MaxWidth     = SysVisual.ViewWidth / 4;
                dlg.ShowVeil     = true;
            }
            Grid grid = new Grid {
                Margin = new Thickness(10)
            };

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1.0, GridUnitType.Star)
            });
            grid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });
            TextBlock tb = new TextBlock {
                Text = p_content, TextWrapping = TextWrapping.Wrap
            };

            grid.Children.Add(tb);

            StackPanel spBtn = new StackPanel {
                Orientation = Orientation.Horizontal, Margin = new Thickness(0, 20, 0, 0), HorizontalAlignment = HorizontalAlignment.Right
            };
            var btn = new Button {
                Content = "确认", Margin = new Thickness(0, 0, 20, 0)
            };

            btn.Click += (s, e) => dlg.Close(true);
            spBtn.Children.Add(btn);
            btn = new Button {
                Content = "取消"
            };
            btn.Click += (s, e) => dlg.Close(false);
            spBtn.Children.Add(btn);
            Grid.SetRow(spBtn, 1);
            grid.Children.Add(spBtn);
            dlg.Content = grid;
            return(dlg.ShowAsync());
        }
예제 #2
0
 void OnClosed(object sender, EventArgs e)
 {
     if (_dlg != null)
     {
         _dlg.Close();
     }
 }
예제 #3
0
 private void taskm_Faulted(object sender, TaskFaultedEventArgs e)
 {
     logger.Log(string.Format(Resources.ResetError, e.Exception), Category.Exception, Priority.None);
     Exception  = e.Exception;
     Dlg.Result = false;
     Dlg.Close();
 }
예제 #4
0
 private void taskmIsEmptyPage_Faulted(object sender, TaskFaultedEventArgs e)
 {
     logger.Log(string.Format(Resources.IsEmptyError, GetMemoryType(), e.Exception), Category.Exception, Priority.None);
     Exception  = e.Exception;
     Dlg.Result = false;
     Dlg.Close();
 }
예제 #5
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs <IMemory> e)
 {
     logger.Log(string.Format(Resources.ReadCompleted, GetMemoryType()), Category.Debug, Priority.None);
     Memory     = e.Result;
     Dlg.Result = true;
     Dlg.Close();
 }
예제 #6
0
        /// <summary>
        /// 执行页面后退
        /// </summary>
        /// <returns></returns>
        public static async void GoBack()
        {
            if (SysVisual.ExistDlg)
            {
                Dlg dlg = SysVisual.GetTopDlg() as Dlg;
                if (dlg != null)
                {
                    dlg.Close();
                }
                return;
            }

            var frame = SysVisual.RootFrame;

            if (frame.CanGoBack)
            {
                if (frame.Content is PhonePage page)
                {
                    // 因OnNavigatingFrom中的取消导航无法实现异步!在此处判断
                    if (await page.IsAllowBack())
                    {
                        frame.GoBack();
                    }
                }
                else
                {
                    frame.GoBack();
                }
            }
        }
예제 #7
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs <byte> e)
 {
     logger.Log(string.Format(Resources.ReadLockCompleted, e.Result), Category.Debug, Priority.None);
     Locks      = e.Result;
     Dlg.Result = true;
     Dlg.Close();
 }
예제 #8
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs <Tuple <int, DateTime> > e)
 {
     logger.Log(Resources.ConnectionCompleted, Category.Debug, Priority.None);
     Version    = e.Result.Item1;
     Date       = e.Result.Item2;
     Dlg.Result = true;
     Dlg.Close();
 }
예제 #9
0
 private void taskm_Canceled(object sender, TaskCanceledEventArgs e)
 {
     logger.Log(Resources.ResetStoped, Category.Debug, Priority.None);
     Dlg.Result = false;
     Dlg.Close();
 }
예제 #10
0
 private void taskm_Completed(object sender, TaskCompletedEventArgs <bool> e)
 {
     logger.Log(Resources.ResetCompleted, Category.Debug, Priority.None);
     Dlg.Result = true;
     Dlg.Close();
 }
예제 #11
0
 private void taskm_Canceled(object sender, TaskCanceledEventArgs e)
 {
     logger.Log(string.Format(Resources.ReadStoped, GetMemoryType()), Category.Debug, Priority.None);
     Dlg.Result = false;
     Dlg.Close();
 }
예제 #12
0
 protected virtual void OnOk()
 {
     Dlg.Result = true;
     Dlg.Close();
 }
예제 #13
0
 protected virtual void OnClose()
 {
     Dlg.Result = false;
     Dlg.Close();
 }