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
using DataRWDAL;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 XHandler.Class.DataEx;
using XImagingXhandler.XDAL;
using static XHandler.Controls.MultiComboBox;
using XCore;
using System.Runtime.Remoting.Channels;
using XHandler.Controls;
using XHandler.View.MethodProperty;
using XCommon.Log;
using DataEntity.Share;
 
namespace XHandler.View.MethodProperty.ElectroPart
{
    /// <summary>
    /// CaptureElectroProperty.xaml 的交互逻辑
    /// </summary>
    public partial class CaptureElectroProperty : UserControl, IMethodProperty
    {
        ObservableCollection<MultiCbxBaseData> bacteriaList = new ObservableCollection<MultiCbxBaseData>();
        BacteriaBll bacteriaBll = new BacteriaBll();
        int mark = 0;
 
        #region 全局变量
        string isrun = "";
        string status = "";
        string name = "";
        string label = "";
        int choicemode = 0;
        string gumLabwareText = "";        // 放胶耗材名称文本
        string gumLabwareValue = "";       // 放胶耗材名称Id
        private int coatingLabwareGotFocus = 0;
        #endregion
 
        public MethodTakePhotoForElectro methodTakePhotoForElectro { get; set; }
        public MethodTakePhotoForElectro currmethodTakePhotoForElectro = null;
 
        public CaptureElectroProperty()
        {
            InitializeComponent();
        }
 
        public CaptureElectroProperty(MethodEx method)
        {
            mark = 0;
            InitializeComponent();
            methodTakePhotoForElectro = new MethodTakePhotoForElectro();
            methodTakePhotoForElectro.name = method.method_name;
            methodTakePhotoForElectro.label = method.method_name;
            methodTakePhotoForElectro.status = (method.isEnabled == true ? "enable" : "disable");
            methodTakePhotoForElectro.strIndex = method.strIndex;
            this.DataContext = methodTakePhotoForElectro;
 
            if (methodTakePhotoForElectro.identification == 1)
                radioBtnManual.IsChecked = true;
            else
                radioBtnAuto.IsChecked = true;
 
            methodTakePhotoForElectro.identification = 0;
 
            if (method.tag != null)
            {
                methodTakePhotoForElectro = (MethodTakePhotoForElectro)method.tag;
                currmethodTakePhotoForElectro = methodTakePhotoForElectro;
 
                isrun = methodTakePhotoForElectro.isrun;
                status = methodTakePhotoForElectro.status;
                name = methodTakePhotoForElectro.name;
                label = methodTakePhotoForElectro.label;
                choicemode = methodTakePhotoForElectro.identification;
                gumLabwareText = methodTakePhotoForElectro.gumLabwareText;
                gumLabwareValue = methodTakePhotoForElectro.gumLabwareValue;
            }
 
            radioBtnManual.IsChecked = true;
        }
 
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            mark += 1;
            try
            {
                if (mark > 2)
                {
                    return;
                }
                if (!string.IsNullOrEmpty(label))
                {
                    tbxCommandLabel.Text = label;
                    tbxCommandName.Text = name;
 
                    gridManual.Visibility = Visibility.Visible;
 
                    // 加载涂布耗材数据
                    string[] coatingLabwareValues = gumLabwareValue.Split(',');
                    string[] coatingLabwareTexts = gumLabwareText.Split(',');
                    for (int iCoatingLabwareValueIndex = 0; iCoatingLabwareValueIndex < coatingLabwareValues.Length; iCoatingLabwareValueIndex++)
                    {
                        PromptTextBox textBox = placeGumLabwareA;
                        textBox.Tag = coatingLabwareValues[iCoatingLabwareValueIndex];
                        textBox.Text = coatingLabwareTexts[iCoatingLabwareValueIndex];
                    }
 
                    if (choicemode == 1)
                    {
                        radioBtnManual.IsChecked = true;
                    }
                    else if (choicemode == 0)
                    {
                        radioBtnAuto.IsChecked = true;
                    }
                }
                else
                {
                    //gridManual.Visibility = Visibility.Hidden;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void radioBtnManual_Checked(object sender, RoutedEventArgs e)
        {
            if (methodTakePhotoForElectro == null)
                return;
            methodTakePhotoForElectro.identification = 1;
        }
 
        private void radioBtnAuto_Checked(object sender, RoutedEventArgs e)
        {
            if (methodTakePhotoForElectro == null)
                return;
            methodTakePhotoForElectro.identification = 0;
        }
 
        private void placeGumLabwareA_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                methodTakePhotoForElectro.gumLabwareText = placeGumLabwareA.Text;
                methodTakePhotoForElectro.gumLabwareValue = placeGumLabwareA.Tag.ToString();
            }
            catch(Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        private void placeGumLabwareA_GotFocus(object sender, RoutedEventArgs e)
        {
            coatingLabwareGotFocus = 0;
        }
 
        private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                if (mark == 1)
                {
                    //methodTakePhotoForElectro.name = tbxCommandName.Text;
                }
                else
                {
                    methodTakePhotoForElectro.name = tbxCommandName.Text;
                }
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
 
        public void SetTableName(string tableName, Labware lb)
        {
            if (lb == null)
                return;
            if (gridManual.Visibility == Visibility.Visible)
            {
                if (methodTakePhotoForElectro != null)
                {
                    placeGumLabwareA.Tag = lb.labware_id;
                    placeGumLabwareA.Text = lb.labware_name;
                }
            }
        }
    }
}