WPF_Rule.xaml 16.9 KB
<Window x:Class="SmartScan.SetControl.WPF.WPF_Rule"
        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" 
        Background="#222222"
          WindowStyle="None"
           WindowStartupLocation="CenterScreen"
        Title="唯一码生成器"
        Loaded="Window_Loaded"
        Height="300" Width="400">
    <Window.Resources>
        <Style x:Key="TextBoxStyle" TargetType="TextBox">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Padding" Value="10,8"/>
            <Setter Property="Background" Value="#333333"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Margin" Value="0,6,0,5"/>
            <Setter Property="FontFamily" Value="微软雅黑"/>

        </Style>
        <Style x:Key="ButtonStyle" TargetType="Button">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Padding" Value="15,10"/>
            <Setter Property="Margin" Value="5"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border Background="{TemplateBinding Background}" 
                            CornerRadius="5" 
                            Padding="{TemplateBinding Padding}">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="SecondaryButtonStyle" TargetType="Button" BasedOn="{StaticResource ButtonStyle}">
            <Setter Property="Background" Value="#444444"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontFamily" Value="微软雅黑"/>
            <Setter Property="FontSize" Value="14"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#555555"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="#666666"/>
                </Trigger>
            </Style.Triggers>
        </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="25"/>
            <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>
        <Style x:Key="WindowControlButtonStyle" TargetType="Button">
            <Setter Property="Width" Value="46"/>
            <Setter Property="Height" Value="30"/>
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#444444"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="#333333"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="CloseButtonStyle" TargetType="Button" BasedOn="{StaticResource WindowControlButtonStyle}">
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#E81123"/>
                    <Setter Property="Foreground" Value="White"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        <!-- 定义ComboBox的ToggleButton模板 -->
        <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="ToggleButton">
            <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"/>
            <ControlTemplate.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter TargetName="Border" Property="BorderBrush" Value="#4080FF"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
      
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <!-- 标题栏 -->
        <Grid Grid.Row="0" Background="#1A1A1A">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <!-- 应用图标 -->
            <Image Grid.Column="0" Source="/Resources/App.png"   Width="126"  Margin="10,0,0,0" 
             VerticalAlignment="Center" HorizontalAlignment="Left" Name="logos"/>



            <!-- 窗口控制按钮 -->
            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Content="&#xE921;" Style="{StaticResource WindowControlButtonStyle}" FontFamily="Segoe MDL2 Assets"
                  Click="MinimizeButton_Click"/>
                <Button Content="&#xE922;" Style="{StaticResource WindowControlButtonStyle}" FontFamily="Segoe MDL2 Assets"
                  Click="MaximizeRestoreButton_Click"/>
                <Button Content="&#xE8BB;" Style="{StaticResource CloseButtonStyle}" FontFamily="Segoe MDL2 Assets"
                  Click="CloseButton_Click"/>
            </StackPanel>
        </Grid>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBox x:Name="keyname"    Style="{StaticResource TextBoxStyle}" ></TextBox>
            <Button Content="生成字符" Grid.Column="1" Style="{StaticResource SecondaryButtonStyle}" Name="Generate_keywords" Click="Generate_keywords_Click" />
        </Grid>
        <Grid Grid.Row="2" Visibility="Collapsed">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                <TextBlock Text="数字位数" Name="LblPlaces" Foreground="#9caaaa" FontFamily="微软雅黑" VerticalAlignment="Center" Margin="20 10 0 8"  FontSize="14" HorizontalAlignment="Center"></TextBlock>
                <Button Margin="10 0 0 0" Name="UsrMacro_btn_1" Click="UsrMacro_btn_1_Click" Content="&lt;" FontSize="14" Width="25" Height="25" Background="#333333" Foreground="White" 
           BorderThickness="1" BorderBrush="#444444" />
                <TextBox Text="0" Name="NumReelIDPlaces" Width="25" Height="25" FontSize="14"  FontFamily="微软雅黑" VerticalContentAlignment="Center" TextAlignment="Center" Margin="2,0" 
            Background="#333333" Foreground="White" BorderThickness="1" BorderBrush="#444444"/>
                <Button Content="&gt;" Name="UsrMacro_btn_2" Click="UsrMacro_btn_2_Click" Width="25" Height="25" FontSize="14" Background="#333333" Foreground="White" 
           BorderThickness="1" BorderBrush="#444444"/>
            </StackPanel>
            <Grid Grid.Column="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <CheckBox  Width="30" x:Name="ChkReelIDFillZero"  Height="30"  Margin="20" VerticalAlignment="Center" HorizontalAlignment="Left" >
                    <CheckBox.Template>
                        <ControlTemplate TargetType="CheckBox">
                            <Grid>
                                <!-- 自定义布局 -->
                                <BulletDecorator>
                                    <!-- 调整复选框图形大小 -->
                                    <BulletDecorator.Bullet>
                                        <Grid Width="30" Height="30">
                                            <!-- 未选中状态 -->
                                            <Rectangle Stroke="Gray" Fill="#252525" x:Name="BackgroundRect" 
     Width="30" Height="30" 
     RadiusX="3" RadiusY="3"/>
                                            <!-- 选中状态(勾号) -->
                                            <Path x:Name="CheckMark" 
Data="M6,14 L12,20 L22,6" 
Stroke="#ffffff" 
StrokeThickness="3"
Visibility="Collapsed"/>
                                        </Grid>
                                    </BulletDecorator.Bullet>
                                    <!-- 文本内容 -->
                                    <ContentPresenter Margin="10,0,0,0"
    VerticalAlignment="Center"/>
                                </BulletDecorator>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsChecked" Value="True">
                                    <Setter TargetName="CheckMark" Property="Visibility" Value="Visible"/>
                                    <Setter TargetName="BackgroundRect" Property="Fill"  Value="#4e77fe"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </CheckBox.Template>
                </CheckBox>
                <TextBlock VerticalAlignment="Center" Grid.Column="1" x:Name="NS_KW_WEISHU"  Margin="0 20" Text="位数不足前面补0" Foreground="#9caaaa" FontFamily="微软雅黑" FontSize="15"></TextBlock>
            </Grid>
         
        </Grid>
        <Grid Grid.Row="3" Visibility="Collapsed">
            <ComboBox HorizontalAlignment="Left" Name="CmbResetidBy" Style="{StaticResource DarkComboBoxStyle}" Margin="10" Height="30"  VerticalContentAlignment="Center"      Background="#333333" FontFamily="微软雅黑"  FontSize="14" Foreground="White" BorderThickness="1" BorderBrush="#444444" SelectedIndex="0">
                <ComboBoxItem Name="Dialog_ResetidByNone" Content="序号不重置" IsSelected="True" />
                <ComboBoxItem Name="Dialog_ResetidByDay" Content="序号每日重置"/>
                <ComboBoxItem Name="Dialog_ResetidByMonth" Content="序号每月重置"/>
            </ComboBox>
        </Grid>
        <Grid Grid.Row="4" Visibility="Collapsed">
            <Button Content="保存" Name="FrmSet_BtnOK"  Style="{StaticResource SecondaryButtonStyle}"  Click="Button_Click"></Button>
        </Grid>



    </Grid>
</Window>