﻿<hb:SimpleMaskControl x:Class="Plugin.QualityReport.QualityReport"
             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:Plugin.QualityReport"
             mc:Ignorable="d" 
             xmlns:hb="clr-namespace:HMI.Base;assembly=HMI.Base"
             xmlns:pu="https://opensource.panuon.com/wpf-ui"
             xmlns:dp="clr-namespace:HMI.UI.DpUtil;assembly=HMI.UI"
                      x:Name="control"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>

       

        <Style x:Key="ReportDataGridRow" TargetType="DataGridRow">
            <Setter Property="Background" Value="White"/>
            <Style.Triggers>
                <Trigger Property="AlternationIndex" Value="1">
                    <Setter Property="Background" Value="#eeeeee"/>
                </Trigger>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="{DynamicResource SecondPrimaryColor}"/>
                    <Setter Property="Foreground" Value="{DynamicResource SecondPrimaryColorContract}"/>
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="ReportDataGrid" TargetType="DataGrid">
            <Setter Property="FontSize" Value="16"/>
            <Setter Property="AlternationCount" Value="2"/>
            <Setter Property="AutoGenerateColumns" Value="False"/>
            <Setter Property="RowHeight" Value="30"/>
            <Setter Property="IsReadOnly" Value="True"/>
            <Setter Property="RowStyle" Value="{StaticResource ReportDataGridRow}"/>
        </Style>

        <Style TargetType="ListBox" x:Key="ListBoxItemStyle1">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Padding" Value="-1"/>
            <Setter Property="ItemContainerStyle">
                <Setter.Value>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Margin" Value="0"/>
                        <Setter Property="Padding" Value="0"/>
                        <Setter Property="Foreground" Value="Black"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Border x:Name="border" Padding="10,5" Cursor="Hand" Margin="5,2" Height="30"
                                                BorderThickness="1" BorderBrush="{DynamicResource CommonBoarder}">
                                        <DockPanel VerticalAlignment="Center">
                                            <Button Margin="10,0,0,0" DockPanel.Dock="Right" 
                                                    Command="{Binding RemoveSNCommand,RelativeSource={RelativeSource AncestorType=local:QualityReport}}" 
                                                    CommandParameter="{Binding }"
                                                    Tag="{Binding }">X</Button>
                                            <ContentPresenter x:Name="cp" Content="{TemplateBinding Content}" 
ContentStringFormat="{TemplateBinding ContentStringFormat}" 
ContentTemplate="{TemplateBinding ContentTemplate}" />
                                        </DockPanel>
                                    </Border>

                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsMouseOver" Value="True">
                                            <Setter TargetName="border" Property="Background" Value="#7093d3" />
                                            <Setter Property="Foreground" Value="{StaticResource SecondPrimaryColorContract}" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Border Style="{StaticResource CardBoarder}" Padding="0">
        <TabControl Style="{StaticResource HeaderTabControl}" >
            <TabItem Header="CMK">
                <Grid dp:GridHelper.Space="10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" dp:StackPanelHelper.ChildSpace="10">
                        <pu:FormGroup Header="型号" Style="{StaticResource InputFormGroupStyle}">
                            <ComboBox MinWidth="180" ItemsSource="{Binding Models}" Style="{StaticResource FormComboxStyle}" SelectedValue="{Binding Model}"
SelectedValuePath="Name" DisplayMemberPath="Name" />
                        </pu:FormGroup>

                        <pu:FormGroup Header="时间" Style="{StaticResource InputFormGroupStyle}">
                            <StackPanel Orientation="Horizontal">
                                <pu:DateTimePicker Style="{StaticResource TimePicker}" SelectedDateTime="{Binding StartTimeCMK}"></pu:DateTimePicker>
                                <TextBlock VerticalAlignment="Center" Text="   至   "/>
                                <pu:DateTimePicker Style="{StaticResource TimePicker}" SelectedDateTime="{Binding EndTimeCMK}"></pu:DateTimePicker>
                            </StackPanel>
                        </pu:FormGroup>

                        <pu:FormGroup Header="测试项" Style="{StaticResource InputFormGroupStyle}">
                            <pu:SearchBox Text="{Binding TestItemCMK,Mode=TwoWay}" Tag="Step" SearchTextChanged="SearchTextChanged" MinWidth="180" />
                        </pu:FormGroup>

                        <Button Style="{StaticResource QueryBtn}" Command="{Binding QueryCMKCommand}"/>
                        <Button Style="{StaticResource ExportBtn}" Command="{Binding ExportCMKCommand}"/>
                    </StackPanel>
                    <DataGrid Grid.Row="2" Style="{StaticResource ReportDataGrid}"
                              ItemsSource="{Binding DatasourceCMK}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="*" Header="数据1" Binding="{Binding d1}"/>
                            <DataGridTextColumn Width="*" Header="数据2" Binding="{Binding d2}"/>
                            <DataGridTextColumn Width="*" Header="数据3" Binding="{Binding d3}"/>
                            <DataGridTextColumn Width="*" Header="数据4" Binding="{Binding d4}"/>
                            <DataGridTextColumn Width="*" Header="数据5" Binding="{Binding d5}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
            <TabItem Header="MSA">
                <Grid dp:GridHelper.Space="10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" dp:StackPanelHelper.ChildSpace="10">
                        <pu:FormGroup Header="型号" Style="{StaticResource InputFormGroupStyle}">
                            <ComboBox MinWidth="180" ItemsSource="{Binding Models}" Style="{StaticResource FormComboxStyle}" SelectedValue="{Binding Model}"
              SelectedValuePath="Name" DisplayMemberPath="Name" />
                        </pu:FormGroup>

                        <pu:FormGroup Header="SN" Style="{StaticResource InputFormGroupStyle}">
                            <DockPanel>
                                <Button DockPanel.Dock="Right"
                                        Command="{Binding AddSnrCommand}"
                                        Style="{StaticResource PrimaryButton}" 
                                        FontFamily="{StaticResource iconfont}"
                                        Content="&#xe61a;"/>
                                <pu:SearchBox Text="{Binding Snr,Mode=TwoWay}" Tag="SN" SearchTextChanged="SearchTextChanged" MinWidth="180" />
                            </DockPanel>
                        </pu:FormGroup>

                        <pu:FormGroup Header="时间" Style="{StaticResource InputFormGroupStyle}">
                            <StackPanel Orientation="Horizontal">
                                <pu:DateTimePicker Style="{StaticResource TimePicker}" SelectedDateTime="{Binding StartTimeCMK}"></pu:DateTimePicker>
                                <TextBlock VerticalAlignment="Center" Text="   至   "/>
                                <pu:DateTimePicker Style="{StaticResource TimePicker}" SelectedDateTime="{Binding EndTimeCMK}"></pu:DateTimePicker>
                            </StackPanel>
                        </pu:FormGroup>

                        <Button Style="{StaticResource QueryBtn}" Command="{Binding QueryMSACommand}"/>
                        <Button Style="{StaticResource ExportBtn}" Command="{Binding ExportMSACommand}"/>
                    </StackPanel>
                    <pu:FormGroup Grid.Row="1" Header="已选SN" Style="{StaticResource InputFormGroupStyle}">
                        <ListBox Style="{StaticResource ListBoxItemStyle1}" ItemsSource="{Binding SelectedSnr}" Height="40">
                        </ListBox>
                    </pu:FormGroup>

                    <DataGrid Grid.Row="2" Style="{StaticResource ReportDataGrid}"
          ItemsSource="{Binding DatasourceMSA}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="*" Header="条码1" Binding="{Binding d1}"/>
                            <DataGridTextColumn Width="*" Header="条码2" Binding="{Binding d2}"/>
                            <DataGridTextColumn Width="*" Header="条码3" Binding="{Binding d3}"/>
                            <DataGridTextColumn Width="*" Header="条码4" Binding="{Binding d4}"/>
                            <DataGridTextColumn Width="*" Header="条码5" Binding="{Binding d5}"/>
                            <DataGridTextColumn Width="*" Header="条码6" Binding="{Binding d5}"/>
                            <DataGridTextColumn Width="*" Header="条码7" Binding="{Binding d5}"/>
                            <DataGridTextColumn Width="*" Header="条码8" Binding="{Binding d5}"/>
                            <DataGridTextColumn Width="*" Header="条码9" Binding="{Binding d5}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                    <!--<Grid Grid.Row="2" x:Name="msaGrid" dp:GridHelper.InnerBorder="1" dp:GridHelper.InnerBorderBrush="Black">
                        
                    </Grid>-->
                </Grid>
            </TabItem>
            <TabItem Header="重复性">
                <Grid dp:GridHelper.Space="10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center" dp:StackPanelHelper.ChildSpace="10">
                        <pu:FormGroup Header="型号" Style="{StaticResource InputFormGroupStyle}">
                            <ComboBox MinWidth="180" ItemsSource="{Binding Models}" Style="{StaticResource FormComboxStyle}" SelectedValue="{Binding Model}"
    SelectedValuePath="Name" DisplayMemberPath="Name" />
                        </pu:FormGroup>

                        <pu:FormGroup Header="SN" Style="{StaticResource InputFormGroupStyle}">
                            <DockPanel>
                                <Button DockPanel.Dock="Right"
                              Command="{Binding AddSnr2RepeatCommand}"
                              Style="{StaticResource PrimaryButton}" 
                              FontFamily="{StaticResource iconfont}"
                              Content="&#xe61a;"/>
                                <pu:SearchBox Text="{Binding Snr,Mode=TwoWay}" Tag="SN" SearchTextChanged="SearchTextChanged" MinWidth="180" />
                            </DockPanel>
                        </pu:FormGroup>

                        <pu:FormGroup Header="测试项" Style="{StaticResource InputFormGroupStyle}">
                            <pu:SearchBox Text="{Binding TestItemCMK,Mode=TwoWay}" Tag="Step" SearchTextChanged="SearchTextChanged" MinWidth="180" />
                        </pu:FormGroup>

                        <pu:FormGroup Header="时间" Style="{StaticResource InputFormGroupStyle}">
                            <StackPanel Orientation="Horizontal">
                                <pu:DateTimePicker Style="{StaticResource TimePicker}" SelectedDateTime="{Binding StartTimeCMK}"></pu:DateTimePicker>
                                <TextBlock VerticalAlignment="Center" Text="   至   "/>
                                <pu:DateTimePicker Style="{StaticResource TimePicker}" SelectedDateTime="{Binding EndTimeCMK}"></pu:DateTimePicker>
                            </StackPanel>
                        </pu:FormGroup>

                        <Button Style="{StaticResource QueryBtn}" Command="{Binding QueryRepeatCommand}"/>
                        <Button Style="{StaticResource ExportBtn}" Command="{Binding ExportRepeatCommand}"/>
                    </StackPanel>
                    <pu:FormGroup Grid.Row="1" Header="已选SN" Style="{StaticResource InputFormGroupStyle}">
                        <ListBox Style="{StaticResource ListBoxItemStyle1}" ItemsSource="{Binding SelectedSnrRepeat}" Height="40">
                        </ListBox>
                    </pu:FormGroup>

                    <DataGrid Grid.Row="2" Style="{StaticResource ReportDataGrid}" ItemsSource="{Binding DatasourceRepeat}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Width="*" Header="条码1" Binding="{Binding d1}"/>
                            <DataGridTextColumn Width="*" Header="条码2" Binding="{Binding d2}"/>
                            <DataGridTextColumn Width="*" Header="条码3" Binding="{Binding d3}"/>
                            <DataGridTextColumn Width="*" Header="条码4" Binding="{Binding d4}"/>
                            <DataGridTextColumn Width="*" Header="条码5" Binding="{Binding d5}"/>
                            <DataGridTextColumn Width="*" Header="条码6" Binding="{Binding d5}"/>
                            <DataGridTextColumn Width="*" Header="条码7" Binding="{Binding d5}"/>
                            <DataGridTextColumn Width="*" Header="条码8" Binding="{Binding d5}"/>
                            <DataGridTextColumn Width="*" Header="条码9" Binding="{Binding d5}"/>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>

            </TabItem>
        </TabControl>
    </Border>
</hb:SimpleMaskControl>
