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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using DataEntity.Share;
using DataEntity.Sockets.TakePhoto;
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>
    /// PlsWaitForwin.xaml 的交互逻辑
    /// </summary>
    public partial class PlsWaitForwin : Window
    {
        System.Windows.Threading.DispatcherTimer timer;  //用于计时数
        int totalTime = 0;
 
        public PlsWaitForwin()
        {
            InitializeComponent();
        }
 
        public PlsWaitForwin(MethodTimer methodTimer,MethodWaitFor methodWaitFor)
        {
            InitializeComponent();
 
            totalTime = Convert.ToInt32(methodTimer.duringTime);
 
            tbkTimerName.Text = methodWaitFor.duringTimeText;
            tbkDuringTime.Text = methodTimer.duringTime;
            tbkContent.Text = methodTimer.duringTimeInfo;
 
            if (methodWaitFor.enableEndWaitfor)
            {
                btnEndTimer.Visibility = Visibility.Visible;
            }
            else
            {
                btnEndTimer.Visibility = Visibility.Collapsed;
            }
 
            this.Owner = (Window)Shared.Main;
        }
 
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                tbkCountdownTime.Text = totalTime.ToString();
 
                //启动一秒计时器刷新提示
                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();
            }
            catch(Exception ex)
            {
 
            }
        }
 
        #region 结束计时
        private void btnEndTimer_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                timer.Stop();
                this.Close();
            }));
        }
        #endregion
 
        #region 计时器时间
        private void timer_OnTime(object sender, EventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                if (totalTime > 0)
                {
                    tbkCountdownTime.Text = totalTime.ToString();
                    totalTime--;
                }
                else if (totalTime == 0)
                {
                    this.Close();
                }
            }));
        }
        #endregion
    }
}