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
using DataEntity.Share;
using DataRWDAL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
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 XHandler.Class;
using XHandler.Class.DataEx;
using XHandler.Controls;
using XImagingXhandler.XDAL;
 
namespace XHandler.View.Consumables
{
    /// <summary>
    /// TipBoxSetting.xaml 的交互逻辑
    /// </summary>
    public partial class TipBoxSetting : UserControl
    {
        public Labware labware { get; set; }
        public TipBoxSetting()
        {
            InitializeComponent();
        }
 
        public TipBoxSetting(Labware l)
        {
            InitializeComponent();
            labware = l;
            DataContext = labware;
        }
 
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            checkboxWN.IsChecked = true;
 
            if (labware == null)
                return;
                
            btnLeftSideColor.RGB = labware.labware_color_lside;     // 左侧
            btnWideColor.RGB = labware.labware_color_front;         // 前侧
            btnTopColor.RGB = labware.labware_color_top;            // 顶面
            btnLineColor.RGB = labware.labware_color_line;          // 边框线
 
            int count = (int)labware.number_row * (int)labware.number_column;
            textboxWellCount.Text = count.ToString();
        }
 
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            CheckBox btn = (CheckBox)sender;
            int nGap = 0;
            if (checkboxWN.IsChecked == true)
            {
                nGap = nGap | GapLabware.WN;
            }
            if (checkboxWS.IsChecked == true)
            {
                nGap = nGap | GapLabware.WS;
            }
            if (checkboxEN.IsChecked == true)
            {
                nGap = nGap | GapLabware.EN;
            }
            if (checkboxES.IsChecked == true)
            {
                nGap = nGap | GapLabware.ES;
            }
            AddGapLabware(nGap);
        }
 
        private void AddGapLabware(int gap)
        {
            gridGapLabware.Children.Clear();
            GapLabware labware = new GapLabware()
            {
                Width = 200,
                GapWidth = 15,
                LabwareGap = gap,
                HorizontalAlignment = HorizontalAlignment.Left,
            };
            gridGapLabware.Children.Add(labware);
        }
 
        #region 宽边颜色
        private void btnWideColor_SelectedColorChangedEvent(object sender, EventArgs e)
        {
            if (labware == null)
            {
                return;
            }
 
            labware.labware_color_front = btnWideColor.RGB;
        }
        #endregion
 
        #region 窄边颜色
        private void btnLeftSideColor_SelectedColorChangedEvent(object sender, EventArgs e)
        {
            if (labware == null)
            {
                return;
            }
 
            labware.labware_color_lside = btnLeftSideColor.RGB;
        }
        #endregion
 
        #region 顶部颜色
        private void btnTopColor_SelectedColorChangedEvent(object sender, EventArgs e)
        {
            if (labware == null)
            {
                return;
            }
 
            labware.labware_color_top = btnTopColor.RGB;
        }
        #endregion
 
        #region 边线颜色
        private void btnLineColor_SelectedColorChangedEvent(object sender, EventArgs e)
        {
            if (labware == null)
            {
                return;
            }
 
            labware.labware_color_line = btnLineColor.RGB;
        }
        #endregion
 
        private void textboxRows_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (string.IsNullOrEmpty(textboxRows.Text.Trim()) || string.IsNullOrEmpty(textboxColumns.Text.Trim()))
                return;
            int rows = 0;
            int.TryParse(textboxRows.Text.Trim(), out rows);
            int cols = 0;
            int.TryParse(textboxColumns.Text.Trim(), out cols);
            textboxWellCount.Text = (rows * cols).ToString();
        }
 
        private void textboxColumns_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (string.IsNullOrEmpty(textboxRows.Text.Trim()) || string.IsNullOrEmpty(textboxColumns.Text.Trim()))
                return;
 
            int rows = 0;
            int.TryParse(textboxRows.Text.Trim(), out rows);
            int cols = 0;
            int.TryParse(textboxColumns.Text.Trim(), out cols);
            textboxWellCount.Text = (rows * cols).ToString();
        }
 
        private void textboxRows_LostFocus(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(textboxRows.Text.Trim()) || string.IsNullOrEmpty(textboxColumns.Text.Trim()))
                return;
            int rows = 0;
            int.TryParse(textboxRows.Text.Trim(), out rows);
            int cols = 0;
            int.TryParse(textboxColumns.Text.Trim(), out cols);
            textboxWellCount.Text = (rows * cols).ToString();
        }
 
        private void textboxColumns_LostFocus(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(textboxRows.Text.Trim()) || string.IsNullOrEmpty(textboxColumns.Text.Trim()))
                return;
 
            int rows = 0;
            int.TryParse(textboxRows.Text.Trim(), out rows);
            int cols = 0;
            int.TryParse(textboxColumns.Text.Trim(), out cols);
            textboxWellCount.Text = (rows * cols).ToString();
        }
 
        private void PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            if (!Utilities.isNumberic(e.Text))
            {
                e.Handled = true;
            }
            else
                e.Handled = false;
        }
 
        private void btnTipLoadType_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string strlabwares = labware.tip_loaded_type;
                ObservableCollection<Labware> labwares = new ObservableCollection<Labware>();
                if (!string.IsNullOrEmpty(strlabwares))
                {
                    string[] array = strlabwares.Split(',');
                    if (array != null)
                    {
                        for (int i = 0; i < array.Length; i++)
                        {
                            Labware labware = new Labware();
                            labware = LabwareDB.GetLabware(array[i]);
                            labwares.Add(labware);
                        }
                    }
                }
 
                TipLoadedTypeSet tipLoadedTypeSet = new TipLoadedTypeSet(labwares, labware);
                tipLoadedTypeSet.Height = this.ActualHeight;
                tipLoadedTypeSet.Width = this.ActualWidth;
 
                SolidColorBrush mybtn1_Brush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
                tipLoadedTypeSet.Background = (System.Windows.Media.Brush)mybtn1_Brush;
                tipLoadedTypeSet.ShowDialog();
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
            }
        }
    }
}