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
<UserControl x:Class="XHandler.View.LiquidManagement"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:XHandler.View"
             xmlns:localL="clr-namespace:XHandler.View.Liquids"
             xmlns:str="clr-namespace:XHandler.Properties"
             xmlns:liq="clr-namespace:XHandler.View.Liquids"
             xmlns:data="clr-namespace:XHandler.Class.DataEx"
             xmlns:dt ="clr-namespace:XImagingXhandler.XDAL;assembly=DataEntity"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"
             Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <PathGeometry x:Key="TreeArrow" Figures="M0,0 L0,6 L6,0 z"/>
        <Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="Width" Value="16"/>
            <Setter Property="Height" Value="16"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToggleButton}">
                        <Border Background="Transparent" Height="16" Padding="5,5,5,5" Width="16">
                            <Path x:Name="ExpandPath" Data="{StaticResource TreeArrow}" Fill="Transparent" Stroke="#FF989898">
                                <Path.RenderTransform>
                                    <RotateTransform Angle="135" CenterY="3" CenterX="3"/>
                                </Path.RenderTransform>
                            </Path>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Stroke" TargetName="ExpandPath" Value="#FF1BBBFA"/>
                                <Setter Property="Fill" TargetName="ExpandPath" Value="Transparent"/>
                            </Trigger>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="RenderTransform" TargetName="ExpandPath">
                                    <Setter.Value>
                                        <RotateTransform Angle="180" CenterY="3" CenterX="3"/>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="Fill" TargetName="ExpandPath" Value="#FF595959"/>
                                <Setter Property="Stroke" TargetName="ExpandPath" Value="#FF262626"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
 
        <Style x:Key="TreeViewItemFocusVisual" TargetType="{x:Type TreeViewItem}">
 
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
 
            <!--<Setter Property="TextBlock.FontWeight" Value="Bold"></Setter>
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="-2" StrokeThickness="1" Stroke="Red" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>-->
        </Style>
 
        <Style x:Key="treeViewItemStyle" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
            <Setter Property="Padding" Value="1,0,0,0"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="IsExpanded" Value="{Binding IsExpanded}"/>
            <Setter Property="IsSelected" Value="{Binding IsSelected}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="16" Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Border x:Name="BdBack" Margin="1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" CornerRadius="3" Background="Transparent"></Border>
                            <ToggleButton x:Name="Expander" Grid.Row="0" Grid.Column="0" Style="{StaticResource ExpandCollapseToggleStyle}" ClickMode="Press" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Border x:Name="Bd" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" CornerRadius="3" SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                                <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" x:Name="PART_Header" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header"/>
                            </Border>
                            <ItemsPresenter x:Name="ItemsHost" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="false">
                                <Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
                            </Trigger>
                            <Trigger Property="HasItems" Value="false">
                                <Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
                            </Trigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource listSelectedBrush}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}}"/>
                            </Trigger>
                            <!--<MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="IsSelectionActive" Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource lightBlueBrush}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightTextBrushKey}}"/>
                            </MultiTrigger>-->
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsMouseOver" Value="true" SourceName="Bd"/>
                                    <Condition Property="IsSelected" Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource lightBlueBrush}"/>
                                <!--<Setter Property="BorderBrush" TargetName="BdBack" Value="{DynamicResource lightBlueBrush}" />-->
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <EventSetter Event="PreviewMouseRightButtonDown"  Handler="TreeViewItem_PreviewMouseRightButtonDown"/>
        </Style>
 
        <HierarchicalDataTemplate x:Key="treeviewTemplate" DataType="{x:Type data:LiquidItemExEx}" ItemsSource="{Binding Children}">
            <!--<Border Width="auto" Height="56" Margin="{Binding Level, Converter={StaticResource leverToThicknessConvert}}">-->
                <Grid>
                    <!--<Grid.ColumnDefinitions>
                        <ColumnDefinition Width="42"/>
                        <ColumnDefinition Width="50"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>-->
                    <TextBlock Grid.Column="0" Foreground="Black" FontSize="16" Text="{Binding Name}" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,0,0" />
                <Image Name="idImage" Source="pack://application:,,,./Assets/Consumables/default.png" HorizontalAlignment="Left"
                       VerticalAlignment="Top" Height="20" Visibility="{Binding nDefault, Converter={StaticResource intToVisibleConvert}}"/>
            </Grid>
            <!--</Border>-->
        </HierarchicalDataTemplate>
 
        <HierarchicalDataTemplate DataType="{x:Type data:LiquidRangeExEx}" ItemsSource="{Binding Path=Chirldren}">
            <TextBlock Text="{Binding liquid_range_name}" FontSize="16"/>
        </HierarchicalDataTemplate>
 
        <HierarchicalDataTemplate x:Key="headType" DataType="{x:Type data:HeadTypeExEx}" ItemsSource="{Binding Children}">
            <TextBlock Text="{Binding name}" FontSize="16"/>
        </HierarchicalDataTemplate>
 
        <!--<HierarchicalDataTemplate DataType="{x:Type dt:Liquid}" ItemsSource="{Binding Children}">
            <TextBlock Text="{Binding name}" FontSize="16"/>
        </HierarchicalDataTemplate>-->
        <DataTemplate DataType="{x:Type dt:Liquid}">
            <TextBlock Text="{Binding liquid_name}" FontSize="16"/>
            
        </DataTemplate>
 
        <!--#region menu-->
        <ContextMenu x:Key="liquidMenu" Width="200">
            <MenuItem Name="menuCopy" Header="{x:Static str:Resources.strCopy}" Click="menuCopy_Click"/>
            <MenuItem Name="menuPaste" Header="{x:Static str:Resources.strPaste}" Click="menuPaste_Click" IsEnabled="False"/>
            <!--<MenuItem Name="menuEdit" Header="{x:Static str:Resources.strEdit}" Click="menuEdit_Click"/>-->
            <MenuItem Name="menuDelete" Header="{x:Static str:Resources.strDelete}" Click="menuDelete_Click"/>
        </ContextMenu>
 
        <!--#endregion-->
    </UserControl.Resources>
    
    <Grid>
        <Border Background="White" CornerRadius="0,10,10,0" Margin="0,0,10,0" >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2.5*"/>
                    <ColumnDefinition Width="7.5*"/>
                </Grid.ColumnDefinitions>
                
                <Border Grid.Row="0" Background="{DynamicResource lightGrayBrush}" CornerRadius="5" BorderThickness="0" Margin="10">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0" Text="{x:Static str:Resources.strAllCategory}" FontSize="16" FontWeight="Bold"
                           Margin="10 0 0 0" VerticalAlignment="Center"/>
 
                        <TreeView x:Name="treeviewLiquid" Grid.Row="1" Margin="10 0 10 10"
                                  Background="White"
                                  ItemContainerStyle="{DynamicResource treeViewItemStyle}"
                                  ItemTemplate="{DynamicResource treeviewTemplate}"
                                  BorderThickness="0" ScrollViewer.VerticalScrollBarVisibility="Auto"
                                  SelectedItemChanged="treeviewLiquid_SelectedItemChanged"
                                  ContextMenu="{DynamicResource liquidMenu}"/>
 
                    </Grid>
                </Border>
                
                <Grid Grid.Column="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="60"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    
                    <Grid x:Name="gdBaseLiquid" Grid.Row="0" Height="200" IsEnabled="{Binding is_default_type, Converter={StaticResource intToEnableConvert}}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="40"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
 
                        <!--名称-->
                        <TextBlock Grid.Row="0" Grid.Column="0" Text="{x:Static str:Resources.strName}" VerticalAlignment="Bottom" Margin="20 0 0 0" FontSize="16"/>
                        <TextBox x:Name="tbliquid_name" Grid.Row="1" Grid.Column="0" Height="30" FontSize="16" VerticalContentAlignment="Center"
                                 VerticalAlignment="Top" Background="{DynamicResource lightGrayBrush}" Margin="20 0" BorderThickness="0" >
                            <TextBox.Text>
                                <Binding Path="liquid_name" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" NotifyOnValidationError="True" >
                                    <Binding.ValidationRules>
                                        <localL:LiquidsValidationRule  ValidateType="1,6@[200]"/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>
                        </TextBox>
                        <TextBlock Grid.Row="0" Grid.Column="0" x:Name="bdvError" Text="{Binding  ElementName=tbliquid_name,Path=(Validation.Errors)[0].ErrorContent}" 
                                   Foreground="Red" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5 5 5 0"/>
 
                        <!--液体类型-->
                        <TextBlock Grid.Row="0" Grid.Column="1" Text="{x:Static str:Resources.strLiquidType}" VerticalAlignment="Bottom" Margin="20 0 0 0" FontSize="16"/>
                        <ComboBox x:Name="cbLiquidType" Grid.Row="1" Grid.Column="1" Height="30" Width="200" BorderThickness="0" Background="{DynamicResource lightGrayBrush}" HorizontalAlignment="Left"
                                      DisplayMemberPath="liquid_type_name" SelectedValuePath="liquid_type_id" SelectionChanged="cbLiquidType_SelectionChanged" Margin="20 0 0 0" IsEnabled="False" IsEditable="False"/>
 
                        <!--枪头类型-->
                        <TextBlock Grid.Row="0" Grid.Column="2" Text="{x:Static str:Resources.strTipsType1}" VerticalAlignment="Bottom" Margin="20 0 0 0" FontSize="16"/>
                        <ComboBox x:Name="cbLiquidRange" Grid.Row="1" Grid.Column="2" Height="30" Width="200" BorderThickness="0" Background="{DynamicResource lightGrayBrush}" HorizontalAlignment="Left"
                                      DisplayMemberPath="liquid_range_name" SelectedValuePath="liquid_range_id" SelectionChanged="cbLiquidRange_SelectionChanged" Margin="20 0 0 0" IsEnabled="False"/>
 
                        <!--移液量程-->
                        <TextBlock Grid.Row="0" Grid.Column="3" Text="{x:Static str:Resources.strLiquidRange}" VerticalAlignment="Bottom" Margin="20 0 0 0" FontSize="16"/>
                        <ComboBox x:Name="cbLiquidArm" Grid.Row="1" Grid.Column="3" Height="30" Width="200" BorderThickness="0" Background="{DynamicResource lightGrayBrush}" HorizontalAlignment="Left"
                                      DisplayMemberPath="head_type" SelectedValuePath="device_arm_id" SelectionChanged="cbLiquidArm_SelectionChanged" Margin="20 0 0 0" IsEnabled="False"/>
 
                        <!--描述-->
                        <TextBlock Grid.Row="2" Grid.Column="0" Text="{x:Static str:Resources.strDescription}" VerticalAlignment="Bottom" Margin="20 0 0 0" FontSize="16"/>
                        <TextBox x:Name="tbcontent" Grid.Row="3" Grid.Column="0"  Grid.ColumnSpan="3" FontSize="16" VerticalContentAlignment="Top" Margin="20 8" Background="{DynamicResource lightGrayBrush}" 
                                     TextWrapping="Wrap" BorderThickness="0" >
                            <TextBox.Text>
                                <Binding Path="content" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" NotifyOnValidationError="True" >
                                    <Binding.ValidationRules>
                                        <localL:LiquidsValidationRule  ValidateType="1,6@[200]"/>
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>
                        </TextBox>
                        <TextBlock Grid.Row="2" Grid.Column="0" x:Name="bError" Text="{Binding  ElementName=tbcontent,Path=(Validation.Errors)[0].ErrorContent}"
                                   Foreground="Red" FontSize="16" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="5 5 5 0"/>
                    </Grid>
 
                    <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
                        <!--吸液参数-->
                        <RadioButton x:Name="rbAspirateParam" Width="120" Height="40" Style="{DynamicResource TxTRadioButtonSytle}" Content="{x:Static str:Resources.strAspirateParam}"
                                     FontSize="20" FontWeight="Black" Background="White" Margin="0 0 40 0" HorizontalAlignment="Center"
                                     VerticalContentAlignment="Center" Checked="rbAspirateParam_Checked"/>
                        <!--加液参数-->
                        <RadioButton x:Name="rbDispenseParam" Width="120" Height="40" Style="{DynamicResource TxTRadioButtonSytle}" Content="{x:Static str:Resources.strDispenseParam}"
                                     FontSize="20" FontWeight="Black" Background="White" Margin="0 0 20 0" HorizontalAlignment="Center"
                                     VerticalContentAlignment="Center" Checked="rbDispenseParam_Checked"/>
                        <!--校准-->
                        <RadioButton x:Name="rbCelibrate" Width="120" Height="40" Style="{DynamicResource TxTRadioButtonSytle}" Content="{x:Static str:Resources.strCalibrate}"
                                     FontSize="20" FontWeight="Black" Background="White" Margin="0 0 20 0" HorizontalAlignment="Center"
                                     VerticalContentAlignment="Center" Checked="rbCelibrate_Checked"/>
                    </StackPanel>
 
                    <ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                        <Grid x:Name="gridParam" IsEnabled="{Binding is_default_type, Converter={StaticResource intToEnableConvert}}">
                            <!--<liq:AspirateParam/>-->
                            <!--<liq:DispenseParam/>-->
                            <!--<liq:CalibrationParam/>-->
                        </Grid>
                    </ScrollViewer>
                </Grid>
            </Grid>
 
        </Border>
    </Grid>
</UserControl>