<UserControl
    x:Class="MECF.Framework.UI.Client.Ctrlib.UnitControls.FOUPFrontViewPro"
    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:converter="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Converter"
    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"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    mc:Ignorable="d">
    <UserControl.Resources>
        <converter:FOUPStatusConverter x:Key="FOUPStatusConverter" />
        <converter:WaferStatusConverter x:Key="WaferStatusConverter" />
    </UserControl.Resources>

    <Grid>
        <StackPanel>
            <TextBlock
                Width="110"
                Height="16"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                FontFamily="Arial"
                FontSize="14"
                Foreground="Black"
                Text="{Binding UnitData.ModuleID, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
                TextAlignment="Center"
                TextWrapping="Wrap" />
            <Border
                Width="310"
                Margin="0,5"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Background="{DynamicResource FOUP_OuterBG}"
                BorderBrush="{DynamicResource FOUP_OuterBD}"
                BorderThickness="1">
                <Grid>
                    <Rectangle Margin="5,5,5,5" Fill="{DynamicResource FOUP_InnerBG}" />
                    <Rectangle Margin="8,8,18,8" Fill="{DynamicResource FOUP_InnerGrow}">
                        <Rectangle.Effect>
                            <BlurEffect Radius="15" />
                        </Rectangle.Effect>
                    </Rectangle>
                    <Grid Margin="5,10,0,10">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="15" />
                            </Grid.ColumnDefinitions>
                            <TextBlock
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                FontFamily="Arial"
                                FontSize="12"
                                Text="{Binding UnitData.Status, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource FOUPStatusConverter}}"
                                TextAlignment="Center"
                                TextWrapping="Wrap" />
                        </Grid>
                        <StackPanel Grid.Row="1" VerticalAlignment="Top">
                            <ListBox
                                ItemContainerStyle="{DynamicResource NoSelection_ListBoxItem}"
                                ItemsSource="{Binding UnitData.WaferManager.Wafers, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
                                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                ScrollViewer.VerticalScrollBarVisibility="Disabled">

                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Height="24">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="25" />
                                                <ColumnDefinition Width="250" />
                                                <ColumnDefinition Width="15" />
                                            </Grid.ColumnDefinitions>
                                            <CheckBox
                                                HorizontalAlignment="Center"
                                                IsChecked="{Binding IsChecked}"
                                                IsEnabled="{Binding WaferStatus, Converter={StaticResource WaferStatusConverter}}" />
                                            <Rectangle
                                                Grid.Column="1"
                                                Width="30"
                                                Height="4"
                                                HorizontalAlignment="Left"
                                                VerticalAlignment="Bottom"
                                                Fill="{DynamicResource FOUP_PathBG}">
                                                <Rectangle.Effect>
                                                    <DropShadowEffect
                                                        BlurRadius="0"
                                                        Direction="270"
                                                        ShadowDepth="1" />
                                                </Rectangle.Effect>
                                            </Rectangle>
                                            <Rectangle
                                                Grid.Column="1"
                                                Width="30"
                                                Height="4"
                                                HorizontalAlignment="Right"
                                                VerticalAlignment="Bottom"
                                                Fill="{DynamicResource FOUP_PathBG}">
                                                <Rectangle.Effect>
                                                    <DropShadowEffect
                                                        BlurRadius="0"
                                                        Direction="270"
                                                        ShadowDepth="1" />
                                                </Rectangle.Effect>
                                            </Rectangle>
                                            <controls:Slot
                                                x:Name="SlotCls"
                                                Grid.Column="1"
                                                Margin="0,9,0,0"
                                                HorizontalAlignment="Center"
                                                VerticalAlignment="Top"
                                                ModuleID="{Binding ModuleID}"
                                                SlotID="{Binding SlotID}"
                                                SourceName="{Binding SourceName}"
                                                ViewType="Front"
                                                WaferStatus="{Binding WaferStatus}">
                                                <i:Interaction.Triggers>
                                                    <i:EventTrigger EventName="SlotMouseButtonDown">
                                                        <micro:ActionMessage MethodName="OnMouseUp">
                                                            <micro:Parameter Value="$source" />
                                                            <micro:Parameter Value="$eventargs" />
                                                        </micro:ActionMessage>
                                                    </i:EventTrigger>
                                                    <i:EventTrigger EventName="WaferTransferStarted">
                                                        <micro:ActionMessage MethodName="OnWaferTransfer">
                                                            <micro:Parameter Value="$eventargs" />
                                                        </micro:ActionMessage>
                                                    </i:EventTrigger>
                                                </i:Interaction.Triggers>
                                            </controls:Slot>
                                            <TextBlock
                                                x:Name="Foup_Text"
                                                Grid.Column="2"
                                                Width="13"
                                                HorizontalAlignment="Center"
                                                VerticalAlignment="Bottom"
                                                Background="#FF646464"
                                                FontFamily="Arial"
                                                FontSize="10"
                                                Foreground="White"
                                                Text="{Binding SlotIndex}"
                                                TextAlignment="Center"
                                                TextWrapping="Wrap" />
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="True">
                                                <Setter TargetName="Foup_Text" Property="Foreground" Value="White" />
                                                <Setter TargetName="Foup_Text" Property="FontWeight" Value="Bold" />
                                                <Setter TargetName="Foup_Text" Property="FontSize" Value="11" />
                                                <Setter TargetName="Foup_Text" Property="Background" Value="Green" />
                                            </Trigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Border>
            <StackPanel.Style>
                <Style>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding UnitData.IsInstalled, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="False">
                            <Setter Property="StackPanel.Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Style>
        </StackPanel>
    </Grid>
</UserControl>
