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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ctrls="clr-namespace:XHandler.Controls"
                    xmlns:cls ="clr-namespace:XHandler.Class.DataEx"
                    >
 
    <ItemsPanelTemplate x:Key="NormalItemsPanel" >
        <WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
                   ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}"
                   ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" 
                   IsItemsHost="True"
                   HorizontalAlignment="Center"/>
    </ItemsPanelTemplate>
 
    <!--#region 耗材style-->
    <Style x:Key="ConsumableListViewItemStyle" TargetType="{x:Type ListViewItem}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListViewItem">
                    <Grid>
                        <Border x:Name="bg" Background="Transparent" CornerRadius="5" BorderThickness="0" Margin="5"/>
                        <ContentPresenter Margin="7"
                                 Content="{TemplateBinding ContentControl.Content}" 
                                 ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" 
                                 ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}" 
                                 HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}" 
                                 VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}" 
                                 SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" 
                                />
                        <!--<Border x:Name="bg" Background="Transparent" CornerRadius="5" BorderThickness="0" Margin="5"/>-->
                    </Grid>
 
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" TargetName="bg" Value="{DynamicResource listSelectedBrush}"/>
                            </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground">
                                <Setter.Value>
                                    <DynamicResource ResourceKey="{x:Static SystemColors.GrayTextBrushKey}" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="true" />
                                <Condition Property="IsSelected" Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="Background" TargetName="bg" Value="{DynamicResource lightBlueBrush}"/>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <!--<EventSetter Event="PreviewMouseMove" Handler="ListViewItem_PreviewMouseMove"/>-->
    </Style>
 
    <DataTemplate x:Key="ConsumableListViewItemDataTemplate">
        <Border Width="110" Height="100" >
            <Grid Margin="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="30"/>
                </Grid.RowDefinitions>
                <!--<Image Grid.Row="0" Name="idImage" Source="{Binding method_ico, Converter={StaticResource cmdIconConvert}}" Stretch="Uniform" Height="32"/>-->
                <ctrls:ControlLabware Grid.Row="0" LabwareWidth="90" LabwareHeight="50" LabwareRealLength="{Binding labware_length}" LabwareRealWidth="{Binding labware_width}"
                                      LeftSideColor="{Binding labware_color_lside,Converter={StaticResource colorConvert}}" 
                                      FrontColor="{Binding labware_color_front,Converter={StaticResource colorConvert}}" 
                                      TopColor="{Binding labware_color_top,Converter={StaticResource colorConvert}}" 
                                      BorderColor="{Binding labware_color_line,Converter={StaticResource colorConvert}}" 
                                      labwareWellInfoList="{Binding labwareWellInfoList}"
                                      
                                      Rows="{Binding number_row}" Columns="{Binding number_column}" WellColor="White" IsFill="true"
                                      LabwareType="{Binding labware_type_id}" LabwareName="{Binding labware_name}" />
                <Image Grid.Row="0" Name="idImage" Source="pack://application:,,,./Assets/Consumables/default.png" HorizontalAlignment="Left"
                       VerticalAlignment="Top" Width="32" Visibility="{Binding is_default_type, Converter={StaticResource intToVisibleConvert}}"/>
 
                <TextBlock Grid.Row="1" x:Name="idText" Text="{Binding labware_name}" FontSize="14" Foreground="Black" TextTrimming="WordEllipsis"
                               VerticalAlignment="Center" Tag="{Binding labware_id}" HorizontalAlignment="Center" ToolTip="{Binding labware_name}"/>
            </Grid>
        </Border>
    </DataTemplate>
 
    <DataTemplate x:Key="ShelfListViewItemDataTemplate">
        <Border Width="110" Height="100" >
            <Grid Margin="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="30"/>
                </Grid.RowDefinitions>
                <ctrls:ShelfLabware Grid.Row="0" ShelfLength="{Binding labware_length}" ShelfWidth="{Binding labware_width}" ShelfTrash="False"/>
                <Image Grid.Row="0" Name="idImage" Source="pack://application:,,,./Assets/Consumables/default.png" HorizontalAlignment="Left"
                       VerticalAlignment="Top" Width="32" Visibility="{Binding is_default_type, Converter={StaticResource intToVisibleConvert}}"/>
 
                <TextBlock Grid.Row="1" x:Name="idText" Text="{Binding labware_name}" FontSize="14" Foreground="Black" TextTrimming="WordEllipsis"
                               VerticalAlignment="Center" Tag="{Binding labware_id}" HorizontalAlignment="Center" ToolTip="{Binding labware_name}"/>
            </Grid>
        </Border>
    </DataTemplate>
    <!--#endregion-->
 
    <!--#region 运行TreeView Style-->
    <Style x:Key="RunTreeViewItemStyle" TargetType="{x:Type TreeViewItem}">
        <Setter Property="IsSelected" Value="{Binding isSelected, Mode=TwoWay}"/>
        <Setter Property="IsExpanded" Value="True"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding 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="Focusable" Value="False"/>  注释掉可操作-->
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TreeViewItem}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition MinWidth="1" Width="auto"/>
                            <ColumnDefinition Width="auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <ToggleButton x:Name="Expander" ClickMode="Press" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Visibility="Collapsed"/>
                        <Rectangle x:Name="Hd" Grid.Column="1" Fill="{DynamicResource blueBrush}" Opacity="0" Width="5"/>
                        <Border x:Name="Bd" Grid.Column="2" BorderThickness="0 0 0 2"  Background="{Binding IsError, Converter={StaticResource methodBackgroundConvert}}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                            <Border.BorderBrush>
                                <VisualBrush>
                                    <VisualBrush.Visual>
                                        <Rectangle StrokeDashArray="4 4" Stroke="LightGray" StrokeThickness="1"
                                                Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
                                                Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"/>
                                    </VisualBrush.Visual>
                                </VisualBrush>
                            </Border.BorderBrush>
 
                            <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                        <ItemsPresenter x:Name="ItemsHost" Grid.Row="1" Grid.Column="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="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
 
                        <DataTrigger Binding="{Binding isRun}" Value="true">
                            <Setter Property="Background" TargetName="Bd" Value="{Binding IsError, Converter={StaticResource methodRanBackgroundConvert}}"/>
                        </DataTrigger>
 
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Opacity" TargetName="Hd" Value="1"/>
                            <Setter Property="Background" TargetName="Bd" Value="{Binding IsError, Converter={StaticResource methodSelectedBackgroundConvert}}"/>
                        </Trigger>
 
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="VirtualizingPanel.IsVirtualizing" Value="true">
                <Setter Property="ItemsPanel">
                    <Setter.Value>
                        <ItemsPanelTemplate>
                            <VirtualizingStackPanel/>
                        </ItemsPanelTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>
 
    <HierarchicalDataTemplate x:Key="RunTreeviewTemplate" DataType="{x:Type cls:MethodExEx}" ItemsSource="{Binding Children}">
        <Border Width="auto" Height="56" Margin="{Binding Level, Converter={StaticResource leverToThicknessConvert}}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="50"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" FontSize="14" Text="{Binding strIndex}" VerticalAlignment="Center" HorizontalAlignment="Left" FontWeight="Bold"
                               Foreground="{Binding isEnabled, Converter={StaticResource enableToBrush}}" Margin="10 0"/>
                <Image Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Left" Stretch="Uniform" Height="32">
                    <Image.Source>
                        <MultiBinding Converter="{StaticResource workflowIconMultiConvert}">
                            <Binding Path="method_ico"/>
                            <Binding Path="isEnabled"/>
                            <Binding Path="method_group_id"/>
                        </MultiBinding>
                    </Image.Source>
                </Image>
 
                <TextBlock Grid.Column="2" FontSize="16" Text="{Binding method_name}" VerticalAlignment="Center" 
                               Foreground="{Binding isEnabled, Converter={StaticResource enableToBrush}}"/>
                <TextBlock Grid.Column="3" FontSize="14" Margin="20,0,0,0" HorizontalAlignment="Left" Text="{Binding method_Tipcontent}" VerticalAlignment="Center" 
                               Foreground="{Binding isEnabled, Converter={StaticResource enableToBrush}}" TextWrapping="WrapWithOverflow"/>
            </Grid>
        </Border>
    </HierarchicalDataTemplate>
    <!--#endregion-->
</ResourceDictionary>