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
using HxEnum;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using XHandler.Class;
using XHandler.Class.DataEx;
using XHandler.Controls;
using XImagingXhandler.XDAL;
 
namespace XHandler.View.Consumables
{
    /// <summary>
    /// LidSetting.xaml 的交互逻辑
    /// </summary>
    public partial class LidSetting : UserControl
    {
        public Labware labware { get; set; }
        public ConsumableManagement consumableManagement;
        public LidSetting()
        {
            InitializeComponent();
        }
 
        public LidSetting(Labware l)
        {
            InitializeComponent();
            if (l.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.Rounddishlid).ToString())       // 圆形皿盖子
            {
                gdMainLidSetting.RowDefinitions[0].Height = new GridLength(0, GridUnitType.Pixel);
                gdLidColor.RowDefinitions[1].Height = new GridLength(0, GridUnitType.Pixel);
                gdLidColor.RowDefinitions[2].Height = new GridLength(0, GridUnitType.Pixel);
                tbxBorderLine.Visibility = Visibility.Hidden;
                btnLineColor.Visibility = Visibility.Hidden;
                gridGapLabware.Visibility = Visibility.Hidden;
            }
            else
            {
                gdMainLidSetting.RowDefinitions[0].Height = new GridLength(40, GridUnitType.Pixel);
                gdLidColor.RowDefinitions[1].Height = new GridLength(40, GridUnitType.Pixel);
                gdLidColor.RowDefinitions[2].Height = new GridLength(40, GridUnitType.Pixel);
                tbxBorderLine.Visibility = Visibility.Visible;
                btnLineColor.Visibility = Visibility.Visible;
                gridGapLabware.Visibility = Visibility.Visible;
            }
            labware = l;
            this.DataContext = labware;
 
            btnTopColor.RGB = labware.labware_color_top;
        }
 
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (labware == null)
                return;
            checkboxWN.IsChecked = true;
 
            btnLeftSideColor.RGB = labware.labware_color_lside;     // 左侧
            btnWideColor.RGB = labware.labware_color_front;         // 前侧
            btnTopColor.RGB = labware.labware_color_top;            // 顶面
            btnLineColor.RGB = labware.labware_color_line;          // 边框线
        }
 
        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;
            if (consumableManagement != null)
            {
                consumableManagement.lvConsumable.SelectedItem = labware;
            }
        }
        #endregion
 
        #region 窄边颜色
        private void btnLeftSideColor_SelectedColorChangedEvent(object sender, EventArgs e)
        {
            if (labware == null)
            {
                return;
            }
 
            labware.labware_color_lside = btnLeftSideColor.RGB;
            if (consumableManagement != null)
            {
                consumableManagement.lvConsumable.SelectedItem = labware;
            }
        }
        #endregion
 
        #region 顶部颜色
        private void btnTopColor_SelectedColorChangedEvent(object sender, EventArgs e)
        {
            if (labware == null)
            {
                return;
            }
 
            labware.labware_color_top = btnTopColor.RGB;
            if (consumableManagement != null)
            {
                consumableManagement.lvConsumable.SelectedItem = labware;
            }
        }
        #endregion
 
        #region 边线颜色
        private void btnLineColor_SelectedColorChangedEvent(object sender, EventArgs e)
        {
            if (labware == null)
            {
                return;
            }
 
            labware.labware_color_line = btnLineColor.RGB;
        }
        #endregion
    }
}