<UserControl
    x:Class="SicUI.Models.Operations.Gem.GemView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="http://www.caliburn.org"
    xmlns:controls="clr-namespace:SicUI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    d:DesignHeight="900"
    d:DesignWidth="1920"
    mc:Ignorable="d">
    <UserControl.Resources>
        <Style x:Key="CenterAlinmentStyle" TargetType="TextBlock">
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
    </UserControl.Resources>

    <Grid IsEnabled="{Binding IsPermission}">
        <Grid.RowDefinitions>
            <RowDefinition Height="160" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="435" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <GroupBox Header="GEM通信">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>

                <StackPanel Orientation="Horizontal">
                    <TextBlock VerticalAlignment="Center" Text="通信状态: " />
                    <TextBlock VerticalAlignment="Center" Text="{Binding CommunicationState}" />
                </StackPanel>

                <StackPanel Grid.Row="1" Orientation="Horizontal">
                    <TextBlock VerticalAlignment="Center" Text="控制模式: " />
                    <TextBlock VerticalAlignment="Center" Text="{Binding ControlMode}" />
                </StackPanel>

                <StackPanel Grid.Row="2" Orientation="Horizontal">
                    <Button
                        Width="80"
                        Height="30"
                        Margin="2,0"
                        Content="打开">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetEnable">
                                    <cal:Parameter Value="True" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>

                    <Button
                        Width="80"
                        Height="30"
                        Margin="2,0"
                        Content="关闭">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetEnable">
                                    <cal:Parameter Value="False" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>

                    <Button
                        Width="80"
                        Height="30"
                        Margin="2,0"
                        Content="远程在线">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetControlMode">
                                    <cal:Parameter Value="OnlineRemote" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>

                    <Button
                        Width="80"
                        Height="30"
                        Margin="2,0"
                        Content="本地在线">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetControlMode">
                                    <cal:Parameter Value="OnlineLocal" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>

                    <Button
                        Width="80"
                        Height="30"
                        Margin="2,0"
                        Content="离线">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="SetControlMode">
                                    <cal:Parameter Value="Offline" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </StackPanel>

            </Grid>
        </GroupBox>

        <TabControl
            Grid.Row="1"
            Grid.ColumnSpan="3"
            Margin="0,20">
            <TabItem Header="数据采集">
                <DataGrid
                    MaxHeight="560"
                    AlternationCount="2"
                    AutoGenerateColumns="False"
                    CanUserAddRows="False"
                    ItemsSource="{Binding VariableList}"
                    ScrollViewer.CanContentScroll="True"
                    ScrollViewer.VerticalScrollBarVisibility="Visible"
                    VirtualizingPanel.IsVirtualizing="True">
                    <DataGrid.Columns>
                        <DataGridTextColumn
                            Width="80"
                            Binding="{Binding Id}"
                            ElementStyle="{StaticResource CenterAlinmentStyle}"
                            Header="编号"
                            IsReadOnly="True" />

                        <DataGridTextColumn
                            Width="350"
                            Binding="{Binding Name}"
                            Header="名称"
                            IsReadOnly="True" />
                        <DataGridTextColumn
                            Width="60"
                            Binding="{Binding VariableType}"
                            ElementStyle="{StaticResource CenterAlinmentStyle}"
                            Header="类型" />
                        <DataGridTextColumn
                            Width="200"
                            Binding="{Binding SmlValue}"
                            ElementStyle="{StaticResource CenterAlinmentStyle}"
                            Header="当前值" />
                        <DataGridTextColumn
                            Width="10*"
                            Binding="{Binding Description}"
                            Header="描述信息"
                            IsReadOnly="True" />
                    </DataGrid.Columns>
                    <DataGrid.ItemContainerStyle>
                        <Style TargetType="DataGridRow">
                            <Style.Triggers>
                                <Trigger Property="DataGrid.AlternationIndex" Value="1">
                                    <Setter Property="Background" Value="#FFDEDEDE" />
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </DataGrid.ItemContainerStyle>
                </DataGrid>

            </TabItem>

            <TabItem Header="事件上报">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="61*" />
                        <ColumnDefinition Width="416*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <DataGrid
                        Grid.ColumnSpan="2"
                        Height="280"
                        AlternationCount="2"
                        AutoGenerateColumns="False"
                        CanUserAddRows="False"
                        ItemsSource="{Binding EventList}"
                        ScrollViewer.CanContentScroll="True"
                        ScrollViewer.VerticalScrollBarVisibility="Visible"
                        VirtualizingPanel.IsVirtualizing="True">
                        <DataGrid.Columns>
                            <DataGridTextColumn
                                Width="80"
                                Binding="{Binding EventId}"
                                ElementStyle="{StaticResource CenterAlinmentStyle}"
                                Header="编号"
                                IsReadOnly="True" />

                            <DataGridTextColumn
                                Width="350"
                                Binding="{Binding EventName}"
                                Header="名称"
                                IsReadOnly="True" />

                            <DataGridTextColumn
                                Width="*"
                                Binding="{Binding Description}"
                                Header="描述信息"
                                IsReadOnly="True" />

                        </DataGrid.Columns>
                        <DataGrid.ItemContainerStyle>
                            <Style TargetType="DataGridRow">
                                <Style.Triggers>
                                    <Trigger Property="DataGrid.AlternationIndex" Value="1">
                                        <Setter Property="Background" Value="#FFDEDEDE" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </DataGrid.ItemContainerStyle>
                    </DataGrid>

                    <DataGrid
                        Grid.Row="1"
                        Grid.ColumnSpan="2"
                        Height="280"
                        AlternationCount="2"
                        AutoGenerateColumns="False"
                        CanUserAddRows="False"
                        ItemsSource="{Binding EventInfoList}"
                        ScrollViewer.CanContentScroll="True"
                        ScrollViewer.VerticalScrollBarVisibility="Visible"
                        VirtualizingPanel.IsVirtualizing="True">
                        <DataGrid.Columns>
                            <DataGridTextColumn
                                Width="1854"
                                Binding="{Binding .}"
                                Header="事件信息"
                                IsReadOnly="True" />
                        </DataGrid.Columns>

                        <DataGrid.ItemContainerStyle>
                            <Style TargetType="DataGridRow">
                                <Style.Triggers>
                                    <Trigger Property="DataGrid.AlternationIndex" Value="1">
                                        <Setter Property="Background" Value="#FFDEDEDE" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </DataGrid.ItemContainerStyle>
                    </DataGrid>
                </Grid>
            </TabItem>

            <TabItem Header="报警上报">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <DataGrid
                        Height="280"
                        AlternationCount="2"
                        AutoGenerateColumns="False"
                        CanUserAddRows="False"
                        ItemsSource="{Binding AlarmList}"
                        ScrollViewer.CanContentScroll="True"
                        ScrollViewer.VerticalScrollBarVisibility="Visible"
                        VirtualizingPanel.IsVirtualizing="True">
                        <DataGrid.Columns>
                            <DataGridTextColumn
                                Width="80"
                                Binding="{Binding AlarmID}"
                                ElementStyle="{StaticResource CenterAlinmentStyle}"
                                Header="编号"
                                IsReadOnly="True" />

                            <DataGridTextColumn
                                Width="350"
                                Binding="{Binding Name}"
                                Header="名称"
                                IsReadOnly="True" />

                            <DataGridTextColumn
                                Width="80"
                                Binding="{Binding ALCD}"
                                ElementStyle="{StaticResource CenterAlinmentStyle}"
                                Header="ALCD"
                                IsReadOnly="True" />

                            <DataGridTextColumn
                                Width="120"
                                Binding="{Binding AlarmText}"
                                ElementStyle="{StaticResource CenterAlinmentStyle}"
                                Header="ALTX"
                                IsReadOnly="True" />

                            <DataGridTextColumn
                                Width="*"
                                Binding="{Binding Description}"
                                Header="描述信息"
                                IsReadOnly="True" />

                        </DataGrid.Columns>
                        <DataGrid.ItemContainerStyle>
                            <Style TargetType="DataGridRow">
                                <Style.Triggers>
                                    <Trigger Property="DataGrid.AlternationIndex" Value="1">
                                        <Setter Property="Background" Value="#FFDEDEDE" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </DataGrid.ItemContainerStyle>
                    </DataGrid>

                    <DataGrid
                        Grid.Row="1"
                        Height="280"
                        AlternationCount="2"
                        AutoGenerateColumns="False"
                        CanUserAddRows="False"
                        ItemsSource="{Binding AlarmInfoList}"
                        ScrollViewer.CanContentScroll="True"
                        ScrollViewer.VerticalScrollBarVisibility="Visible"
                        VirtualizingPanel.IsVirtualizing="True">
                        <DataGrid.Columns>
                            <DataGridTextColumn
                                Width="1854"
                                Binding="{Binding .}"
                                Header="报警信息"
                                IsReadOnly="True" />
                        </DataGrid.Columns>

                        <DataGrid.ItemContainerStyle>
                            <Style TargetType="DataGridRow">
                                <Style.Triggers>
                                    <Trigger Property="DataGrid.AlternationIndex" Value="1">
                                        <Setter Property="Background" Value="#FFDEDEDE" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </DataGrid.ItemContainerStyle>
                    </DataGrid>
                </Grid>
            </TabItem>

            <!--<TabItem Header="配方管理">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="500" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <DataGrid
                        Height="560"
                        AlternationCount="2"
                        AutoGenerateColumns="False"
                        CanUserAddRows="False"
                        VirtualizingPanel.IsVirtualizing="True"
                        VirtualizingPanel.ScrollUnit="Item"
                        EnableRowVirtualization ="True"
                        VirtualizingPanel.VirtualizationMode="Recycling" 
                        EnableColumnVirtualization="True" 
                        VirtualizingPanel.IsContainerVirtualizable="True"
                        ItemsSource="{Binding SequenceRecipeNameList,IsAsync=False}">
                        <DataGrid.Columns>
                            <DataGridTextColumn
                                Width="495"
                                Binding="{Binding .}"
                                Header="Sequence和Recipe名称"
                                IsReadOnly="True" />
                        </DataGrid.Columns>

                        <DataGrid.ItemContainerStyle>
                            <Style TargetType="DataGridRow">
                                <Style.Triggers>
                                    <Trigger Property="DataGrid.AlternationIndex" Value="1">
                                        <Setter Property="Background" Value="#FFDEDEDE" />
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </DataGrid.ItemContainerStyle>

                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="SelectedCellsChanged">
                                <cal:ActionMessage MethodName="SelectedCellsChanged">
                                    <cal:Parameter Value="$source" />
                                    <cal:Parameter Value="$eventargs" />
                                </cal:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>

                    </DataGrid>

                    <TextBox
                        Grid.Column="1"
                        Margin="10,0,0,0"
                        VerticalContentAlignment="Top"
                        AcceptsReturn="True"
                        AcceptsTab="True"
                        Background="WhiteSmoke"
                        HorizontalScrollBarVisibility="Auto"
                        IsReadOnly="True"
                        ScrollViewer.CanContentScroll="True"
                        Text="{Binding SequenceRecipeContent}"
                        TextAlignment="Left"
                        TextWrapping="NoWrap"
                        VerticalScrollBarVisibility="Auto" />

                </Grid>
            </TabItem>-->

            <TabItem Header="远程操作">
                <Grid Height="560">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="360"/>
                        <ColumnDefinition Width="360"/>
                    </Grid.ColumnDefinitions>

                    <StackPanel Orientation="Vertical">
                        <TextBlock Margin="5,5,5,10" Text="当前程序支持以下远程指令:" />
                        <TextBlock Margin="5,5,5,2" Text="1.  GO-LOCAL(S2F21)" />
                        <TextBlock Margin="5,0,5,5" Text="无参数" />

                        <TextBlock Margin="5,5,5,2" Text="2.  GO-REMOTE(S2F21)" />
                        <TextBlock Margin="5,0,5,5" Text="无参数" />

                        <TextBlock Margin="5,5,5,2" Text="3.  PP-SELECT(S2F41)" />
                        <TextBlock Margin="5,0,5,5" Text="参数1名称： PPID， 参数1类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="参数2名称： LotID，参数2类型： ASCII" />

                        <TextBlock Margin="5,5,5,2" Text="4.  CREATE-JOB(S2F21)" />
                        <TextBlock Margin="5,0,5,5" Text="无参数" />

                        <TextBlock Margin="5,5,5,2" Text="5.  START(S2F21)" />
                        <TextBlock Margin="5,0,5,5" Text="无参数" />

                        <TextBlock Margin="5,5,5,2" Text="6.  ABORT(S2F21)" />
                        <TextBlock Margin="5,0,5,5" Text="无参数" />

                        <TextBlock Margin="5,5,5,2" Text="7.  STOP(S2F21)" />
                        <TextBlock Margin="5,0,5,5" Text="无参数" />

                        <TextBlock Margin="5,5,5,2" Text="8.  Online(S2F41)" />
                        <TextBlock Margin="5,0,5,5" Text="参数1名称： ModuleID， 参数1类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  System/LoadLock/Buffer/TM/PM1/PM2" />

                        <TextBlock Margin="5,5,5,2" Text="9.  Offline(S2F41)" />
                        <TextBlock Margin="5,0,5,5" Text="参数1名称： ModuleID， 参数1类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  System/LoadLock/Buffer/TM/PM1/PM2" />

                    </StackPanel>

                    <StackPanel Orientation="Vertical" Grid.Column="1">
                        <TextBlock Margin="5,5,5,10" Text="" />

                        <TextBlock Margin="5,5,5,2" Text="10.  CreateWafer(S2F41)" />
                        <TextBlock Margin="5,0,5,5" Text="参数1名称： ModuleID， 参数1类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  TM/LoadLock/Buffer/PM1/PM2" />
                        <TextBlock Margin="5,5,5,5" Text="参数2名称： SlotID，参数2类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  Buffer为0,1,2;其余为0" />

                        <TextBlock Margin="5,5,5,2" Text="11.  CreateTray(S2F41)" />
                        <TextBlock Margin="5,0,5,5" Text="参数1名称： ModuleID， 参数1类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  TM/LoadLock/Buffer/PM1/PM2" />
                        <TextBlock Margin="5,5,5,5" Text="参数2名称： SlotID，参数2类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  Buffer为0,1,2;其余为0" />

                        <TextBlock Margin="5,5,5,2" Text="12.  DeleteWafer(S2F41)" />
                        <TextBlock Margin="5,0,5,5" Text="参数1名称： ModuleID， 参数1类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  TM/LoadLock/Buffer/PM1/PM2" />
                        <TextBlock Margin="5,5,5,5" Text="参数2名称： SlotID，参数2类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  Buffer为0,1,2;其余为0" />

                        <TextBlock Margin="5,5,5,2" Text="13.  DeleteTray(S2F41)" />
                        <TextBlock Margin="5,0,5,5" Text="参数1名称： ModuleID， 参数1类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  TM/LoadLock/Buffer/PM1/PM2" />
                        <TextBlock Margin="5,5,5,5" Text="参数2名称： SlotID，参数2类型： ASCII" />
                        <TextBlock Margin="5,0,5,5" Text="枚举值:  Buffer为0,1,2;其余为0" />

                    </StackPanel>
                </Grid>
            </TabItem>

            <TabItem Header="终端服务">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <GroupBox Height="560" Header="收到来自工厂主机的消息">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="25" />
                            </Grid.RowDefinitions>
                            <TextBox
                                Margin="2,2,2,2"
                                VerticalContentAlignment="Top"
                                AcceptsReturn="True"
                                AcceptsTab="True"
                                Background="WhiteSmoke"
                                IsReadOnly="True"
                                Text="{Binding RecvMsg}" />

                            <Button
                                Grid.Row="1"
                                Width="70"
                                Margin="0,0,2,0"
                                HorizontalAlignment="Right"
                                Content="确认消息"
                                IsDefault="True"
                                IsEnabled="True">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="ConfirmHostMessage" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </Grid>
                    </GroupBox>
                    <GroupBox
                        Grid.Column="1"
                        Height="560"
                        Header="发送给工厂主机的消息">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <TextBox
                                Margin="2,2,2,5"
                                VerticalContentAlignment="Top"
                                AcceptsReturn="True"
                                AcceptsTab="True"
                                Background="WhiteSmoke"
                                IsReadOnly="True"
                                Text="{Binding SendMsgTextBox}" />
                            <TextBox
                                Grid.Row="1"
                                Margin="2,0,71,0"
                                VerticalContentAlignment="Center"
                                Text="{Binding SendMsg, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                            <Button
                                Grid.Row="1"
                                Width="70"
                                Margin="0,0,2,0"
                                HorizontalAlignment="Right"
                                Content="发送"
                                IsDefault="True"
                                IsEnabled="True">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <cal:ActionMessage MethodName="SendMessageToHost" />
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>
                        </Grid>
                    </GroupBox>
                </Grid>
            </TabItem>

            <!--<TabItem Header="程序日志">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="346*" />
                        <ColumnDefinition Width="190*" />
                        <ColumnDefinition Width="11*" />
                        <ColumnDefinition Width="1361*" />
                    </Grid.ColumnDefinitions>
                    <TextBox
                        Grid.ColumnSpan="4"
                        Height="520"
                        Margin="0,35,0,0"
                        VerticalContentAlignment="Top"
                        AcceptsReturn="True"
                        AcceptsTab="True"
                        Background="WhiteSmoke"
                        Text="{Binding ProgramLog}"
                        TextAlignment="Left"
                        TextWrapping="NoWrap"
                        VerticalScrollBarVisibility="Auto" />
                    <Button
                        Grid.Column="3"
                        Width="80"
                        Height="30"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Top"
                        Content="清除">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="ClearProgramLog" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Grid>
            </TabItem>

            <TabItem Header="SECS日志">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="193*" />
                        <ColumnDefinition Width="761*" />
                    </Grid.ColumnDefinitions>
                    <TextBox
                        Grid.ColumnSpan="2"
                        Height="520"
                        Margin="0,35,0,0"
                        VerticalContentAlignment="Top"
                        AcceptsReturn="True"
                        AcceptsTab="True"
                        Background="WhiteSmoke"
                        Text="{Binding SecsLog}"
                        TextAlignment="Left"
                        TextWrapping="NoWrap"
                        VerticalScrollBarVisibility="Auto" />
                    <Button
                        Grid.Column="1"
                        Width="80"
                        Height="30"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Top"
                        Content="清除">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <cal:ActionMessage MethodName="ClearSecsLog" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                </Grid>
            </TabItem>-->

        </TabControl>

    </Grid>
</UserControl>
