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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
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.Navigation;
using System.Windows.Shapes;
using XImagingXhandler.XDAL;
using XCommon.Log;
namespace XHandler.View.MethodProperty
{
    /// <summary>
    /// TimerProperty.xaml 的交互逻辑
    /// </summary>
    public partial class TimerProperty : UserControl
    {
        public MethodTimer methodTimer { get; set; }
        public MethodTimer currmethodTimer = null;
        public MethodEx method = null;
 
        #region 全局属性变量
        string isrun = "";
        string status = "";
        string name = "";
        string label = "";
        string duringTime = "";
        string duringTimeInfo = "";
        int mark = 0;
        #endregion
 
        public TimerProperty()
        {
            InitializeComponent();
        }
 
        public TimerProperty(MethodEx method)
        {
            InitializeComponent();
            mark = 0;
            methodTimer = new MethodTimer();
            methodTimer.name = method.method_name;
            methodTimer.label = method.method_name;
            methodTimer.status = (method.isEnabled == true ? "enable" : "disable");
            methodTimer.isrun = "disable";
            methodTimer.strIndex = method.strIndex;
 
            this.method = method;
            if (method.tag != null)
            {
                methodTimer = (MethodTimer)method.tag;
 
                currmethodTimer = methodTimer;
                isrun = methodTimer.isrun;
                status = methodTimer.status;
                name = methodTimer.name;
                label = methodTimer.label;
                duringTime = methodTimer.duringTime;
                duringTimeInfo = methodTimer.duringTimeInfo;
            }
            this.DataContext = methodTimer;
        }
 
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            mark += 1;
            try
            {
                if (mark > 1)
                {
                    return;
                }
                if (!string.IsNullOrEmpty(duringTime) || !string.IsNullOrEmpty(duringTimeInfo))
                {
                    tbxCommandName.Text = name;
 
 
                    tbxDuringTime.Text = duringTime;
                    tbxDuringTimeMsg.Text = duringTimeInfo;
 
                    if (currmethodTimer != null)
                    {
                        methodTimer = currmethodTimer;
                    }
                }
                else
                {
                    tbxDuringTime.Text = "1";
 
                    if (currmethodTimer != null)
                    {
                        methodTimer = currmethodTimer;
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void tbxDuringTime_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                string message = "";
                if (!Consumables.ConsumablesValidationRule.IsNullOrEmpty(tbxDuringTime.Text, out message))
                {
                    ptError.Text = message;
                    return;
                }
                if (!Consumables.ConsumablesValidationRule.IsPositiveIntegerr(tbxDuringTime.Text, out message))
                {
                    ptError.Text = message;
                    return;
                }
                ptError.Text = "";
                if (methodTimer != null)
                {
                    methodTimer.duringTime = tbxDuringTime.Text;
                    if (this.method != null)
                    {
                        this.method.method_Tipcontent = string.Format("{0}s", methodTimer.duringTime.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void tbxDuringTimeMsg_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                string message = "";
                if (!Consumables.ConsumablesValidationRule.IsNullOrEmpty(tbxDuringTimeMsg.Text, out message))
                {
                    pmError.Text = message;
                    return;
                }
                if (!Consumables.ConsumablesValidationRule.IsLength(tbxDuringTimeMsg.Text, 200, out message))
                {
                    pmError.Text = message;
                    return;
                }
                pmError.Text = "";
                if (methodTimer != null)
                {
                    methodTimer.duringTimeInfo = tbxDuringTimeMsg.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (methodTimer != null)
                {
                    methodTimer.name = tbxCommandName.Text;
                    //调用更新Wairfor中的Timer
                    var mainWin = (MainWindow)Application.Current.MainWindow;
                    if (mainWin != null)
                    {
                        if (mark > 1)
                        {
                            mainWin.testDesign.updateWaitforOnWorkflow();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
    }
}