<UserControl
    x:Class="MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory.ProcessHistoryTestView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    xmlns:userControls="clr-namespace:MECF.Framework.UI.Client.CenterViews.Core.UserControls"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
    xmlns:lex="http://wpflocalizeextension.codeplex.com"
    d:DesignHeight="800"
    d:DesignWidth="1900"
    FontSize="14"
    mc:Ignorable="d"
    lex:LocalizeDictionary.DesignCulture="en"
    lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
    lex:ResxLocalizationProvider.DefaultDictionary="lang_common">

    <UserControl.Resources>
        <cv:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />
    </UserControl.Resources>

    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="610" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Border
            Grid.ColumnSpan="2"
            Margin="0,6"
            Padding="1"
            HorizontalAlignment="Stretch"
            Background="{StaticResource Tab_BG}"
            BorderBrush="{StaticResource Tab_BD}"
            BorderThickness="1,1,1,1">
            <StackPanel Orientation="Horizontal">
                <StackPanel.Resources>
                    <Style TargetType="xctk:DateTimeUpDown">
                        <Setter Property="Width" Value="180" />
                        <Setter Property="Format" Value="Custom" />
                        <Setter Property="FormatString" Value="yyyy/MM/dd HH:mm:ss" />
                    </Style>
                </StackPanel.Resources>
                <StackPanel Margin="15,0" Orientation="Horizontal">
                    <TextBlock
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="14"
                        Text="{lex:Loc ID_TXT_StartTime}" />
                    <WindowsFormsHost
                        Width="170"
                        Height="25"
                        Margin="5,0,15,0"
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="14">
                        <forms:DateTimePicker
                            x:Name="wfTimeFrom"
                            CustomFormat="yyyy/MM/dd HH:mm:ss"
                            Format="Custom"
                            Value="2011-8-1" />
                    </WindowsFormsHost>
                    <TextBlock
                        Margin="0"
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="14"
                        Text="{lex:Loc ID_TXT_EndTime}" />
                    <WindowsFormsHost
                        Width="170"
                        Height="25"
                        Margin="5,0,0,0"
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="14">
                        <forms:DateTimePicker
                            x:Name="wfTimeTo"
                            CustomFormat="yyyy/MM/dd HH:mm:ss"
                            Format="Custom"
                            Value="2011-8-1" />
                    </WindowsFormsHost>
                    <ComboBox
                        Width="80"
                        Height="30"
                        Margin="20,0"
                        ItemsSource="{Binding PmList}"
                        SelectedItem="{Binding CbSelectPM}" />
                    <Button
                        Width="85"
                        Height="30"
                        HorizontalAlignment="Right"
                        Content="{lex:Loc ID_BTN_Query_Content}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <micro:ActionMessage MethodName="QueryRecipeProcessHistory" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button
                        Width="85"
                        Height="30"
                        Margin="15,0"
                        HorizontalAlignment="Right"
                        Content="{Binding ExportTXt}"
                        IsEnabled="{Binding IsExportNotBusy}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <micro:ActionMessage MethodName="ExportRecipeProcessHistory" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button
                        Width="100"
                        Height="30"
                        Margin="0,0,15,0"
                        HorizontalAlignment="Right"
                        Content="HandExport">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <micro:ActionMessage MethodName="HandExport" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button
                        Width="100"
                        Height="30"
                        Margin="0,0,15,0"
                        HorizontalAlignment="Right"
                        Content="AutoExport">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <micro:ActionMessage MethodName="AutoExport" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Label Margin="3,0" VerticalAlignment="Center">Select Recipe Name</Label>
                    <Label 
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Margin="3,0" VerticalAlignment="Center" Content="{lex:Loc ID_TXT_SelectRecipeName}"/>
                    <Label
                        Margin="3,0"
                        VerticalAlignment="Center"
                        Content="{Binding RecipeProcessHistoryData.Name}"
                        FontWeight="Black" />
                    <Label 
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Margin="3,0" VerticalAlignment="Center" Content="{lex:Loc ID_TXT_SelectStepName}"/>
                    <Label
                        Margin="3,0"
                        VerticalAlignment="Center"
                        Content="{Binding SelectProcessHistoryData.StepName}"
                        FontWeight="Black" />
                </StackPanel>
            </StackPanel>
        </Border>



        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            
            <DataGrid
                MaxHeight="350"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                AlternationCount="2"
                AutoGenerateColumns="False"
                CanUserAddRows="False"
                FontSize="14"
                IsReadOnly="True"
                Visibility="{Binding SelectRecipeIsNull, Converter={StaticResource BoolVisibilityConverter}}"
                ItemsSource="{Binding ProcessHistoryDataList}"
                ScrollViewer.VerticalScrollBarVisibility="Visible"
                SelectedItem="{Binding SelectProcessHistoryData}">
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content.Text}" />
                    </Style>
                </DataGrid.CellStyle>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <micro:ActionMessage MethodName="GetProcessHistory" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>

                <DataGrid.Columns>
                    <DataGridTemplateColumn Width="60">
                        <DataGridTemplateColumn.Header>
                            <StackPanel Orientation="Horizontal">
                                <CheckBox
                                    x:Name="cb_Select"
                                    VerticalContentAlignment="Center"
                                    Content="Exp">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <micro:ActionMessage MethodName="SetExportAll">
                                                <micro:Parameter Value="{Binding Path=IsChecked, RelativeSource={RelativeSource AncestorType={x:Type CheckBox}}}" />
                                            </micro:ActionMessage>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </CheckBox>
                                <!--<TextBlock Margin="3">全选</TextBlock>-->
                            </StackPanel>
                        </DataGridTemplateColumn.Header>
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox
                                    Margin="10,0"
                                    VerticalContentAlignment="Center"
                                    IsChecked="{Binding IsExport, UpdateSourceTrigger=PropertyChanged}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Width="155"
                        Binding="{Binding StepBeginTime}"
                        Header="{lex:Loc ID_TXT_StepStartTime}" />
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                        Width="90"
                        Binding="{Binding StepEndTimeDisp}"
                        Header="{lex:Loc ID_TXT_EndTime}" />
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Width="80"
                        Binding="{Binding StepTime}"
                        Header="{lex:Loc ID_TXT_StepTime}" />
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Width="80"
                        Binding="{Binding StepNumber}"
                        Header="{lex:Loc ID_TXT_StepNum}" />
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Width="116"
                        Binding="{Binding StepName}"
                        Header="{lex:Loc ID_TXT_StepName}" />
                </DataGrid.Columns>

            </DataGrid>

            <DataGrid
                Grid.Row="1"
                Margin="0,8,0,0"
                HorizontalAlignment="Left"
                VerticalAlignment="Top"
                AlternationCount="2"
                AutoGenerateColumns="False"
                CanUserAddRows="False"
                FontSize="14"
                IsReadOnly="True"
                Visibility="{Binding SelectRecipeIsNull, Converter={StaticResource BoolVisibilityConverter}}"
                ItemsSource="{Binding StepDeviceDataList}"
                ScrollViewer.VerticalScrollBarVisibility="Visible"
                SelectedItem="{Binding StepSelectDeviceData}">
                <DataGrid.CellStyle>
                    <Style TargetType="DataGridCell">
                        <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content.Text}" />
                    </Style>
                </DataGrid.CellStyle>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseDoubleClick">
                        <micro:ActionMessage MethodName="DeviceCharting" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
                <DataGrid.Columns>
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Width="170"
                        Binding="{Binding DeviceName}"
                        Header="{lex:Loc ID_TXT_DeviceName}" />
                    <DataGridTextColumn
                        Width="80"
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Binding="{Binding Unit}"
                        Header="{lex:Loc ID_TXT_Unit}" />
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Width="110"
                        Binding="{Binding Min, StringFormat=F1}"
                        Header="{lex:Loc ID_TXT_Min}" />
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Width="110"
                        Binding="{Binding Max, StringFormat=F1}"
                        Header="{lex:Loc ID_TXT_Max}" />
                    <DataGridTextColumn
                        lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
                        Width="110"
                        Binding="{Binding Average, StringFormat=F1}"
                        Header="{lex:Loc ID_TXT_Average}" />
                </DataGrid.Columns>

            </DataGrid>
        </Grid>
        <userControls:DataViewChart
            x:Name="chart"
            Grid.Row="1"
            Grid.Column="2"
            Margin="3,0"
            Visibility="{Binding SelectRecipeIsNull, Converter={StaticResource BoolVisibilityConverter}}"
            AutoRange="{Binding ChartAutoRange}"
            RenderableSeries="{Binding AppendedSeries}"
            VisibleRangeTime="{Binding VisibleRangeTime}"
            VisibleRangeValue="{Binding VisibleRangeValue}" />
    </Grid>
</UserControl>
