C3032
2025-12-20 15492363f898704b51afce5f1c88fa3b754cbabc
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
<Window x:Class="SmartScanner.DownloadData"
      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:SmartScanner" 
      xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
      xmlns:Properties="clr-namespace:SmartScanner.Properties"
      mc:Ignorable="d" 
      Width="490" Height="320"
      Title="图像设置">
 
    <Grid Background="#3C3C3C">
        <Grid.Resources>
            <Style x:Key="TextBoxStyle" TargetType="TextBox">
                <Style.Setters>
                    <Setter Property="VerticalContentAlignment" Value="Center"/>
                    <Setter Property="HorizontalContentAlignment" Value="Right"/>
                    <Setter Property="Background" Value="#6C6C6C"/>
                    <Setter Property="BorderBrush" Value="#1F0000"/>
                    <Setter Property="Foreground" Value="White"/>
                    <Setter Property="BorderThickness" Value="1"/>
                </Style.Setters>
            </Style>
            <Style TargetType="RadioButton" x:Key="RadioButtonStyle">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="RadioButton">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CheckStates">
                                        <VisualState x:Name="Checked">
                                            <Storyboard>
                                                <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="contentPresenter">
                                                    <EasingColorKeyFrame KeyTime="0" Value="White"/>
                                                </ColorAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Unchecked"/>
                                        <VisualState x:Name="Indeterminate"/>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Ellipse Width="{Binding ActualHeight, ElementName=contentPresenter}" Height="{Binding ActualHeight, ElementName=contentPresenter}" Fill="{TemplateBinding Background}"/>
                                <ContentPresenter x:Name="contentPresenter" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="BtnLabelStyle">
                <Style.Triggers>
                    <Trigger Property="Button.IsFocused" Value="False">
                        <Setter Property="Button.Background" Value="Transparent"/>
                        <Setter Property="Button.BorderThickness" Value="0"/>
                    </Trigger>
                    <Trigger Property="Button.IsFocused" Value="True">
                        <Setter Property="Button.Background" Value="#4D0000"/>
                        <Setter Property="Button.BorderThickness" Value="0"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="LabelStyle">
                <Style.Triggers>
                    <Trigger Property="Label.IsFocused" Value="False">
                        <Setter Property="Label.Background" Value="Transparent"/>
                        <Setter Property="Label.Foreground" Value="White"/>
                    </Trigger>
                    <Trigger Property="Label.IsFocused" Value="True">
                        <Setter Property="Label.Background" Value="#FFBEE6FD"/>
                        <Setter Property="Label.Foreground" Value="#4F4F4F"/>
                    </Trigger>
                    <Trigger Property="Label.IsMouseOver" Value="True">
                        <Setter Property="Label.Background" Value="#FFBEE6FD"/>
                        <Setter Property="Label.Foreground" Value="#4F4F4F"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="FocusVisual">
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <!--按钮静态时背景颜色-->
            <SolidColorBrush x:Key="Button.Static.Background" Color="#4F4F4F"/>
            <!--按钮静态时边框颜色-->
            <SolidColorBrush x:Key="Button.Static.Border" Color="#2F0000"/>
            <!--按钮静态时文字颜色-->
            <SolidColorBrush x:Key="Button.Static.Foreground" Color="White"/>
            <!--鼠标移入时背景颜色-->
            <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#4D0000"/>
            <!--鼠标移入时边框颜色-->
            <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#2F0000"/>
            <!--鼠标按下时背景颜色-->
            <SolidColorBrush x:Key="Button.Pressed.Background" Color="#4D0000"/>
            <!--鼠标按下时边框颜色-->
            <SolidColorBrush x:Key="Button.Pressed.Border" Color="#2F0000"/>
            <!--按钮不使用时背景颜色-->
            <SolidColorBrush x:Key="Button.Disabled.Background" Color="Gray"/>
            <!--按钮不使用时边框颜色-->
            <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
            <!--按钮不使用时文字颜色-->
            <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="White"/>
            <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
                <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
                <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
                <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
                <Setter Property="Foreground" Value="{StaticResource Button.Static.Foreground}"/>
                <Setter Property="BorderThickness" Value="1"/>
                <!--边框宽度,设置为0 即:无边框-->
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Padding" Value="1"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Button}">
                            <Border x:Name="border" CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true">
                                <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Border>
                            <!--触发器:根据依赖属性的值去控制控件的状态-->
                            <ControlTemplate.Triggers>
                                <!--默认属性-->
                                <Trigger Property="IsDefaulted" Value="true">
                                    <!--<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>-->
                                    <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Static.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Static.Border}"/>
                                    <Setter Property="TextElement.Foreground" TargetName="border" Value="{StaticResource Button.Static.Foreground}"/>
                                </Trigger>
                                <!--鼠标移入属性-->
                                <Trigger Property="IsMouseOver" Value="true">
                                    <Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
                                </Trigger>
                                <!--鼠标按下属性-->
                                <Trigger Property="IsPressed" Value="true">
                                    <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
                                </Trigger>
                                <!--按钮可用状态属性-->
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
                                    <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
                                    <!--<Setter Property="Foreground" TargetName="border" Value="{StaticResource Button.Disabled.Foreground}"/>-->
                                    <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="{StaticResource Button.Disabled.Foreground}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="70"/>
            <RowDefinition Height="160"/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
            <Label Content="路径选择:" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Height="35"/>
            <StackPanel Orientation="Horizontal" Height="35">
                <TextBox Name="SetDataSavingRoad" Text="{Binding Source={x:Static Properties:Settings.Default}, Path=DataSavingRoad, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"
                         HorizontalContentAlignment="Left"  Height="30" FontSize="14" ToolTip="文件存储路径" Width="400" Margin="10,0,0,0" MouseDoubleClick="SetDataSavingRoad_MouseDoubleClick"/>
                <Button Name="SelectFilePath" Content="浏览…" Width="50" Height="30" Click="SelectFilePath_Click" Style="{DynamicResource ButtonStyle}"/>
            </StackPanel>
        </StackPanel>
        <StackPanel Grid.Row="1">
            <StackPanel Orientation="Horizontal" Height="35">
                <Label Content="保存设置:" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Width="100"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Height="35">
                <CheckBox Name="ImageDeleteCheck" Content="定期清图" IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=ImageDeleteEnabled, Mode=TwoWay}" Unchecked="ImageDeleteCheck_Unchecked"  Checked="ImageDeleteCheck_Checked" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Width="130" Margin="20,0,0,0"/>
                <toolkit:IntegerUpDown x:Name="Data_deleteImage" FormatString="N" Increment="1" Maximum="200000"
                                       Value="{Binding Source={x:Static Properties:Settings.Default}, Path=DeleteImageDays, Mode=TwoWay}"
                                        LostFocus="Data_deleteImage_LostFocus"  Width="100" Height="25"/>
                <Label Content="天" Foreground="White" VerticalAlignment="Center"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Height="35">
                <StackPanel Orientation="Horizontal" Width="300">
                <CheckBox Name="ImageSaveCheck" Content="启用图像保存" IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=ImageSaveEnabled, Mode=TwoWay}" 
                          Unchecked="ImageSaveCheck_Unchecked" Checked="ImageSaveCheck_Checked" 
                          HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Width="130" Margin="20,0,0,0"/>
                <Label Content="保存格式" Foreground="White" VerticalAlignment="Center"/>
                    <ComboBox Name="ImageFormat" SelectedIndex="{Binding Source={x:Static Properties:Settings.Default}, Path=ImageFormatSelect, Mode=TwoWay}" 
                              Height="25" SelectionChanged="ImageFormat_SelectionChanged" LostFocus="ImageFormat_LostFocus">
                    <ComboBoxItem Content=".BMP"/>
                    <ComboBoxItem Content=".JPG"/>
                    <ComboBoxItem Content=".PNG"/>
                </ComboBox>
                </StackPanel>
                <StackPanel x:Name="CompressionVisible" Orientation="Horizontal" Visibility="Visible">
                <Label Content="压缩比率" Foreground="White" VerticalAlignment="Center"/>
                    <toolkit:IntegerUpDown x:Name="ImageCompressionRatio" FormatString="N" Increment="1" Maximum="10" Minimum="0" UpdateValueOnEnterKey="True"
                                       Value="{Binding Source={x:Static Properties:Settings.Default}, Path=CompressionRatio, Mode=TwoWay}"
                                       Watermark="取值[0-10]" Width="85" Height="25" LostFocus="ImageCompressionRatio_LostFocus"/>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Height="35">
                <CheckBox Name="MemoryAlarmCheck" Content="存储空间预警" IsChecked="{Binding Source={x:Static Properties:Settings.Default}, Path=MemoryAlarmEnabled, Mode=TwoWay}"
                          Unchecked="MemoryAlarmCheck_Unchecked"  Checked="MemoryAlarmCheck_Checked"  HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Foreground="White" Width="130" Margin="20,0,0,0"/>
                <toolkit:IntegerUpDown x:Name="MemoryAlarm" FormatString="N" Maximum="90" Minimum="10" UpdateValueOnEnterKey="True"
                                       Value="{Binding Source={x:Static Properties:Settings.Default}, Path=MemoryAlarmSetting, Mode=TwoWay}"
                                       Width="100" Height="25" LostFocus="MemoryAlarm_LostFocus"/>
                <Label Content="%" Foreground="White" VerticalAlignment="Center"/>
            </StackPanel>
        </StackPanel>
        <StackPanel Grid.Row="2">
            <Button Content="确定" Width="300" Height="30" Name="Confirm_Btn" Click="Confirm_Btn_Click"  Margin="5" Style="{DynamicResource ButtonStyle}"/>
        </StackPanel>
    </Grid>
</Window>