Exemple #1
0
 public static void Show(string title, string msg, int autoCloseDelayMs)
 {
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => {
         int times = (autoCloseDelayMs / 1000);
         if (times <= 0)
         {
             times = 1;
         }
         var msgBox              = new UIMessageBox();
         msgBox.Title            = title;
         msgBox.Message          = msg;
         msgBox.Topmost          = true;
         msgBox.confirm_btn.Text = $"确定{times}";
         msgBox.Show();
         SetInterval(1000, (i) => {
             Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                        new Action(() => {
                 if (i < times)
                 {
                     msgBox.confirm_btn.Text = "确定 (" + (times - i) + ")";
                 }
                 else
                 {
                     msgBox.Close();
                 }
             }));
         }, times);
     }));
 }
Exemple #2
0
        /// <summary>
        /// 静态方法 模拟MESSAGEBOX.Show方法
        /// </summary>
        /// <param name="title">标题</param>
        /// <param name="msg">消息</param>
        /// <returns></returns>
        public static bool?Show(string title, string msg)
        {
            var msgBox = new UIMessageBox();

            msgBox.Title   = title;
            msgBox.Message = msg;
            return(msgBox.ShowDialog());
        }