<UserControl x:Class="SlnMesnac.WPF.Page.IndexPage.MaterialBind"
             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.Page.IndexPage" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                xmlns:converters="clr-namespace:SlnMesnac.WPF.Converter.Generate"
             mc:Ignorable="d" 
             d:DesignHeight="1080" d:DesignWidth="1920" Background="#FF031B3D">

    <UserControl.Resources>
        <converters:ConfigToDynamicGridViewConverter  x:Key="ConfigToDynamicGridViewConverter"/>
        <DataTemplate x:Key="LogMsgTemplate">
            <TextBlock Text="{Binding}" FontSize="20"  Foreground="White" TextWrapping="Wrap" MaxWidth="800"/>
        </DataTemplate>
        <DataTemplate x:Key="FlightTemplate">
            <StackPanel Margin="10,0,0,0">
                <Button Content="{Binding StationName}" Foreground="Black"/>
            </StackPanel>
        
        </DataTemplate>
    </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  BorderThickness="0" Background="Transparent" CornerRadius="5" Margin="10,10,0,0" Grid.ColumnSpan="2">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="0.5*"/>
                                    <RowDefinition Height="0.7*"/>
                            
                                    <RowDefinition Height="1.7*"/>
                                </Grid.RowDefinitions>
                                <StackPanel Grid.Row="0" 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 KTBoxCode,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="250" IsReadOnly="True" Margin="0 0 10 0"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
                                    <TextBox FontSize="20" Text="{Binding KTBoxTime,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="200" IsReadOnly="True" Margin="10 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
                                    <TextBlock Visibility="{Binding OKIsVis}" Grid.Row="0" Text="OK" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10 0 0 0" FontWeight="Bold" Foreground="LightGreen"></TextBlock>
                                    <TextBox FontSize="20" Text="{Binding OKCount,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="60" IsReadOnly="True" Margin="10 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
                                    <Button Content="清 空" Command="{Binding ResetCommand}" Background="#FF1CC57B" Width="50" Margin="5 0 0 0"/>
                                </StackPanel>
                                <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Center" >
                                    <TextBlock x:Name="tb_MaterialCode" Text="组件条码" FontSize="22" Foreground="White" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0 0 30 0"/>
                                    <TextBox FontSize="20" Text="{Binding ZJBoxCode,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="250" IsReadOnly="True" Margin="0 0 10 0"  HorizontalContentAlignment="Center" VerticalContentAlignment="Center" />
                                    <TextBox FontSize="20" Text="{Binding ZJBoxTime,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="200" IsReadOnly="True" Margin="10 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
                                    <TextBlock Visibility="{Binding NGIsVis}" Grid.Row="1" Text="NG" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10 0 0 0" FontWeight="Bold" Foreground="OrangeRed"></TextBlock>
                                    <TextBox FontSize="20" Text="{Binding NGCount,Mode=TwoWay}" BorderBrush="White"  Foreground="White" Width="60" IsReadOnly="True" Margin="10 0 0 0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>

                                </StackPanel>

                                <Border Grid.Row="2" BorderBrush="#1254AB" BorderThickness="2" Margin="0,10,0,0">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="2*"/>
                                            <RowDefinition Height="9*"/>
                                        </Grid.RowDefinitions>
                                        <TextBlock Grid.Row="0" Text="日志信息" FontSize="18" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                          
                                        <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                                            <ItemsControl ItemsSource="{Binding LogMessages}" ItemTemplate="{StaticResource LogMsgTemplate}" />
                                        </ScrollViewer>
                                    </Grid>
                                </Border>

                                <!--<StackPanel Grid.Row="2" Grid.RowSpan="2" Margin="0 40 0 0" >
                                    
                                    <TextBlock Text="提示信息:" FontSize="22" Foreground="White"/>
                                    <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                                        <ItemsControl ItemsSource="{Binding LogMessages}" ItemTemplate="{StaticResource LogMsgTemplate}" />
                                    </ScrollViewer>
                                    --><!--<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}"                   
                                        
                                        TextWrapping="Wrap"
                                        VerticalScrollBarVisibility="Auto" Height="70"  />--><!--
                                </StackPanel>-->
                            </Grid>
                        </Border>
                    </Grid>
                </Border>
            </Grid>
        </Border>
        <Border Grid.Row="1" Grid.ColumnSpan="2"  BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="#FF031B3D" 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>
                        <ListView Background="#FF031B3D" Foreground="White" FontSize="18"  Height="{Binding Path=ActualHeight, ElementName=ScanPanel}"  ItemsSource="{Binding TaskInfoDataGrid}" View="{Binding ColumnConfig,Converter={StaticResource ConfigToDynamicGridViewConverter}}">
         </ListView>
                        <!--<Grid.RowDefinitions>
                            <RowDefinition Height="auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <DataGrid x:Name="dg_TaskInfo" Grid.Row="0" ItemsSource="{Binding TaskInfoDataGrid}" Background="#00000000" 
                       ColumnHeaderHeight="35"   Height="{Binding Path=ActualHeight, ElementName=ScanPanel}" 
                      RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"  FontSize="18"
                      GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"  LoadingRow="dgv_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 TaskNo}" Header="任务编号" Width="2*" />
                                <DataGridTextColumn Binding="{Binding KBarCode}" Header="壳体条码" Width="2*"  />
                                <DataGridTextColumn Binding="{Binding QBarCode}" Header="前盖条码" Width="2*"  />
                                <DataGridTextColumn Binding="{Binding Station1}" Header="前盖轴封" Width="*"  />
                                <DataGridTextColumn Binding="{Binding Station2}" Header="曲轴压入转子" Width="*"  />
                                <DataGridTextColumn Binding="{Binding Station3}" Header="曲轴压入前盖" Width="*"  />
                                <DataGridTextColumn Binding="{Binding Station4}" Header="电机壳压轴承" Width="*"  />
                                <DataGridTextColumn Binding="{Binding Station5}" Header="前盖轴封检漏" Width="*"  />
                                <DataGridTextColumn Binding="{Binding Station6}" Header="转子充磁" Width="*"  />
                                <DataGridTextColumn Binding="{Binding RecordTime,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="扫描时间" Width="1.7*" />

                            </DataGrid.Columns>
                        </DataGrid>-->
                    </Grid>
                </Border>
            </Grid>
        </Border>
        <!--日志信息-->
        <Border Grid.Row="0" Grid.Column="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="5" Background="#FF031B3D" 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" />

                    </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*"/>
                        </Grid.ColumnDefinitions>
                        <StackPanel x:Name="stackpanel1">

                        </StackPanel>
                        <!--<ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
                            <ItemsControl ItemsSource="{Binding StationQualityInfos}"  ItemTemplate="{StaticResource FlightTemplate}"/>
                        </ScrollViewer>-->

                    </Grid>
                </Border>
            </Grid>
        </Border>


    </Grid>
</UserControl>
