<UserControl x:Class="SicUI.Controls.LoadLock"
             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:SicUI.Controls"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:cal="http://www.caliburn.org"     
             xmlns:controls="http://OpenSEMI.Ctrlib.com/presentation"
             xmlns:ctrl="http://OpenSEMI.Ctrlib.com/presentation"
             mc:Ignorable="d">
    <UserControl.Resources>
        <Storyboard x:Key="Door_Open">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" >
                <EasingDoubleKeyFrame KeyTime="0" Value="29"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Door_Close">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" >
                <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="29"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Door_Unknown">
            <DoubleAnimation Storyboard.TargetProperty="(FrameworkElement.Height)" To="20" >
            </DoubleAnimation>
            <ColorAnimation Storyboard.TargetProperty="(Fill).(SolidColorBrush.Color)" To="Red" >
            </ColorAnimation>
        </Storyboard>

        <Storyboard x:Key="Wafer_Up">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Top)" >
                <EasingDoubleKeyFrame KeyTime="0" Value="13"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-5"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="Wafer_Down">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(Canvas.Top)" >
                <EasingDoubleKeyFrame KeyTime="0" Value="-5"/>
                <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="13"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Style TargetType="{x:Type Rectangle}" x:Key="ATM_Animation" >
            <Style.Triggers>
                <DataTrigger Binding="{Binding ATMDoorStatus, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="Open">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource Door_Open}"/>
                    </DataTrigger.EnterActions>
                    <DataTrigger.ExitActions>
                        <BeginStoryboard Storyboard="{StaticResource Door_Close}"/>
                    </DataTrigger.ExitActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style TargetType="{x:Type Rectangle}" x:Key="SlitValve_Animation" >
            <Style.Triggers>
                <DataTrigger Binding="{Binding SlitValveStatus, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="Open">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource Door_Open}"/>
                    </DataTrigger.EnterActions>
                    <DataTrigger.ExitActions>
                        <BeginStoryboard Storyboard="{StaticResource Door_Close}"/>
                    </DataTrigger.ExitActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style TargetType="{x:Type TextBlock}" x:Key="Text_Online" >
            <Style.Triggers>
                <DataTrigger Binding="{Binding UnitData.IsOnline, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="True">
                    <Setter Property="Foreground" Value="{DynamicResource FG_Green}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding UnitData.IsOnline, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="False">
                    <Setter Property="Foreground" Value="{DynamicResource FG_Black}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="100"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="15"/>
            <ColumnDefinition />
            <ColumnDefinition Width="15"/>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.ColumnSpan="3" FontFamily="Arial" FontSize="14" Style="{StaticResource Text_Online}"   VerticalAlignment="Center" HorizontalAlignment="Center" Visibility="Collapsed">              
             <Run Text="{Binding UnitData.ModuleID, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"/>
             <Run Text=" Front View"/>
        </TextBlock>
        <TextBlock Grid.Row="1" Text="ATM Door" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource FG_Black}">
            <TextBlock.LayoutTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform Angle="-90"/>
                    <TranslateTransform/>
                </TransformGroup>
            </TextBlock.LayoutTransform>
        </TextBlock>
        <TextBlock Grid.Row="1" Grid.Column="2" Text="Slit Valve" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Arial" FontSize="12" Foreground="{DynamicResource FG_Black}">
            <TextBlock.LayoutTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform Angle="90"/>
                    <TranslateTransform/>
                </TransformGroup>
            </TextBlock.LayoutTransform>
        </TextBlock>
        <Border Grid.Column="1" Grid.Row="1" BorderThickness="1" BorderBrush="{DynamicResource FOUP_OuterBD}" Background="{DynamicResource FOUP_OuterBG}" Width="150">
            <Grid>
                <Rectangle Fill="{DynamicResource FOUP_InnerBG}" Margin="15,5,10,5"/>
                <Rectangle Fill="{DynamicResource FOUP_InnerBG}" Margin="0,25,0,15"/>
                <Rectangle Fill="{DynamicResource FOUP_InnerGrow}" Margin="18,8,13,8">
                    <Rectangle.Effect>
                        <BlurEffect Radius="15"/>
                    </Rectangle.Effect>
                </Rectangle>
                <Rectangle Fill="{DynamicResource FOUP_InnerGrow}" Margin="3,28,3,18">
                    <Rectangle.Effect>
                        <BlurEffect Radius="15"/>
                    </Rectangle.Effect>
                </Rectangle>
                <Grid Margin="15,10,10,10">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Grid>
                        <TextBlock TextWrapping="NoWrap" Text="" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Arial" FontSize="12" TextAlignment="Center" />
                    </Grid>
                    <Canvas Grid.Row="1">
                        <StackPanel x:Name="LoadLock_Body" Grid.Row="1" Width="123" Canvas.Left="0" Canvas.Top="-5">
                            <Grid Height="22">
                                <Rectangle Height="4" Width="20" HorizontalAlignment="Left" Fill="{DynamicResource FOUP_PathBG}" VerticalAlignment="Bottom" >
                                    <Rectangle.Effect>
                                        <DropShadowEffect Direction="270" BlurRadius="0" ShadowDepth="1"/>
                                    </Rectangle.Effect>
                                </Rectangle>
                                <Rectangle Height="4" Width="30" HorizontalAlignment="Right" Fill="{DynamicResource FOUP_PathBG}" VerticalAlignment="Bottom" >
                                    <Rectangle.Effect>
                                        <DropShadowEffect Direction="270" BlurRadius="0" ShadowDepth="1"/>
                                    </Rectangle.Effect>
                                </Rectangle>
                                <ctrl:Slot ViewType="Front" x:Name="LL2" DataContext="{Binding UnitData.WaferManager.Wafers[1], RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" WaferStatus="{Binding WaferStatus}" SlotID="{Binding SlotID}" ModuleID="{Binding ModuleID}" SourceName="{Binding SourceName}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,6,11,0">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="SlotMouseButtonDown">
                                            <cal:ActionMessage MethodName="OnMouseUp">
                                                <cal:Parameter Value="$source" />
                                                <cal:Parameter Value="$eventargs" />
                                            </cal:ActionMessage>
                                        </i:EventTrigger>
                                        <i:EventTrigger EventName="WaferTransferStarted">
                                            <cal:ActionMessage MethodName="OnWaferTransfer">
                                                <cal:Parameter Value="$eventargs" />
                                            </cal:ActionMessage>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </ctrl:Slot>
                                <TextBlock x:Name="LL_Text1" HorizontalAlignment="Right" Margin="0,0,0,4" TextWrapping="NoWrap" Text="2" Background="#FF646464" Foreground="White" VerticalAlignment="Bottom" FontFamily="Arial" FontSize="10" Width="13" TextAlignment="Center">
                                </TextBlock>
                            </Grid>
                            <Grid Height="22">
                                <Rectangle Height="4" Width="20" HorizontalAlignment="Left" Fill="{DynamicResource FOUP_PathBG}" VerticalAlignment="Bottom" >
                                    <Rectangle.Effect>
                                        <DropShadowEffect Direction="270" BlurRadius="0" ShadowDepth="1"/>
                                    </Rectangle.Effect>
                                </Rectangle>
                                <Rectangle Height="4" Width="30" HorizontalAlignment="Right" Fill="{DynamicResource FOUP_PathBG}" VerticalAlignment="Bottom" >
                                    <Rectangle.Effect>
                                        <DropShadowEffect Direction="270" BlurRadius="0" ShadowDepth="1"/>
                                    </Rectangle.Effect>
                                </Rectangle>
                                <ctrl:Slot ViewType="Front" DataContext="{Binding UnitData.WaferManager.Wafers[0], RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"  WaferStatus="{Binding WaferStatus}" SlotID="{Binding SlotID}" ModuleID="{Binding ModuleID}" SourceName="{Binding SourceName}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,6,11,0">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="SlotMouseButtonDown">
                                            <cal:ActionMessage MethodName="OnMouseUp">
                                                <cal:Parameter Value="$source" />
                                                <cal:Parameter Value="$eventargs" />
                                            </cal:ActionMessage>
                                        </i:EventTrigger>
                                        <i:EventTrigger EventName="WaferTransferStarted">
                                            <cal:ActionMessage MethodName="OnWaferTransfer">
                                                <cal:Parameter Value="$eventargs" />
                                            </cal:ActionMessage>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </ctrl:Slot>
                                <TextBlock x:Name="LL_Text2" HorizontalAlignment="Right" Margin="0,0,0,4" TextWrapping="NoWrap" Text="1" Background="#FF646464" Foreground="White" VerticalAlignment="Bottom" FontFamily="Arial" FontSize="10" Width="13" TextAlignment="Center">
                                </TextBlock>
                            </Grid>
                            <StackPanel.Style>
                                <Style>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding CurrentSlot, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="1">
                                            <DataTrigger.EnterActions>
                                                <BeginStoryboard Storyboard="{StaticResource Wafer_Down}"/>
                                            </DataTrigger.EnterActions>
                                            <DataTrigger.ExitActions>
                                                <BeginStoryboard Storyboard="{StaticResource Wafer_Up}"/>
                                            </DataTrigger.ExitActions>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </StackPanel.Style>
                        </StackPanel>
                    </Canvas>
                </Grid>
                <Grid Margin="1,25,1,15">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="8"/>
                        <ColumnDefinition />
                        <ColumnDefinition Width="4"/>
                    </Grid.ColumnDefinitions>
                    <Grid x:Name="ATM_Door">
                        <Rectangle x:Name="ATMDoor_Top" Style="{StaticResource ATM_Animation}" Fill="Black" Width="8" VerticalAlignment="Top" Height="29" />
                        <Rectangle x:Name="ATMDoor_Bottom" Style="{StaticResource ATM_Animation}" Fill="Black" Width="8" VerticalAlignment="Bottom" Height="29" />
                    </Grid>
                    <Grid x:Name="Slit_valve" Grid.Column="2">
                        <Rectangle x:Name="SlitValve_Top" Style="{StaticResource SlitValve_Animation}" Fill="Black" Width="8" VerticalAlignment="Top" Height="29"/>
                        <Rectangle x:Name="SlitValve_Bottom" Style="{StaticResource SlitValve_Animation}" Fill="Black" Width="8" VerticalAlignment="Bottom" Height="29"/>
                    </Grid>
                </Grid>
            </Grid>
        </Border>
    </Grid>
</UserControl>
