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
using DataEntity.Share;
using DataRWDAL;
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>
    /// CoatingProperty.xaml 的交互逻辑
    /// </summary>
    public partial class CoatingProperty : UserControl, IMethodProperty
    {
        Labware selectedLabware;
        public MethodCoating methodCoating { get; set; }
        public MethodCoating currmethodCoating = null;
 
        #region 全局属性变量
        string isrun = "";
        string status = "";
        string name = "";
        string label = "";
        string labwareText = "";
        string labwareValue = "";
        string positionText = "";
        string positionValue = "";
        string armText = "";
        string armValue = "";
        string headType = "";
        private int[] channels = Shared.ChannelsId;
        string wellarray = "";
        string coatingmodeText = "";
        string coatingmodeValue = "";
 
        static int mark = 0;
        int curArmSelectedIndex = -1;
        #endregion
 
        public CoatingProperty()
        {
            InitializeComponent();
        }
 
        public CoatingProperty(MethodEx method)
        {
            InitializeComponent();
            mark = 0;
 
            curArmSelectedIndex = 0;
 
 
            List<DeviceArm> armList = DataModule.getInstance().GetDeviceArm();
            cbArm.ItemsSource = armList;
            if (armList.Count == 2) //只有一个臂的情况下默认选中该臂
                cbArm.SelectedIndex = 1;
            else
                cbArm.SelectedIndex = 0;
 
            ObservableCollection<DropdownName> coatingModeList = DataModule.getInstance().GetCoatingMode();
            cbCoatingMode.ItemsSource = coatingModeList;
            cbCoatingMode.SelectedIndex = 0;
 
            List<string> list = new List<string>();
            List<Lattice> lattices = DataModule.getInstance().GetLattices();
            for (int i = 0; i < Shared.SoftwareInformation.columns; i++)
            {
                for (int j = 0; j < Shared.SoftwareInformation.rows; j++)
                {
                    int tmp = i * Shared.SoftwareInformation.rows + j;
                    Lattice latt = lattices[tmp];
                    if (latt.is_trash == 1)
                        continue;
                    list.Add(latt.lattice_num);
                }
            }
            list.Insert(0, Properties.Resources.strPleaseSelect);
            comboboxTablePos.ItemsSource = list;
            comboboxTablePos.SelectedIndex = 0;
 
            methodCoating = new MethodCoating();
            methodCoating.name = method.method_name;
            methodCoating.label = method.method_name;
            methodCoating.status = (method.isEnabled == true ? "enable" : "disable");
            methodCoating.wellarray = "";
            methodCoating.strIndex = method.strIndex;
 
            DropdownName dpdItem = (DropdownName)cbCoatingMode.SelectedItem;
            methodCoating.coatingmodeValue = dpdItem.dropdown_id;
            methodCoating.coatingmodeText = dpdItem.dropdown_name;
            //methodCoating.coatingmodeValue = cbCoatingMode.SelectedValue.ToString();
            this.DataContext = methodCoating;
 
            if (Shared.ChannelCount > 1)
            {
                tipsChannel.CanEdit = true;
            }
 
            if (method.tag != null)
            {
                methodCoating = (MethodCoating)method.tag;
 
                currmethodCoating = methodCoating;
 
                isrun = methodCoating.isrun;
                status = methodCoating.status;
                name = methodCoating.name;
                label = methodCoating.label;
                labwareText = methodCoating.labwareText;
                labwareValue = methodCoating.labwareValue;
                positionText = methodCoating.positionText;
                positionValue = methodCoating.positionValue;
                armText = methodCoating.armText;
                armValue = methodCoating.armValue;
                headType = methodCoating.headType;
                channels = methodCoating.channels;
                wellarray = methodCoating.wellarray;
                coatingmodeText = methodCoating.coatingmodeText;
                coatingmodeValue = methodCoating.coatingmodeValue;
            }
        }
 
        private void z_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (mark == 0)
                {
                }
                else
                {
                    if (cbCoatingMode.SelectedIndex < 0)
                        return;
 
                    DropdownName dpdItem = (DropdownName)cbCoatingMode.SelectedItem;
                    methodCoating.coatingmodeValue = dpdItem.dropdown_id;
                    methodCoating.coatingmodeText = dpdItem.dropdown_name;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void cbArm_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // 臂未选择
            if (cbArm.SelectedIndex < 0 || cbArm.SelectedIndex == 0)
            {
                tipsChannel.SetTotalChannelCount(0);
                tipsChannel.SelectedChannels = new List<int>();
                tipsChannel.SetSelectedChannels();
                tipsChannel_SelectedChangedEvent(null, null);
                return;
            }
 
            curArmSelectedIndex = cbArm.SelectedIndex;
            string armName = ((DeviceArm)cbArm.SelectedItem).device_arm_name.ToString();
 
            tipsChannel.SelectedChannels = Shared.ChannelsId.ToList();
            tipsChannel.SetTotalChannelCount(Shared.ChannelCount);
            tipsChannel.SetSelectedChannels();
            tipsChannel_SelectedChangedEvent(null, null);
 
            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.ToString();
        }
 
        public void SetTableName(string tableName, Labware lb)
        {
            if (lb == null)
                return;
            if (string.IsNullOrEmpty(lb.labware_id))
                return;
            if (string.IsNullOrEmpty(methodCoating.armValue))
            {
                MessageBox.Show(Properties.Resources.msgPlsSelectArm, "Tips");
                return;
            }
            selectedLabware = lb;
 
            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;
            }
            comboboxTablePos.SelectedItem = tableName;
            methodCoating.positionText = tableName;
            methodCoating.positionValue = lattice.lattice_id;
            methodCoating.labwareText = lb.labware_name;
            methodCoating.labwareValue = lb.labware_id;
 
        }
 
        private void comboboxTablePos_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (comboboxTablePos.SelectedItem == null)
                    return;
                string name = comboboxTablePos.SelectedItem as string;
                SetTableName(name, selectedLabware);
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark == 0)
                {
 
                }
                else
                {
                    methodCoating.name = tbxCommandName.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void tbxWellPositionTips_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark == 0)
                {
                }
                else
                {
                    methodCoating.wellarray = tbxWellPositionTips.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            mark += 1;
            try
            {
                if (mark > 1)
                {
                    return;
                }
 
                if (!string.IsNullOrEmpty(armText))
                {
                    tbxCommandName.Text = name;
                    cbArm.SelectedValue = armValue;
                    DeviceArm arm = cbArm.SelectedItem as DeviceArm;
                    textboxArmHead.Text = arm.head_type;
                    comboboxTablePos.SelectedItem = positionText;
                    tipsChannel.SelectedChannels = channels.ToList();
                    tipsChannel_SelectedChangedEvent(null, null);
 
                    tbxWellPositionTips.Text = wellarray;
                    wellPlate.Selection = wellarray;
                    //wellPlate.SetSelection(wellarray);
                    cbCoatingMode.SelectedValue = coatingmodeValue;
 
 
                    if (currmethodCoating != null)
                    {
                        methodCoating = currmethodCoating;
                    }
                }
                else
                {
                    cbArm.SelectedIndex = curArmSelectedIndex;
 
                    DeviceArm arm = cbArm.SelectedItem as DeviceArm;
                    textboxArmHead.Text = arm.head_type;
 
                    if (currmethodCoating != null)
                    {
                        methodCoating = currmethodCoating;
                    }
                }
 
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        #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
    }
}