UserControl1.xaml
26.6 KB
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<UserControl x:Class="SmartScan.SetControl.WPF.UserControl1"
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:SmartScan.SetControl.WPF"
mc:Ignorable="d"
d:DesignHeight="650" d:DesignWidth="600" Background="#1A1A1A"
Loaded="UserControl_Loaded">
<UserControl.Resources>
<!-- 自定义按钮样式 -->
<Style x:Key="BorderedButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#333333"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#555555"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="10,5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="3">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#444444"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#555555"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 自定义文本框样式 -->
<Style x:Key="DarkTextBoxStyle" TargetType="TextBox">
<Setter Property="Background" Value="#333333"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#555555"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="5,2"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
<!-- 自定义CheckBox样式 -->
<Style x:Key="DarkCheckBoxStyle" TargetType="CheckBox">
<Setter Property="Foreground" Value="White"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,2"/>
</Style>
<!-- 自定义NavigationButton样式 (用于数字导航按钮) -->
<Style x:Key="NavigationButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#333333"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#555555"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Width" Value="25"/>
<Setter Property="Height" Value="25"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="2">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#444444"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#555555"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 自定义关键字按钮样式 -->
<Style x:Key="KeywordButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#0078D7"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#0066CC"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="10,5"/>
<Setter Property="Margin" Value="3"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="3">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#006CCF"/>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#005BB5"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DarkComboBoxStyle" TargetType="{x:Type ComboBox}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="MinWidth" Value="120"/>
<Setter Property="MinHeight" Value="28"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#1A1A1A"/>
<Setter Property="BorderBrush" Value="#333333"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid>
<ToggleButton
x:Name="ToggleButton"
Template="{DynamicResource ComboBoxToggleButton}"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}"
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
<ContentPresenter
Name="ContentSite"
IsHitTestVisible="False"
Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Margin="8,3,32,3"
VerticalAlignment="Center"
HorizontalAlignment="Left"/>
<!-- 自定义下拉按钮为白色三角形 -->
<Path
x:Name="DropDownArrow"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Data="M0,0 L8,0 L4,4 Z"
Fill="White"
Margin="0,0,8,0"
Width="8"
Height="4"/>
<!-- 点击后的弹出内容 -->
<Popup
Name="Popup"
Placement="Bottom"
IsOpen="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
AllowsTransparency="True"
Focusable="False"
PopupAnimation="Slide">
<Grid
Name="DropDown"
SnapsToDevicePixels="True"
MinWidth="{TemplateBinding ActualWidth}"
MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border
x:Name="DropDownBorder"
Background="#1D1D1D"
BorderBrush="#444444"
BorderThickness="1"/>
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
</ScrollViewer>
</Grid>
</Popup>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#888888"/>
</Trigger>
<Trigger Property="IsDropDownOpen" Value="True">
<Setter TargetName="DropDownArrow" Property="Fill" Value="#4080FF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<!-- 自定义下拉项样式 -->
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Padding" Value="6,2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBoxItem}">
<Border
Name="Border"
Padding="{TemplateBinding Padding}"
Background="Transparent">
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="Border" Property="Background" Value="#404040"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="#888888"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
<Border x:Name="Border" Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="3"/>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="Border" Property="BorderBrush" Value="#4080FF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!-- 标题容器样式 -->
<Style x:Key="SectionTitleStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#2D2D2D"/>
<Setter Property="Padding" Value="10,5"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontFamily" Value="微软雅黑"/>
</Style>
<!-- 分隔线样式 -->
<Style x:Key="DarkSeparatorStyle" TargetType="Separator">
<Setter Property="Background" Value="#333333"/>
<Setter Property="Margin" Value="0,8"/>
<Setter Property="Height" Value="1"/>
</Style>
<!-- 面板容器样式 -->
<Style x:Key="PanelContainerStyle" TargetType="Border">
<Setter Property="BorderBrush" Value="#007acc"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="3"/>
<Setter Property="Margin" Value="0,0,0,10"/>
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="0.3*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<!-- 解析结果区域 -->
<Border Grid.Row="0" Style="{StaticResource PanelContainerStyle}" Margin="0,15,0,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 标题 -->
<TextBlock Grid.Row="0" Text="解析结果" Name="WPF_Reslues" Style="{StaticResource SectionTitleStyle}"/>
<!-- 结果显示 -->
<Border Grid.Row="1" Background="#1A1A1A" Margin="8">
<TextBlock x:Name="LblMatchRes" Foreground="White" Margin="8"
TextWrapping="Wrap" VerticalAlignment="Center"/>
</Border>
</Grid>
</Border>
<!-- 提取设置区域 -->
<Border Grid.Row="1" Style="{StaticResource PanelContainerStyle}" Margin="0,15,0,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 标题 -->
<TextBlock Grid.Row="0" Text="提取设置" Name="WPF_Set" Style="{StaticResource SectionTitleStyle}"/>
<!-- 提取设置内容 -->
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<StackPanel Margin="10">
<!-- 选择关键字 -->
<Grid Margin="0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="选择关键字:" Name="WPF_ChooseKeys" FontFamily="微软雅黑" FontSize="14" Foreground="White" VerticalAlignment="Center" Grid.Column="0"/>
<ComboBox Margin="15 0 0 0" x:Name="CboKeyword" Style="{StaticResource DarkComboBoxStyle}" Grid.Column="1"
SelectionChanged="CboKeyword_SelectionChanged"/>
</Grid>
<Separator Style="{StaticResource DarkSeparatorStyle}"/>
<!-- 条码分割字符 -->
<Grid Margin="0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="ChkSplitBarcode" FontFamily="微软雅黑" FontSize="14" Content="条码分割字符" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="0" Checked="ChkSplitBarcode_Checked" Unchecked="ChkSplitBarcode_Unchecked"/>
<ComboBox Margin="15 0 0 0" x:Name="CboSplitChar" Style="{StaticResource DarkComboBoxStyle}" Grid.Column="1"
IsEnabled="{Binding ElementName=ChkSplitBarcode, Path=IsChecked}"
SelectionChanged="CboSplitChar_SelectionChanged"/>
</Grid>
<!-- 获取分割部分 -->
<Grid Margin="0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="获取分割部分:" Name="WPF_CHkSplit" FontFamily="微软雅黑" FontSize="14" Foreground="White" VerticalAlignment="Center" Grid.Column="0"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="15 0 0 0">
<Button Content="−" Style="{StaticResource NavigationButtonStyle}" Click="DecreaseButton_Click" Tag="TxtSplitIndex"/>
<Border Background="#333333" BorderBrush="#555555" BorderThickness="1" Width="25" Height="25" Margin="5" CornerRadius="2">
<TextBlock x:Name="TxtSplitIndex" Text="1" FontFamily="微软雅黑" FontSize="14" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Button Content="+" Style="{StaticResource NavigationButtonStyle}" Click="IncreaseButton_Click" Tag="TxtSplitIndex"/>
</StackPanel>
</Grid>
<Separator Style="{StaticResource DarkSeparatorStyle}"/>
<!-- 内容截取起始位 -->
<Grid Margin="0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="截取起始位置:" Name="WPF_CHkSplitStart" FontFamily="微软雅黑" FontSize="14" Foreground="White" VerticalAlignment="Center" Grid.Column="0"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="15 0 0 0">
<Button Content="−" Style="{StaticResource NavigationButtonStyle}" Click="DecreaseButton_Click" Tag="TxtStartPosition"/>
<Border Background="#333333" BorderBrush="#555555" BorderThickness="1" Width="25" Height="25" Margin="5" CornerRadius="2">
<TextBlock x:Name="TxtStartPosition" Text="0" FontSize="14" FontFamily="微软雅黑" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Button Content="+" Style="{StaticResource NavigationButtonStyle}" Click="IncreaseButton_Click" Tag="TxtStartPosition"/>
</StackPanel>
</Grid>
<!-- 内容截取长度 -->
<Grid Margin="0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="截取长度:" Name="WPF_SplitLenght" Foreground="White" FontFamily="微软雅黑" FontSize="14" VerticalAlignment="Center" Grid.Column="0"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="15 0 0 0">
<Button Content="−" Style="{StaticResource NavigationButtonStyle}"
Click="DecreaseButton_Click" Tag="TxtSubstringLength"/>
<Border Background="#333333" BorderBrush="#555555" BorderThickness="1" Margin="5" Width="25" Height="25" CornerRadius="2">
<TextBlock x:Name="TxtSubstringLength" Text="0" Foreground="White" FontSize="14" FontFamily="微软雅黑"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Button Content="+" Style="{StaticResource NavigationButtonStyle}"
Click="IncreaseButton_Click" Tag="TxtSubstringLength"/>
</StackPanel>
</Grid>
<!-- 必须为数字 &只取数字& 截取至结尾 -->
<Grid Margin="0,8" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="ChkMustBeNumber" FontFamily="微软雅黑" FontSize="14" Content="必须为数字" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="0" Checked="ChkMustBeNumber_Checked" Unchecked="ChkMustBeNumber_Unchecked"/>
<CheckBox x:Name="OnlyTakeBeNumber" FontFamily="微软雅黑" FontSize="14" Content="只取数字" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="1" Checked="OnlyTakeBeNumber_Checked" Unchecked="OnlyTakeBeNumber_Unchecked"/>
<CheckBox x:Name="ChkExtractToEnd" FontFamily="微软雅黑" FontSize="14" Content="截取至结尾" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="2" IsChecked="True" Checked="ChkExtractToEnd_Checked" Unchecked="ChkExtractToEnd_Unchecked"/>
</Grid>
<Separator Style="{StaticResource DarkSeparatorStyle}"/>
<!-- 最小长度 -->
<Grid Margin="0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="ChkMinLength" Content="最小长度" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="0" Checked="ChkMinLength_Checked" Unchecked="ChkMinLength_Unchecked"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="15 0 0 0">
<Button Content="−" Style="{StaticResource NavigationButtonStyle}"
Click="DecreaseButton_Click" Tag="TxtMinLength"
IsEnabled="{Binding ElementName=ChkMinLength, Path=IsChecked}"/>
<Border Background="#333333" BorderBrush="#555555" BorderThickness="1" Width="35" Height="28" CornerRadius="2">
<TextBlock x:Name="TxtMinLength" Text="0" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Button Content="+" Style="{StaticResource NavigationButtonStyle}"
Click="IncreaseButton_Click" Tag="TxtMinLength"
IsEnabled="{Binding ElementName=ChkMinLength, Path=IsChecked}"/>
</StackPanel>
</Grid>
<!-- 最大长度 -->
<Grid Margin="0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox x:Name="ChkMaxLength" Content="最大长度" Style="{StaticResource DarkCheckBoxStyle}"
Grid.Column="0" Checked="ChkMaxLength_Checked" Unchecked="ChkMaxLength_Unchecked"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="15 0 0 0">
<Button Content="−" Style="{StaticResource NavigationButtonStyle}"
Click="DecreaseButton_Click" Tag="TxtMaxLength"
IsEnabled="{Binding ElementName=ChkMaxLength, Path=IsChecked}"/>
<Border Background="#333333" BorderBrush="#555555" BorderThickness="1" Width="35" Height="28" CornerRadius="2">
<TextBlock x:Name="TxtMaxLength" Text="0" Foreground="White"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Button Content="+" Style="{StaticResource NavigationButtonStyle}"
Click="IncreaseButton_Click" Tag="TxtMaxLength"
IsEnabled="{Binding ElementName=ChkMaxLength, Path=IsChecked}"/>
</StackPanel>
</Grid>
</StackPanel>
</ScrollViewer>
</Grid>
</Border>
</Grid>
</UserControl>