<Page x:Class="WSDDBBrowser.PgSelect"
      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:WSDDBBrowser"
      xmlns:conv="clr-namespace:WSDDBBrowser.Converter"
        xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
        xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="PageSelect">
    <Page.Resources>

    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <StackPanel Orientation="Vertical">

            <StackPanel Orientation="Vertical" Margin="{StaticResource ControlMargin}">
                <StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
                    <TextBlock Text="数据" Style="{StaticResource h1}" />
                    <TextBlock Text="查找" Style="{StaticResource h2}" VerticalAlignment="Bottom"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <StackPanel Orientation="Vertical" Margin="4">
                        <TextBlock Text="{Binding DBInitResult}" Foreground="Red"/>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
            <StackPanel Orientation="Vertical" Margin="5">

                
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Orientation="Horizontal">
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal">
                                <StackPanel Orientation="Vertical" Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource TitleStyle}" Text="机台号"/>
                                    <TextBox Style="{StaticResource ValueStyle}" Text="{Binding MachineNo}"/>
                                </StackPanel>
                                <StackPanel Orientation="Vertical" Margin="{StaticResource ControlMargin}">
                                    <TextBlock Style="{StaticResource TitleStyle}" Text="工序号"/>
                                    <TextBox Style="{StaticResource ValueStyle}" Text="{Binding StepNo}"/>
                                </StackPanel>
                            </StackPanel>
                            <StackPanel Orientation="Horizontal">

                                <DatePicker Width="200"
                            Margin="{StaticResource ControlMargin}"
                            HorizontalAlignment="Center"
                            HorizontalContentAlignment="Stretch"
                            controls:TextBoxHelper.UseFloatingWatermark="True"
                            controls:TextBoxHelper.Watermark="开始日期"
                            controls:TextBoxHelper.WatermarkAlignment="Right" 
                                        SelectedDate="{Binding BeginDate}"/>
                                <DatePicker Width="200"
                            Margin="{StaticResource ControlMargin}"
                            HorizontalAlignment="Center"
                            HorizontalContentAlignment="Stretch"
                            controls:TextBoxHelper.UseFloatingWatermark="True"
                            controls:TextBoxHelper.Watermark="结束日期"
                            controls:TextBoxHelper.WatermarkAlignment="Right" 
                                        SelectedDate="{Binding EndDate}"/>
                            </StackPanel>
                            <TextBox Margin="{StaticResource ControlMargin}" HorizontalAlignment="Left" Width="410"
                         controls:TextBoxHelper.ButtonCommand="{Binding ButtonSearch, Mode=OneWay}"
                         controls:TextBoxHelper.ClearTextButton="True"
                         controls:TextBoxHelper.UseFloatingWatermark="True"
                         controls:TextBoxHelper.Watermark="输入订单号查找"
                                 Text="{Binding OrderNoFilter}">
                                <TextBox.InputBindings>
                                    <KeyBinding Key="Return" 
                                    Command="{Binding ButtonSearch, Mode=OneWay}"
                                    CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TextBox}, Path=Text, Mode=OneWay}" />
                                </TextBox.InputBindings>
                                <TextBox.Style>
                                    <Style BasedOn="{StaticResource SearchMetroTextBox}" TargetType="{x:Type TextBox}">
                                        <Style.Triggers>
                                            <Trigger Property="controls:TextBoxHelper.HasText" Value="True">
                                                <Setter Property="controls:TextBoxHelper.ButtonContent" Value="r" />
                                                <Setter Property="controls:TextBoxHelper.ButtonContentTemplate" Value="{x:Null}" />
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBox.Style>
                            </TextBox>
                        </StackPanel>
                        <Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,5" Grid.Column="1" VerticalAlignment="Bottom" Command="{Binding ButtonSearch, Mode=OneWay}">
                            <iconPacks:Material Width="25" Height="25"
                                           Kind="Magnify" />
                        </Button>
                    </StackPanel>

                    <StackPanel Grid.Column="1" Orientation="Horizontal" Margin="{StaticResource ControlMargin}" HorizontalAlignment="Right">

                        <Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,5"  VerticalAlignment="Bottom" Click="ButtonOK_Click">
                            <iconPacks:PackIconFontAwesome Width="40" Height="40"
                                           Kind="CheckCircleSolid" />
                        </Button>
                    </StackPanel>
                </Grid>

            </StackPanel>
        </StackPanel>
        <Button VerticalAlignment="Top" HorizontalAlignment="Right" Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,-29" Grid.Column="1" Click="ButtonBack_Click">
            <iconPacks:PackIconEntypo Width="30" Height="30"
                                           Kind="Back" />
        </Button>
        <DataGrid x:Name="dgridProcesses" Grid.Row="1" AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{Binding Processes}"
                      RowStyle="{StaticResource MetroDataGridRow}"
                  SelectionMode="Single"
                  SelectionUnit="FullRow"
                      >
            <DataGrid.Style>
                <Style BasedOn="{StaticResource MetroDataGrid}" TargetType="{x:Type DataGrid}">
                    <Setter Property="AlternatingRowBackground" Value="{DynamicResource GrayBrush10}" />
                </Style>
            </DataGrid.Style>
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding OrderNo}" Header="订单号"/>
                <DataGridTextColumn Binding="{Binding ProjectNo}" Header="项目号"/>
                <DataGridTextColumn Binding="{Binding TechnologyNo}" Header="工艺号"/>
                <DataGridTextColumn Binding="{Binding BeginTime}" Header="开始时间"/>
                <DataGridTextColumn Binding="{Binding EndTime}" Header="结束时间"/>
                <DataGridTextColumn Binding="{Binding TotalLen}" Header="检测长度"/>
                <DataGridTextColumn Binding="{Binding HasSBData}" Header="温度数据"/>
                <DataGridTextColumn Binding="{Binding HasTGData}" Header="厚度数据"/>
            </DataGrid.Columns>
        </DataGrid>



    </Grid>
</Page>
