<UserControl x:Class="SlnMesnac.WPF.Views.ConfigPage"
             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:SlnMesnac.WPF.Views"
              xmlns:converters="clr-namespace:SlnMesnac.WPF.ConvertTo"
             mc:Ignorable="d" 
             d:DesignHeight="900" d:DesignWidth="1620">
    <UserControl.Resources>

        <converters:IsCheckedConverter x:Key="IsCheckedConverter"/>
       

        <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontSize" Value="18"/>
        </Style>
        <Style TargetType="DataGrid">
            <!--网格线颜色-->
            <Setter Property="CanUserResizeColumns" Value="false"/>
            <Setter Property="Background" Value="#1152AC" />
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="HorizontalGridLinesBrush">
                <Setter.Value>
                    <SolidColorBrush Color="#4285DE"/>
                </Setter.Value>
            </Setter>
            <Setter Property="VerticalGridLinesBrush">
                <Setter.Value>
                    <SolidColorBrush Color="#1152AC"/>
                </Setter.Value>
            </Setter>
        </Style>
        <!--列头标题栏样式-->
        <Style TargetType="DataGridColumnHeader">

            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="BorderBrush" Value="#dddddd" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="Background" Value="#4285DE"/>
            <Setter Property="Foreground" Value="White"/>
        </Style>

        <!--单元格样式-->
        <Style TargetType="DataGridCell">
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type DataGridCell}">
                        <Grid Background="{TemplateBinding Background}" >
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="#4285DE"/>
                    <Setter Property="Foreground" Value="#dddddd"/>
                </Trigger>
            </Style.Triggers>

        </Style>
    </UserControl.Resources>


    <Border Grid.Row="1" Grid.Column="1" BorderBrush="#0288d1" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="5">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="0.8*"/>
                <RowDefinition Height="9*"/>
            </Grid.RowDefinitions>

            <Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="#1157b9" Margin="1,1,5,5" >
                <TextBlock Text="校验项配置" FontSize="25" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            </Border>
            <Border Grid.Row="1" BorderBrush="Green" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
                <Grid Margin="10,5">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="8*"/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="horizontal" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center">
                        <Label Content="型号:"  FontSize="20" Foreground="White"/>
                        <TextBox Text="{Binding QueryCode,Mode=TwoWay}" Width="250" FontSize="20" Foreground="White" Margin="0 0 30 0" />
                            <Label Content="是否校验:" Width="100" FontSize="20" Foreground="White"/>
                        <ComboBox Width="70" Height="30" FontSize="20" SelectedItem="{Binding QueryIsCheck,Mode=TwoWay}" Margin="10,0,30,0" Foreground="White">
                            <ComboBoxItem Content="是" Background="White" Foreground="#4285DE"/>
                            <ComboBoxItem Content="否"  Foreground="#4285DE"/>
                            <ComboBoxItem Content=""  Foreground="#4285DE"/>
                        </ComboBox>
                        <Button
                            Content="查 询"  Command="{Binding QueryCommand}"
                            Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Background="Green" Margin="0 0 100 0"/>
                       
                        <Button
                            Content="配方管理"  Command="{Binding MangerCommand}"
                            Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Background="YellowGreen" Margin="140 0 0 0"/>
                        <Button
                            Content="同步型号"  Command="{Binding SyncCommand}"  Margin="40 0 0 0"
                            Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Background="#FF1CC57B"/>
                    </StackPanel>
                    <UniformGrid Grid.Row="1">
                        <DataGrid x:Name="listDataGrid"  Grid.Row="0" ItemsSource="{Binding LogoConfigDataGrid}" Background="#00000000" 
                       ColumnHeaderHeight="35"   Height="{Binding Path=ActualHeight, ElementName=ScanPanel}" 
                      RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"  FontSize="20"
                      GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"  LoadingRow="dgvMH_LoadingRow"
                      ScrollViewer.VerticalScrollBarVisibility="Auto"  BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True"
                      Foreground="White"  >
                            <!--修改选中字体颜色-->
                            <DataGrid.Columns>
                                <DataGridTemplateColumn  Width="55" Header="序号"  >
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" FontSize="18" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                                <DataGridTextColumn Binding="{Binding MaterialType}" Header="产品型号" Width="2*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                                <DataGridTextColumn Binding="{Binding MaterialName}" Header="产品名称" Width="1*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding IsChecked, Converter={StaticResource IsCheckedConverter}}" Header="是否校验" Width="2*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding CheckKind}" Header="检测类型" Width="*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding LightType}" Header="灯光类型" Width="*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding Ch1Hight}" Header="CH1亮度" Width="*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding Ch2Hight}" Header="CH2亮度" Width="*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTemplateColumn Header="操作" Width="1.5*">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="修改"  Command="{Binding DataContext.UpdateCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                    CommandParameter="{Binding MaterialType}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>


                    </UniformGrid>
                </Grid>
            </Border>
        </Grid>
    </Border>
</UserControl>
