<UserControl
    x:Class="MECF.Framework.UI.Client.TrayThickness.HistoryData.HistoryDataView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
    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:lex="http://wpflocalizeextension.codeplex.com"
    xmlns:local="clr-namespace:MECF.Framework.UI.Client.TrayThickness.HistoryData"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
    d:DesignHeight="450"
    d:DesignWidth="1200"
    lex:LocalizeDictionary.DesignCulture="zh"
    lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
    lex:ResxLocalizationProvider.DefaultDictionary="lang_overview"
    mc:Ignorable="d">
    <UserControl.Resources>
        <local:ColorConverter x:Key="ColorConverter_Current" />
        <local:BoolToVisibilityConverter x:Key="BoolToVisibility_Converter" />
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <!--  右侧操作面板  -->
        <StackPanel
            Height="340"
            Margin="10"
            VerticalAlignment="Top"
            Background="#FFDBE5F1"
            Orientation="Vertical">
            <StackPanel
                Width="260"
                Margin="10"
                lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
                <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="3,0" Orientation="Horizontal">
                    <TextBlock
                        Width="70"
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="14"
                        Text="{lex:Loc ID_TXT_StartTime}" />
                    <WindowsFormsHost
                        Width="170"
                        Height="22"
                        Margin="5,0,0,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>
                </StackPanel>
                <StackPanel Margin="3,0" Orientation="Horizontal">
                    <TextBlock
                        Width="70"
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="14"
                        Text="{lex:Loc ID_TXT_EndTime}" />
                    <WindowsFormsHost
                        Width="170"
                        Height="22"
                        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>
                </StackPanel>

            </StackPanel>
            <StackPanel
                Margin="5"
                HorizontalAlignment="Right"
                Orientation="Horizontal">
                <RadioButton
                    Margin="5"
                    VerticalAlignment="Center"
                    Content="{lex:Loc ID_TXT_Tray}"
                    IsChecked="{Binding IsQueryTray}" />

                <RadioButton
                    Margin="5"
                    VerticalAlignment="Center"
                    Content="PM"
                    IsChecked="{Binding IsQueryPM}"
                    ToolTip="选中时间段内查询" />


            </StackPanel>
            <StackPanel lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
                <Button
                    Width="100"
                    Height="30"
                    Margin="10"
                    HorizontalAlignment="Left"
                    Content="Query All"
                    ToolTip="查询所有记录"
                    Visibility="Collapsed">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="QueryAll" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
                <Button
                    x:Name="ID_BTN_Query_Content"
                    Width="100"
                    Height="30"
                    Margin="10"
                    HorizontalAlignment="Right"
                    Content="{lex:Loc}"
                    ToolTip="{lex:Loc}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="QueryTime" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>

            </StackPanel>

            <StackPanel Visibility="{Binding IsQueryTray, Converter={StaticResource BoolToVisibility_Converter}}">
                <StackPanel
                    Margin="10,30,0,0"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                    Orientation="Horizontal">
                    <TextBlock
                        Width="50"
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="14"
                        Text="{lex:Loc ID_TXT_Name}" />
                    <TextBox
                        Name="txt_TrayName"
                        Width="170"
                        Height="22"
                        Margin="5,0,0,0"
                        VerticalAlignment="Center"
                        FontFamily="Arial"
                        FontSize="14" />


                </StackPanel>
                <StackPanel
                    Margin="10"
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">
                    <RadioButton
                        x:Name="ID_RAD_Monocycle_Content"
                        Margin="5"
                        VerticalAlignment="Center"
                        Content="{lex:Loc}"
                        IsChecked="{Binding Unit}"
                        ToolTip="{lex:Loc}" />


                    <RadioButton
                        x:Name="ID_RAD_Entirety_Content"
                        Margin="5"
                        VerticalAlignment="Center"
                        Content="{lex:Loc}"
                        IsChecked="{Binding Entirety}"
                        ToolTip="{lex:Loc}" />


                </StackPanel>
                <Button
                    Width="100"
                    Height="30"
                    Margin="10"
                    HorizontalAlignment="Right"
                    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
                    Content="{lex:Loc ID_BTN_Query_Content}"
                    ToolTip="{lex:Loc ID_BTN_Query_Content}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="QueryName">
                                <micro:ActionMessage.Parameters>
                                    <micro:Parameter Value="{Binding Path=Text, ElementName=txt_TrayName}" />
                                </micro:ActionMessage.Parameters>
                            </micro:ActionMessage>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
            </StackPanel>
        </StackPanel>

        <ScrollViewer
            Grid.Column="1"
            Width="900"
            Margin="10"
            HorizontalAlignment="Left"
            lex:ResxLocalizationProvider.DefaultDictionary="lang_overview">
            <StackPanel>

                <!--  Tray信息展示控件包含整体Tray和单环信息两种控件  -->
                <StackPanel Visibility="{Binding IsQueryTray, Converter={StaticResource BoolToVisibility_Converter}}">

                    <!--  单行信息展示  -->
                    <ListView
                        VerticalAlignment="Top"
                        AlternationCount="2"
                        ItemsSource="{Binding CoatingData}"
                        Visibility="{Binding Unit, Converter={StaticResource BoolToVisibility_Converter}}">
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Width="80" Header="{lex:Loc ID_TXT_Index}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Index}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>

                                <GridViewColumn Width="120" Header="{lex:Loc ID_TXT_Caption}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Caption}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>

                                <GridViewColumn Width="200" Header="{lex:Loc ID_TXT_Name}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding SerialNumber}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>

                                <GridViewColumn Width="100" Header="{lex:Loc ID_TXT_Max}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding MAX}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>

                                <GridViewColumn Width="100" Header="{lex:Loc ID_TXT_Current}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Current, StringFormat=N2}">
                                                <TextBlock.Foreground>
                                                    <MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
                                                        <Binding Path="Current" />
                                                        <Binding Path="MAX" />
                                                    </MultiBinding>
                                                </TextBlock.Foreground>
                                            </TextBlock>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>

                                <GridViewColumn Width="80" Header="{lex:Loc ID_TXT_PM_ID}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding PmOwned}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>

                                <GridViewColumn Width="220" Header="{lex:Loc ID_TXT_Creat_Time}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding CreatTime}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>

                            </GridView>
                        </ListView.View>
                    </ListView>

                    <!--  Tray整体信息展示  -->
                    <ListView
                        HorizontalAlignment="Left"
                        Background="White"
                        FontSize="12"
                        ItemsSource="{Binding TrayCoatingList}"
                        Visibility="{Binding IsNotUnit, Converter={StaticResource BoolToVisibility_Converter}}">
                        <ListView.Resources>
                            <Style TargetType="ListViewItem">
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="White" />
                                    </Trigger>
                                    <Trigger Property="IsMouseOver" Value="False">
                                        <Setter Property="Background" Value="White" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>

                            <Style TargetType="Label">
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Background" Value="LightSkyBlue" />
                                    </Trigger>
                                    <Trigger Property="IsMouseOver" Value="False">
                                        <Setter Property="Background" Value="White" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </ListView.Resources>
                        <ListView.View>
                            <GridView>
                                <GridViewColumn
                                    Width="900"
                                    lex:ResxLocalizationProvider.DefaultDictionary="lang_overview"
                                    Header="{lex:Loc ID_TXT_Tray_Coating_History_Data}">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <Grid Width="850">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="50" />
                                                    <ColumnDefinition />
                                                </Grid.ColumnDefinitions>
                                                <Border BorderBrush="Gray" BorderThickness="1,1,0,1">
                                                    <Label
                                                        HorizontalAlignment="Center"
                                                        VerticalAlignment="Center"
                                                        Content="{Binding Tray.PmOwned}"
                                                        FontFamily="Bold"
                                                        FontSize="18" />
                                                </Border>

                                                <StackPanel Grid.Column="1">
                                                    <Border BorderBrush="Gray" BorderThickness="1">
                                                        <StackPanel Orientation="Horizontal">
                                                            <Label>Caption:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding Tray.Caption}" />

                                                            <Label>Name:</Label>
                                                            <Label
                                                                Width="150"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding Tray.SerialNumber}" />

                                                            <Label>Max:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding Tray.MAX}" />

                                                            <Label>Thickness:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding Tray.Current}">
                                                                <Label.Foreground>
                                                                    <MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
                                                                        <Binding Path="Tray.Current" />
                                                                        <Binding Path="Tray.MAX" />
                                                                    </MultiBinding>
                                                                </Label.Foreground>
                                                            </Label>

                                                            <Label>Time:</Label>
                                                            <Label
                                                                Width="160"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding Tray.CreatTime}" />

                                                        </StackPanel>
                                                    </Border>

                                                    <Border BorderBrush="Gray" BorderThickness="1,0,1,1">
                                                        <StackPanel Orientation="Horizontal">
                                                            <Label>Caption:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding TrayInner.Caption}" />

                                                            <Label>Name:</Label>
                                                            <Label
                                                                Width="150"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding TrayInner.SerialNumber}" />

                                                            <Label>Max:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding TrayInner.MAX}" />

                                                            <Label>Thickness:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding TrayInner.Current}">
                                                                <Label.Foreground>
                                                                    <MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
                                                                        <Binding Path="TrayInner.Current" />
                                                                        <Binding Path="TrayInner.MAX" />
                                                                    </MultiBinding>
                                                                </Label.Foreground>
                                                            </Label>

                                                            <Label>Time:</Label>
                                                            <Label
                                                                Width="160"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding TrayInner.CreatTime}" />
                                                        </StackPanel>
                                                    </Border>

                                                    <Border BorderBrush="Gray" BorderThickness="1,0,1,1">
                                                        <StackPanel Orientation="Horizontal">
                                                            <Label>Caption:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingInner.Caption}" />

                                                            <Label>Name:</Label>
                                                            <Label
                                                                Width="150"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingInner.SerialNumber}" />

                                                            <Label>Max:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingInner.MAX}" />

                                                            <Label>Thickness:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingInner.Current}">
                                                                <Label.Foreground>
                                                                    <MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
                                                                        <Binding Path="RingInner.Current" />
                                                                        <Binding Path="RingInner.MAX" />
                                                                    </MultiBinding>
                                                                </Label.Foreground>
                                                            </Label>

                                                            <Label>Time:</Label>
                                                            <Label
                                                                Width="160"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingInner.CreatTime}" />
                                                        </StackPanel>
                                                    </Border>

                                                    <Border BorderBrush="Gray" BorderThickness="1,0,1,1">
                                                        <StackPanel Orientation="Horizontal">
                                                            <Label>Caption:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingOuter.Caption}" />

                                                            <Label>Name:</Label>
                                                            <Label
                                                                Width="150"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingOuter.SerialNumber}" />

                                                            <Label>Max:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingOuter.MAX}" />

                                                            <Label>Thickness:</Label>
                                                            <Label
                                                                Width="60"
                                                                Margin="0,0,5,0"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingOuter.Current}">
                                                                <Label.Foreground>
                                                                    <MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
                                                                        <Binding Path="RingOuter.Current" />
                                                                        <Binding Path="RingOuter.MAX" />
                                                                    </MultiBinding>
                                                                </Label.Foreground>
                                                            </Label>

                                                            <Label>Time:</Label>
                                                            <Label
                                                                Width="160"
                                                                HorizontalAlignment="Left"
                                                                Content="{Binding RingOuter.CreatTime}" />
                                                        </StackPanel>
                                                    </Border>
                                                </StackPanel>
                                            </Grid>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>

                </StackPanel>

                <!--  PM信息展示控件  -->
                <ListView
                    HorizontalAlignment="Left"
                    Background="White"
                    FontSize="12"
                    ItemsSource="{Binding PMCoatingList}"
                    Visibility="{Binding IsQueryPM, Converter={StaticResource BoolToVisibility_Converter}}">
                    <ListView.Resources>
                        <Style TargetType="ListViewItem">
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" Value="White" />
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="False">
                                    <Setter Property="Background" Value="White" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>

                        <Style TargetType="Label">
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter Property="Background" Value="LightSkyBlue" />
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="False">
                                    <Setter Property="Background" Value="White" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </ListView.Resources>
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Width="920" Header="{lex:Loc ID_TXT_PM_Coating_History_Data}">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Width="920">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="50" />
                                                <ColumnDefinition />
                                            </Grid.ColumnDefinitions>
                                            <Border BorderBrush="Gray" BorderThickness="1,1,0,1">
                                                <Label
                                                    HorizontalAlignment="Center"
                                                    VerticalAlignment="Center"
                                                    Content="{Binding MinorCycle.PmOwned}"
                                                    FontFamily="Bold"
                                                    FontSize="18" />
                                            </Border>

                                            <StackPanel Grid.Column="1">
                                                <Border BorderBrush="Gray" BorderThickness="1">
                                                    <StackPanel Orientation="Horizontal">
                                                        <Label>Caption:</Label>
                                                        <Label
                                                            Width="80"
                                                            Margin="0,0,5,0"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MinorCycle.Caption}" />

                                                        <Label>Name:</Label>
                                                        <Label
                                                            Width="150"
                                                            Margin="0,0,5,0"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MinorCycle.SerialNumber}" />

                                                        <Label>Max:</Label>
                                                        <Label
                                                            Width="60"
                                                            Margin="0,0,5,0"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MinorCycle.MAX}" />

                                                        <Label>Thickness:</Label>
                                                        <Label
                                                            Width="60"
                                                            Margin="0,0,5,0"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MinorCycle.Current}" />

                                                        <Label>Time:</Label>
                                                        <Label
                                                            Width="160"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MinorCycle.CreatTime}" />

                                                    </StackPanel>
                                                </Border>

                                                <Border BorderBrush="Gray" BorderThickness="1,0,1,1">
                                                    <StackPanel Orientation="Horizontal">
                                                        <Label>Caption:</Label>
                                                        <Label
                                                            Width="80"
                                                            Margin="0,0,5,0"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MajorCycle.Caption}" />

                                                        <Label>Name:</Label>
                                                        <Label
                                                            Width="150"
                                                            Margin="0,0,5,0"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MajorCycle.SerialNumber}" />

                                                        <Label>Max:</Label>
                                                        <Label
                                                            Width="60"
                                                            Margin="0,0,5,0"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MajorCycle.MAX}" />

                                                        <Label>Thickness:</Label>
                                                        <Label
                                                            Width="60"
                                                            Margin="0,0,5,0"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MajorCycle.Current}" />

                                                        <Label>Time:</Label>
                                                        <Label
                                                            Width="160"
                                                            HorizontalAlignment="Left"
                                                            Content="{Binding MajorCycle.CreatTime}" />
                                                    </StackPanel>
                                                </Border>
                                            </StackPanel>
                                        </Grid>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>
            </StackPanel>

        </ScrollViewer>

    </Grid>
</UserControl>
