schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using DataEntity.Share;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using XImagingXhandler.XDAL;
 
namespace XHandler.View.MethodProperty
{
    /// <summary>
    /// PlsPausewin.xaml 的交互逻辑
    /// </summary>
    public partial class PlsPausewin : Window
    {
        int totalTime = 0;
        string TipInfo=string.Empty;
        int model = 0;
        System.Windows.Threading.DispatcherTimer timer;
 
        public PlsPausewin(MethodPauseMove methodPauseMove)
        {
            InitializeComponent();
 
            model = methodPauseMove.pauseMode;
            if (model == 0)
            {
                totalTime = Convert.ToInt32(methodPauseMove.pauseTime);
            }
            else
            {
                TipInfo = methodPauseMove.pauseTipInfo;
            }
            this.Owner = (Window)Shared.Main;
        }
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //启动倒计时
            if(model==0)
            {
                textblockMsg.Text = "系统需要暂停"+totalTime.ToString()+"S";
                textblockData.Text = "倒计时"+ totalTime + "S";
                //启动一秒计时器刷新提示
                timer=new System.Windows.Threading.DispatcherTimer();
                timer.Interval = new TimeSpan(0, 0, 1);//设置的间隔为一秒
                timer.Tick += timer_OnTime;//设置定时器溢出触发事件
                                           //timer = new System.Windows.Threading.DispatcherTimer(new System.Windows.Threading(timer_OnTime), null, -1, 1000);
                                           //timer.
                                           //开启定时器
                timer.Start();
            }
            else
            {
                textblockMsg.Text = TipInfo;
            }
        }
 
        private void timer_OnTime(object sender, EventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                if (totalTime > 0)
                {
                    textblockData.Text = "倒计时" + totalTime + "S";
                    totalTime--;
                }
                else if(totalTime == 0)
                {
                    this.Close();
                }
            }));
        }
    }
}