<UserControl x:Class="SlnMesnac.WPF.Views.IndexPage"
             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" Background="#1152AC"   FontFamily="Microsoft YaHei"
             d:DesignHeight="1080" d:DesignWidth="1920">

    <UserControl.Resources>
        <converters:IsCheckedConverter x:Key="IsCheckedConverter"/>
        <converters:IsSuccessConverter x:Key="IsSuccessConverter"/>

        <converters:ByteArrayToImageConverter x:Key="ByteArrayToImageConverter"/>
        <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Center" />
        </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="Gray" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="18"/>
            <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="White"/>
                </Trigger>
            </Style.Triggers>

        </Style>
    </UserControl.Resources>

    <Grid Margin="1 5 1 0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <!--扫描信息-->
        <Border Grid.Row="0" Grid.Column="0" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="Transparent" Margin="3,1,5,5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="9*"/>
                </Grid.RowDefinitions>

                <Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="#1157b9" Margin="1,1,3,5" >
                    <TextBlock Text="扫描信息" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold"/>
                </Border>
                <!--扫描信息-->
                <Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,3,5">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="6*"/>
                            <ColumnDefinition Width="0.5*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="0"  BorderThickness="0" Background="Transparent" CornerRadius="5" >
                            
                        </Border>

                        <Border Grid.Column="1"  BorderThickness="0" Background="Transparent" CornerRadius="5" Margin="0,10,0,0">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.5*"/>
                                    <RowDefinition Height="0.7*"/>
                                    <RowDefinition Height="0.5*"/>
                                    <RowDefinition Height="1.2*"/>
                                </Grid.RowDefinitions>
                                <Border Grid.Row="0"  BorderThickness="0.5" BorderBrush="#0288d1" CornerRadius="5" >
                                    <Grid Grid.Row="0" Grid.Column="0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                             
                                            <ColumnDefinition Width="*" />
                                            
                                            <ColumnDefinition Width="*" />
                                            
                                        </Grid.ColumnDefinitions>

                                         
                                        <!--<StackPanel Grid.Column="0" VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Left">
                                            <TextBlock VerticalAlignment="Center" Text="扫码数:" FontSize="30" Foreground="LawnGreen" />
                                            <TextBox VerticalAlignment="Center" Text="{Binding ScanCount,Mode=TwoWay}" FontSize="30" BorderBrush="Transparent" Background="Transparent" Foreground="LawnGreen" IsReadOnly="True" Margin="0 0 0 0" />
                                        </StackPanel>

                                        
                                        <StackPanel Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal"   HorizontalAlignment="Center">
                                            <TextBlock VerticalAlignment="Center" Text="识别数:" FontSize="30" Foreground="LawnGreen" />
                                            <TextBox VerticalAlignment="Center" Text="{Binding PassCount,Mode=TwoWay}" FontSize="30" BorderBrush="Transparent" Background="Transparent" Foreground="LawnGreen" IsReadOnly="True" Margin="0 0 0 0" />
                                        </StackPanel>

                                         
                                        <StackPanel Grid.Column="2" VerticalAlignment="Center"  Orientation="Horizontal"  HorizontalAlignment="Right">
                                            <TextBlock VerticalAlignment="Center" Text="通过率:" FontSize="30" Foreground="LawnGreen" />
                                            <TextBox VerticalAlignment="Center" Text="{Binding PassRate,Mode=TwoWay}" FontSize="30" BorderBrush="Transparent" Background="Transparent" Foreground="LawnGreen" IsReadOnly="True" Margin="0 0 0 0" />
                                        </StackPanel>-->
                                    </Grid>
                                </Border>
                                <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" >
                                    <TextBlock Text="产品条码" FontSize="22" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 0 30 0"/>
                                    <TextBox FontSize="20" Text="{Binding BoxCode,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="250" IsReadOnly="True" Margin="0 0 10 0"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
                                    <TextBox FontSize="20" Text="{Binding BoxTime,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="200" IsReadOnly="True" Margin="10 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
                                </StackPanel>
                                <StackPanel Grid.Row="2" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center"  >
                                    <TextBlock Text="产品型号" FontSize="22" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 0 30 0"/>
                                    <TextBox FontSize="18" Text="{Binding ProductModel,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="250" IsReadOnly="True" Margin="0 0 0 0"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
                                    <Button Content="人工确认" Command="{Binding ConfirmCommand}"
                            Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Background="#FF1CC57B" Width="130" Height="50"  Margin="50 0 0 0"/>

                                    <Button Content="放行" Command="{Binding PassCommand}"
                            Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Background="LimeGreen" Width="130" Height="50"  Margin="50 0 0 0"/>
                                    
                                </StackPanel>


                                <StackPanel Grid.Row="3" Grid.RowSpan="2" Margin="0 40 0 0" >
                                    <TextBlock Text="提示信息:" FontSize="22" Foreground="White"/>
                                    <TextBox FontSize="18"  BorderBrush="White" BorderThickness="1" 
                                       MinHeight="70"   IsReadOnly="True" Foreground="{Binding MsgColor}" Margin="0 5 0 0" 
                                        AcceptsReturn="True" Text="{Binding Message,Mode=TwoWay}"                   
                                        Style="{StaticResource MaterialDesignOutlinedTextBox}"
                                        TextWrapping="Wrap"
                                        VerticalScrollBarVisibility="Auto" Height="70"  />
                                </StackPanel>
                            </Grid>
                        </Border>
                    </Grid>
                </Border>
            </Grid>
        </Border>

        <!--日志信息-->
        <Border Grid.Row="0" Grid.Column="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="#1157b9" Margin="3,1,3,5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="9*"/>

                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="Transparent" Margin="1,1,1,5" >
                    <Grid>
                        <TextBlock Text="视觉识别信息" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 80 0">
                            <TextBlock Text="识别结果" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" />
                            <!--<TextBlock Text="{Binding ResultTxt,Mode=TwoWay}" FontSize="20" FontWeight="Bold" Foreground="{Binding ResultColor}" VerticalAlignment="Center" Margin="0 0 40 0" />-->
                        </StackPanel>

                    </Grid>
                </Border>

                <Border  Grid.Row="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="10" Background="Transparent" Margin="5,1,5,5">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="3*"/>
                            <ColumnDefinition Width="*"/>
                          </Grid.ColumnDefinitions>
                        <StackPanel Grid.Column="0">
                            <Image Source="{Binding ImageData, Converter={StaticResource ByteArrayToImageConverter}}" Height="{Binding ElementName=HeightHelperPanel, Path=ActualHeight}" Width="{Binding ElementName=HeightHelperPanel, Path=ActualWidth}"/>
                        </StackPanel >
                        <Grid Grid.Column="1" >
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <TextBlock Visibility="{Binding OKIsVis}" Grid.Row="0" Text="OK" FontSize="100" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="LightGreen"></TextBlock>
                            <TextBlock Visibility="{Binding NOIsVis}" Grid.Row="0" Text="NO" FontSize="100" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="LightGreen"></TextBlock>
                            <TextBlock Visibility="{Binding NGIsVis}" Grid.Row="1" Text="NG" FontSize="100" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="OrangeRed"></TextBlock>
                        </Grid >
                    </Grid>
                </Border>
            </Grid>
        </Border>

        <!--扫描记录-->
        <Border Grid.Row="1" Grid.ColumnSpan="2"  BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="#1157b9" Margin="3,1,3,5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="1*"/>
                    <RowDefinition Height="9*"/>

                </Grid.RowDefinitions>
                <Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="Transparent" Margin="1,1,5,5" >
                    <TextBlock Text="扫描记录" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"  />
                </Border>

                <!--计划列表-->
                <Border x:Name="ScanPanel" Grid.Row="1" Grid.Column="0" BorderBrush="#0288d1" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="1,1,5,5">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <DataGrid Grid.Row="0" ItemsSource="{Binding LogoIdentifyDataGrid}" 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 ProductCode}" Header="产品条码" Width="2*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                                <DataGridTextColumn Binding="{Binding MaterialType}" Header="产品型号" Width="2*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding MaterialName}" Header="产品名称" Width="2*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding isChecked, Converter={StaticResource IsCheckedConverter}}" Header="是否检测" Width="*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding Result, Converter={StaticResource IsSuccessConverter}}" Header="检测结果" Width="*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                                <DataGridTextColumn Binding="{Binding RecordTime,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="扫描时间" Width="1.5*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>

                            </DataGrid.Columns>
                        </DataGrid>
                    </Grid>
                </Border>
            </Grid>
        </Border>

    </Grid>
</UserControl>
