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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
using DataEntity.Share;
using DataRWDAL;
using HxEnum;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using XCommon.Log;
using XHandler.Class.DataEx;
using XHandler.Controls;
using XHandler.View.MethodProperty;
using XImagingXhandler.XDAL;
 
namespace XHandler.View.BacteriaProperty
{
    /// <summary>
    /// 接种转板方法属性页面
    /// </summary>
    public partial class CoatingAndTransferProperty : UserControl, IMethodProperty
    {
        #region 变量
        private int mark = 0;
        private PromptTextBox coatingLabware = null;    // 接种耗材类型
        public MethodCoatingAndTransfer methodCoating = null;
        private int[] channels = Shared.ChannelsId;
        #endregion
 
        #region 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="method"></param>
        public CoatingAndTransferProperty(MethodEx method)
        {
            mark = 0;
            InitializeComponent();
 
            methodCoating = new MethodCoatingAndTransfer();
            mark = 1;
            methodCoating.strIndex = method.strIndex;
            methodCoating.label = method.method_name;                                    // 命令标签
            methodCoating.name = method.method_name;                                     // 命令名称
            methodCoating.status = (method.isEnabled == true ? "enable" : "disable");
            this.DataContext = methodCoating;
 
            #region 获取机械臂信息
            methodCoating.channels = Shared.ChannelsId;
            List<DeviceArm> armList = DataModule.getInstance().GetDeviceArm();
            cbArm.ItemsSource = armList;
            // 只有一个臂的情况下默认选中该臂
            cbArm.SelectedIndex = armList.Count == 2 ? 1 : 0;
            #endregion
 
            #region 涂布方式
            ObservableCollection<DropdownName> coatingModeList = DataModule.getInstance().GetCoatingMode();
            ObservableCollection<DropdownName> coatingModeListNew = new ObservableCollection<DropdownName>();
            foreach (var coatingModeItem in coatingModeList)
            {
                // 上下、加液
                if (coatingModeItem.dropdown_name.Equals(Properties.Resources.strUpDownMode) ||
                    coatingModeItem.dropdown_name.Equals(Properties.Resources.strDispense))
                {
                    coatingModeListNew.Add(coatingModeItem);
                }
            }
 
            cbCoatingMode.ItemsSource = coatingModeListNew;
            #endregion
 
            #region 接种数量
            rdoCoatingCount1.IsChecked = true;
            #endregion
 
            if (Shared.ChannelCount > 1)
            {
                tipsChannel.CanEdit = true;
            }
 
            if (method.tag!=null)
            {
                methodCoating = (MethodCoatingAndTransfer)method.tag;
                channels = methodCoating.channels;
            }
        }
        #endregion
 
        #region 方法标签文件更改事件
        /// <summary>
        /// 方法标签文件更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbxCommandLabel_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark == 0)
                {
                    return;
                }
 
                methodCoating.label = tbxCommandLabel.Text;
            }
            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)
                {
                    return;
                }
 
                methodCoating.name = tbxCommandName.Text;
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 机械臂选择变更事件
        /// <summary>
        /// 机械臂选择变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbArm_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (mark == 0)
            {
                return;
            }
 
            // 臂未选择
            if (cbArm.SelectedIndex < 0 || cbArm.SelectedIndex == 0)
            {
                methodCoating.armText = "";      // 机械臂
                methodCoating.armValue = "";
                textboxArmHead.Text = "";        // 挑菌枪
 
                tipsChannel.SetTotalChannelCount(0);
                tipsChannel.SelectedChannels = new List<int>();
                tipsChannel.SetSelectedChannels();
                tipsChannel_SelectedChangedEvent(null, null);
                return;
            }
 
            #region 设置移液枪通道
            tipsChannel.SelectedChannels = Shared.ChannelsId.ToList();
            tipsChannel.SetTotalChannelCount(Shared.ChannelCount);
            tipsChannel.SetSelectedChannels();
            tipsChannel_SelectedChangedEvent(null, null);
            #endregion
 
            DeviceArm arm = cbArm.SelectedItem as DeviceArm;
            methodCoating.armText = arm.device_arm_name;
            methodCoating.armValue = arm.device_arm_id.ToString();
            methodCoating.headType = arm.head_type;
            textboxArmHead.Text = arm.head_type;
        }
        #endregion
 
        #region 涂布方式选择变更事件
        /// <summary>
        /// 涂布方式选择变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbCoatingMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (mark == 0)
            {
                return;
            }
 
            DropdownName dpdItem = (DropdownName)cbCoatingMode.SelectedItem;
            methodCoating.coatingModeValue = Convert.ToInt32(dpdItem.dropdown_id);
 
            // 回字型
            if (dpdItem.dropdown_id.Equals(EnumManagement.GetEnumValue(CoatingModeEnum.HuiziMode).ToString()))
            {
                gridShake.Visibility = Visibility.Collapsed;
            }
            // Z字型
            else if (dpdItem.dropdown_id.Equals(EnumManagement.GetEnumValue(CoatingModeEnum.ZMode).ToString()))
            {
                gridShake.Visibility = Visibility.Collapsed;
            }
            // 上下移动
            else if (dpdItem.dropdown_id.Equals(EnumManagement.GetEnumValue(CoatingModeEnum.UpDownMode).ToString()))
            {
                gridShake.Visibility = Visibility.Visible;
            }
            // 放液
            else if (dpdItem.dropdown_id.Equals(EnumManagement.GetEnumValue(CoatingModeEnum.DispenseMode).ToString()))
            {
                gridShake.Visibility = Visibility.Collapsed;
            }
        }
        #endregion
 
        #region 接种数量选择变更事件
        /// <summary>
        /// 接种数量选择变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rdoCoatingCount_Checked(object sender, RoutedEventArgs e)
        {
            if (mark == 0)
            {
                return;
            }
 
            methodCoating.coatingCount = rdoCoatingCount1.IsChecked == true ? 0 : 1;
        }
        #endregion
 
        #region 接种耗材
        /// <summary>
        /// 接种A耗材类型文字变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void coatingLabwareA_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (mark == 0)
            {
                return;
            }
            methodCoating.coatingLabwareAText = coatingLabwareA.Text;
            methodCoating.coatingLabwareAValue = coatingLabwareA.Tag.ToString();
        }
 
        /// <summary>
        /// 接种B耗材类型文字变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void coatingLabwareB_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (mark == 0)
            {
                return;
            }
            //methodCoating.coatingLabwareBText = coatingLabwareB.Text;
            //methodCoating.coatingLabwareBValue = coatingLabwareB.Tag.ToString();
        }
 
        /// <summary>
        /// 接种耗材获得焦点事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void coatingLabware_GotFocus(object sender, RoutedEventArgs e)
        {
            coatingLabware = (PromptTextBox)sender;
        }
        #endregion
 
        #region 自动开关盖点击事件
        /// <summary>
        /// 自动开关盖点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ckbAutoOpenCloseCover_Click(object sender, RoutedEventArgs e)
        {
            if (mark == 0)
            {
                return;
            }
            methodCoating.autoOpenCloseCover = ckbAutoOpenCloseCover.IsChecked == true ? 1 : 0;
        }
        #endregion
 
        #region 设置已选择的台面数据
        public void SetTableName(string tableName, Labware lb)
        {
            if (lb == null || string.IsNullOrEmpty(lb.labware_id))
            {
                return;
            }
 
            List<Lattice> latticeList = LatticeDB.GetLatticeDataFromdb(Shared.SoftwareInformation.software_device_number, Convert.ToInt32(methodCoating.armValue));
            Lattice lattice = latticeList.Find(s => s.lattice_num == tableName);
            if (lattice == null)
            {
                LoggerHelper.InfoLog("Error: Can't find lattice with lattice_num=" + tableName);
                return;
            }
 
            if (coatingLabware != null)
            {
                coatingLabware.Tag = lb.labware_id;
                coatingLabware.Text = lb.labware_name;
            }
        }
        #endregion
 
        #region 界面初期表示事件
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (mark == 0)
                {
                    return;
                }
 
                #region 机械臂
                if (!string.IsNullOrEmpty(methodCoating.armText))
                {
                    tbxCommandName.Text = methodCoating.name;
                    cbArm.SelectedValue = methodCoating.armValue;
                    DeviceArm arm = cbArm.SelectedItem as DeviceArm;
                    textboxArmHead.Text = arm.head_type;
                    // 通道
                    tipsChannel.SelectedChannels = channels.ToList();
                    tipsChannel_SelectedChangedEvent(null, null);
                }
                else
                {
                    cbArm.SelectedIndex = 0;
                    DeviceArm arm = cbArm.SelectedItem as DeviceArm;
                    if (arm != null)
                    {
                        textboxArmHead.Text = arm.head_type;
                    }
                }
                #endregion
 
                #region 涂布方式
                cbCoatingMode.SelectedValue = methodCoating.coatingModeValue.ToString();
                #endregion
 
                #region 涂布数量
                // 单板
                if (methodCoating.coatingCount == 0)
                {
                    rdoCoatingCount1.IsChecked = true;
                }
                // 双板
                else
                {
                    rdoCoatingCount2.IsChecked = true;
                }
                #endregion
 
                #region 接种耗材
                coatingLabwareA.Tag = methodCoating.coatingLabwareAValue;
                coatingLabwareA.Text = methodCoating.coatingLabwareAText;
 
                //coatingLabwareB.Tag = methodCoating.coatingLabwareBValue;
                //coatingLabwareB.Text = methodCoating.coatingLabwareBText;
                #endregion
 
                #region 自动开关盖
                ckbAutoOpenCloseCover.IsChecked = methodCoating.autoOpenCloseCover == 1;
                #endregion
 
                #region 涂布方式:上下相关
                tbxDistanceFromBottom.Text = methodCoating.distanceFromBottom.ToString();
                tbxShakeDistance.Text = methodCoating.shakeDistanceValue.ToString();
                tbxShakeCount.Text = methodCoating.shakeCountValue.ToString();
                #endregion
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 涂布方式:上下
        /// <summary>
        /// 距底距离更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbxDistanceFromBottom_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark == 0)
                {
                    return;
                }
 
                methodCoating.distanceFromBottom = Convert.ToInt32(tbxDistanceFromBottom.Text);
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        /// <summary>
        /// 移动距离更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbxShakeDistance_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark == 0)
                {
                    return;
                }
 
                methodCoating.shakeDistanceValue = float.Parse(tbxShakeDistance.Text);
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        /// <summary>
        /// 次数更改事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbxShakeCount_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark == 0)
                {
                    return;
                }
 
                methodCoating.shakeCountValue = Convert.ToInt32(tbxShakeCount.Text);
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
        #endregion
 
        #region 可用通道鼠标选择变更事件
        /// <summary>
        /// 可用通道鼠标选择变更事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tipsChannel_SelectedChangedEvent(object sender, EventArgs e)
        {
            methodCoating.channels = tipsChannel.SelectedChannels.ToArray();
        }
        #endregion
    }
}