<mah:MetroWindow x:Class="BDU.Windows.TestDataInfomationWindow"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:local="clr-namespace:BDU.Windows"
                 xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 Title="TestDataInfomationWindow"
                 Width="800"
                 Height="450"
                 d:DataContext="{d:DesignInstance Type=local:TestDataInfomationWindow}"
                 PreviewKeyDown="TestDataWindow_PreviewKeyDown"
                 Loaded="MetroWindow_Loaded"
                 ShowTitleBar="False"
                 WindowStyle="None"
                 mc:Ignorable="d">
    <Grid>
        <GroupBox Header="测试数据记录"
                  Padding="10"
                  MouseLeftButtonDown="GroupBox_MouseLeftButtonDown">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>

                <StackPanel Margin="7">
                    <StackPanel Orientation="Horizontal">
                        <Label Content="参数名称"
                               VerticalAlignment="Bottom"
                               Margin="7,7,0,7" />
                        <TextBox Width="80"
                                 Text="{Binding Search_ParaName}"
                                 Margin="0,7,7,7" />

                        <Label Content="测试结果"
                               VerticalAlignment="Bottom"
                               Margin="7,7,0,7" />
                        <ComboBox Width="80"
                                  Text="{Binding Search_Result}"
                                  Margin="0,7,7,7">
                            <ComboBoxItem Content="" />
                            <ComboBoxItem Content="PASS" />
                            <ComboBoxItem Content="FAIL" />
                        </ComboBox>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <CheckBox IsChecked="{Binding Search_IsUseTime}"
                                  VerticalAlignment="Bottom"
                                  Margin="7,7,0,10" />
                        <StackPanel Orientation="Horizontal">
                            <Label Content="启用时间筛选"
                                   VerticalAlignment="Bottom"
                                   Margin="0,7,7,7" />
                            <Label Content="开始时间"
                                   Margin="7,7,0,7"
                                   VerticalAlignment="Bottom" />
                            <TextBox Text="{Binding Search_StartTime,StringFormat='yyyy-MM-dd HH:mm:ss'}"
                                     Margin="0,7,7,7"
                                     Width="120"
                                     VerticalAlignment="Bottom" />
                            <mah:DateTimePicker Width="25"
                                                Background="Transparent"
                                                SelectedDateTime="{Binding Search_StartTime}"
                                                VerticalAlignment="Bottom"
                                                Margin="0,7,7,7" />
                            <Label Content="结束时间"
                                   Margin="7,7,0,7"
                                   VerticalAlignment="Bottom" />
                            <TextBox Text="{Binding Search_EndTime,StringFormat='yyyy-MM-dd HH:mm:ss'}"
                                     Margin="0,7,7,7"
                                     Width="120"
                                     VerticalAlignment="Bottom" />
                            <mah:DateTimePicker Width="25"
                                                Background="Transparent"
                                                SelectedDateTime="{Binding Search_EndTime}"
                                                VerticalAlignment="Bottom"
                                                Margin="0,7,7,7" />
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
                <StackPanel  Grid.Column="1"
                             Margin="7"
                             Orientation="Horizontal">
                    <Button Content="查询"
                            Width="80"
                            VerticalAlignment="Center"
                            Margin="7"
                            Click="Search_Click" />
                    <Button Content="导出"
                            Width="80"
                            VerticalAlignment="Center"
                            Margin="7"
                            Click="Export_Click" />
                </StackPanel>
                <DataGrid Name="TestData_DataGrid"
                          Grid.Row="1"
                          Grid.ColumnSpan="2"
                          AutoGenerateColumns="False"
                          Background="Transparent"
                          IsReadOnly="True"
                          CanUserAddRows="False"
                          ItemsSource="{Binding DataList}"
                          Margin="15">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="参数名称"
                                            Binding="{Binding ParameterID, Converter={StaticResource GuidToParameterNameConverter}}" />
                        <DataGridTextColumn Header="实际值"
                                            Binding="{Binding Value}" />
                        <DataGridTextColumn Header="下限值"
                                            Binding="{Binding LowerLimit}" />
                        <DataGridTextColumn Header="上限值"
                                            Binding="{Binding UpperLimit}" />
                        <DataGridTemplateColumn Header="测试结果">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock x:Name="OKNG"></TextBlock>
                                    <DataTemplate.Triggers>
                                        <DataTrigger Binding="{Binding Result}"
                                                     Value="true">
                                            <Setter TargetName="OKNG"
                                                    Property="Text"
                                                    Value="PASS"></Setter>
                                        </DataTrigger>
                                        <DataTrigger Binding="{Binding Result}"
                                                     Value="false">
                                            <Setter TargetName="OKNG"
                                                    Property="Text"
                                                    Value="FAIL"></Setter>
                                        </DataTrigger>
                                    </DataTemplate.Triggers>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTextColumn Header="测试时间"
                                            Binding="{Binding InsertTime, StringFormat=yyyy-MM-dd HH:mm:ss}" />
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </GroupBox>
    </Grid>
</mah:MetroWindow>
