MainWindow_Top.xaml 16.7 KB
<UserControl x:Class="SmartScan.SetControl.WPF.MainWindow_Top"
             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" Width="700" 
             >


    <UserControl.Resources>
        <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="20" />
                </Grid.ColumnDefinitions>
                <Border Grid.ColumnSpan="2" 
                   Background="Transparent" 
                   BorderBrush="#444444" 
                   BorderThickness="1" />
                <Border Grid.Column="1" 
                   Background="Transparent" 
                   BorderBrush="#444444" 
                   BorderThickness="0,0,0,0" />
            </Grid>
        </ControlTemplate>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="52" />
           
        </Grid.RowDefinitions>
        <!-- 自定义标题栏 -->
        <Border Grid.Row="0" 
               Background="#111111" 
               BorderBrush="#333333" 
               BorderThickness="0,0,0,1"
               MouseLeftButtonDown="TitleBar_MouseLeftButtonDown">

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Image x:Name="Logos" Source="/Resources/NEO 64.png"  Width="50" Height="50"/>

                <!-- 标题文本 -->
                <TextBlock Grid.Column="0" 
                          Text="物料注册系统" 
                          Foreground="White" 
                          VerticalAlignment="Center" 
                          HorizontalAlignment="Center"
                           Grid.ColumnSpan="3"
                           Name="mf_name"
                          Margin="15,0,0,0"
                          FontFamily="微软雅黑"
                          FontSize="25"/>
                <!-- 中间空白区域,用于拖拽窗口 -->
                <Border Grid.Column="1" Background="Transparent" />
                <!-- 语言选择下拉框 - 使用ComboBox -->
                <ComboBox Grid.Column="2" 
                         x:Name="LanguageSelector"
                         Width="100"
                         Height="24"
                         Margin="0,0,10,0"
                         VerticalAlignment="Center"
                         SelectedIndex="0"
                         Background="Transparent"
                         Foreground="White"
                         BorderBrush="#444444"
                         FontSize="12">

                    <!-- 自定义ComboBox样式 -->
                    <ComboBox.Resources>
                        <!-- 下拉菜单背景色 -->
                        <SolidColorBrush x:Key="{x:Static SystemColors.WindowBrushKey}" Color="#222222"/>
                        <!-- 选中项背景色 -->
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#444444"/>
                    </ComboBox.Resources>

                    <ComboBox.ItemContainerStyle>
                        <Style TargetType="{x:Type ComboBoxItem}">
                            <Setter Property="Background" Value="Transparent"/>
                            <Setter Property="Foreground" Value="White"/>
                            <Style.Triggers>
                                <Trigger Property="IsHighlighted" Value="True">
                                    <Setter Property="Background" Value="#444444"/>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ComboBox.ItemContainerStyle>

                    <!-- 设置下拉箭头样式 -->
                    <ComboBox.Style>
                        <Style TargetType="{x:Type ComboBox}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ComboBox}">
                                        <Grid>
                                            <ToggleButton x:Name="ToggleButton" 
                                                       ClickMode="Press" 
                                                       Focusable="false"
                                                       IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                                       Template="{StaticResource ComboBoxToggleButton}"/>

                                            <ContentPresenter x: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="Arrow"
                                               HorizontalAlignment="Right"
                                               VerticalAlignment="Center"
                                               Margin="0,0,8,0"
                                               Fill="White"
                                               Data="M 0 0 L 6 6 L 12 0 Z"/>

                                            <Popup x:Name="Popup"
                                                Placement="Bottom"
                                                IsOpen="{TemplateBinding IsDropDownOpen}"
                                                AllowsTransparency="True" 
                                                Focusable="False"
                                                PopupAnimation="Slide">
                                                <Grid x:Name="DropDown"
                                                   SnapsToDevicePixels="True"                
                                                   MinWidth="{TemplateBinding ActualWidth}"
                                                   MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                                    <Border x:Name="DropDownBorder"
                                                        Background="#222222"
                                                        BorderThickness="1"
                                                        BorderBrush="#444444"/>
                                                    <ScrollViewer SnapsToDevicePixels="True">
                                                        <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained"/>
                                                    </ScrollViewer>
                                                </Grid>
                                            </Popup>
                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </ComboBox.Style>

                    <!-- 下拉框的选项 -->
                    <ComboBoxItem>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="简体中文" FontFamily="微软雅黑" VerticalAlignment="Center"/>
                        </StackPanel>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="English"  FontFamily="微软雅黑" VerticalAlignment="Center"/>
                        </StackPanel>
                    </ComboBoxItem>
                    <ComboBoxItem>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="日语"  FontFamily="微软雅黑" VerticalAlignment="Center"/>
                    </StackPanel>
                    </ComboBoxItem>
                </ComboBox>
                <!-- 窗口控制按钮 -->
                <StackPanel Grid.Column="3" 
                           Orientation="Horizontal" 
                           HorizontalAlignment="Right">

                    <!-- 最小化按钮 -->
                    <Button x:Name="MinimizeButton" 
                           Width="45" 
                           Height="32" 
                           Background="Transparent" 
                           BorderThickness="0"
                           Click="MinimizeButton_Click">
                        <Button.Content>
                            <Path Data="M0,0 L10,0" 
                                 Stroke="White" 
                                 StrokeThickness="1" 
                                 Width="10" 
                                 Height="1"/>
                        </Button.Content>
                        <Button.Style>
                            <Style TargetType="Button">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Border Background="{TemplateBinding Background}" 
                                                   BorderBrush="{TemplateBinding BorderBrush}" 
                                                   BorderThickness="{TemplateBinding BorderThickness}">
                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                            </Border>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Background" Value="#333333"/>
                                                </Trigger>
                                                <Trigger Property="IsPressed" Value="True">
                                                    <Setter Property="Background" Value="#444444"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Button.Style>
                    </Button>

                    <!-- 最大化/还原按钮 -->
                    <Button x:Name="MaximizeButton" 
                           Width="45" 
                           Height="32" 
                           Background="Transparent" 
                           BorderThickness="0"
                           Click="MaximizeButton_Click">
                        <Button.Content>
                            <Grid>
                                <Path x:Name="MaximizePath" 
                                     Data="M0,0 L10,0 L10,10 L0,10 Z" 
                                     Stroke="White" 
                                     StrokeThickness="1" 
                                     Width="10" 
                                     Height="10" 
                                     Visibility="Visible"/>

                                <Path x:Name="RestorePath" 
                                     Data="M2,2 L10,2 L10,10 L2,10 Z M0,0 L8,0 L8,8 L0,8 Z" 
                                     Stroke="White" 
                                     StrokeThickness="1" 
                                     Width="10" 
                                     Height="10" 
                                     Visibility="Collapsed"/>
                            </Grid>
                        </Button.Content>
                        <Button.Style>
                            <Style TargetType="Button">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Border Background="{TemplateBinding Background}" 
                                                   BorderBrush="{TemplateBinding BorderBrush}" 
                                                   BorderThickness="{TemplateBinding BorderThickness}">
                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                            </Border>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Background" Value="#333333"/>
                                                </Trigger>
                                                <Trigger Property="IsPressed" Value="True">
                                                    <Setter Property="Background" Value="#444444"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Button.Style>
                    </Button>

                    <!-- 关闭按钮 -->
                    <Button x:Name="CloseButton" 
                           Width="45" 
                           Height="32" 
                           Background="Transparent" 
                           BorderThickness="0"
                           Click="CloseButton_Click">
                        <Button.Content>
                            <Path Data="M0,0 L10,10 M10,0 L0,10" 
                                 Stroke="White" 
                                 StrokeThickness="1" 
                                 Width="10" 
                                 Height="10"/>
                        </Button.Content>
                        <Button.Style>
                            <Style TargetType="Button">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="Button">
                                            <Border Background="{TemplateBinding Background}" 
                                                   BorderBrush="{TemplateBinding BorderBrush}" 
                                                   BorderThickness="{TemplateBinding BorderThickness}">
                                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                            </Border>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Background" Value="#E81123"/>
                                                </Trigger>
                                                <Trigger Property="IsPressed" Value="True">
                                                    <Setter Property="Background" Value="#8C0A15"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </Button.Style>
                    </Button>
                </StackPanel>
            </Grid>
        </Border>
        <!-- 主内容区域 -->
       
    </Grid>
</UserControl>