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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
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 XCommon.Log;
using XCommon;
using XImagingXhandler.XDAL;
namespace XHandler.View.MethodProperty
{
    /// <summary>
    /// VariableCaculationProperty.xaml 的交互逻辑
    /// </summary>
    public partial class VariableCaculationProperty : UserControl, IMethodProperty
    {
        #region 变量
        private int mark = 0;
        public MethodVarCalc methodVarCalc = null;
        #endregion
 
        public VariableCaculationProperty()
        {
            InitializeComponent();
        }
 
        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="method"></param>
        public VariableCaculationProperty(MethodEx method)
        {
            InitializeComponent();
 
            mark = 0;
            methodVarCalc = new MethodVarCalc();
            methodVarCalc.strIndex = method.strIndex;
            methodVarCalc.label = method.method_name;                                    // 命令标签
            methodVarCalc.name = method.method_name;                                     // 命令名称
            methodVarCalc.status = (method.isEnabled == true ? "enable" : "disable");    // 使能状态
 
            cboxOperator.ItemsSource = ComUtility.GetDropDownList<CalcOperatorTypeEnum>();
 
            if (method.tag != null)
            {
                methodVarCalc = (MethodVarCalc)method.tag;
            }
            else
            {
                method.tag = methodVarCalc;
            }
 
            this.DataContext = methodVarCalc;
        }
        #endregion
 
        #region 界面初期表示事件
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            mark += 1;
            try
            {
                if (mark > 1)
                {
                    return;
                }
                if (methodVarCalc != null)
                {
                    tboxResult.Text = methodVarCalc.calcResult;
                    tboxValue1.Text = methodVarCalc.calcValue1;
                    tboxValue2.Text = methodVarCalc.calcValue2;
                    cboxOperator.SelectedValue = methodVarCalc.calcOperator.ToString();
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 方法名称更改事件
        /// <summary>
        /// 方法名称更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark != 0)
                {
                    methodVarCalc.name = tbxCommandName.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 方法标签文件更改事件
        /// <summary>
        /// 方法标签文件更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbxCommandLabel_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark != 0)
                {
                    methodVarCalc.label = tbxCommandLabel.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 计算结果更改事件
        /// <summary>
        /// 计算结果更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tboxResult_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark != 0)
                {
                    methodVarCalc.calcResult = tboxResult.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 计算值1更改事件
        /// <summary>
        /// 计算值1更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tboxValue1_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark != 0)
                {
                    methodVarCalc.calcValue1 = tboxValue1.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 计算值2更改事件
        /// <summary>
        /// 计算值2更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tboxValue2_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark != 0)
                {
                    methodVarCalc.calcValue2 = tboxValue2.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 计算操作符选择变更
        /// <summary>
        /// 计算操作符选择变更
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cboxOperator_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (cboxOperator.SelectedIndex < 0)
                {
                    return;
                }
 
                if (methodVarCalc != null)
                {
                    methodVarCalc.calcOperator = Convert.ToInt32(cboxOperator.SelectedValue.ToString());
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        public void SetTableName(string tableName, Labware lb)
        {
        }
    }
}