<UserControl x:Class="CyberX8_Themes.UserControls.FOUPFrontView"
             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:CyberX8_Themes.UserControls"
             xmlns:converter="clr-namespace:CyberX8_Themes.Converters"
             xmlns:controls="http://OpenSEMI.Ctrlib.com/presentation"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" Name="FoupView">

    <UserControl.Resources>
        <converter:FOUPStatusConverter x:Key="FOUPStatusConverter"/>
    </UserControl.Resources>
    <Grid>
        <StackPanel>
            <TextBlock Text="{Binding UnitData.ModuleData.ModuleID, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" FontFamily="Arial" Width="90" Height="13" TextAlignment="Center" FontSize="8" 
                       TextWrapping="Wrap" FontWeight="{Binding UnitData.UnitFontWeight, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" 
                       Foreground="{Binding UnitData.UnitNameForeground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding ShowTitle, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}},Converter={StaticResource bool2VisibilityConverter}}">
            </TextBlock>
            <Border BorderThickness="1" BorderBrush="{DynamicResource FOUP_OuterBD}" Background="{DynamicResource FOUP_OuterBG}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="130" Margin="0,0,0,5">
                <Grid>
                    <Rectangle Fill="{DynamicResource FOUP_InnerBG}" Margin="5,5,15,5"/>
                    <Rectangle Fill="{DynamicResource FOUP_InnerGrow}" Margin="8,8,18,8">
                        <Rectangle.Effect>
                            <BlurEffect Radius="15"/>
                        </Rectangle.Effect>
                    </Rectangle>
                    <Grid Margin="5,0,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid>
                            <TextBlock TextWrapping="Wrap" Text="{Binding UnitData.Status, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}},Converter={StaticResource FOUPStatusConverter}}" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Arial" FontSize="12" TextAlignment="Center" />
                        </Grid>
                        <StackPanel Grid.Row="1" VerticalAlignment="Top" Margin="0,5,0,2">
                            <ListBox ItemsSource="{Binding UnitData.WaferManager.Wafers, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Height="15">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="108"/>
                                                <ColumnDefinition Width="15"/>
                                            </Grid.ColumnDefinitions>
                                            <Rectangle  Height="2" Width="30" HorizontalAlignment="Left" Fill="{DynamicResource FOUP_PathBG}" VerticalAlignment="Bottom" >
                                                <Rectangle.Effect>
                                                    <DropShadowEffect Direction="270" BlurRadius="0" ShadowDepth="1"/>
                                                </Rectangle.Effect>
                                            </Rectangle>
                                            <Rectangle Height="2" Width="30" HorizontalAlignment="Right" Fill="{DynamicResource FOUP_PathBG}" VerticalAlignment="Bottom" >
                                                <Rectangle.Effect>
                                                    <DropShadowEffect Direction="270" BlurRadius="0" ShadowDepth="1"/>
                                                </Rectangle.Effect>
                                            </Rectangle>
                                            <controls:Slot ViewType="Front"  WaferStatus="{Binding WaferStatus}" SlotID="{Binding SlotID}" ModuleID="{Binding ModuleID}" 
                                                           SourceName="{Binding SourceName}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,1,0,0" SlotWidth="{Binding ElementName=FoupView,Path=SlotWidth}" 
                                                           SlotMouseButtonDown="Slot_SlotMouseButtonDown" WaferTransferStarted="Slot_WaferTransferStarted" FontFamily="Arial" FontSize="2">
                                            </controls:Slot>
                                            <TextBlock x:Name="Foup_Text" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" TextWrapping="Wrap" Text="{Binding SlotIndex}" Background="#FF646464" Foreground="White" FontFamily="Arial" FontSize="9" Width="13" TextAlignment="Center" >
                                            </TextBlock>
                                        </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 IsCassettePlaced, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="False">
                            <Setter  Property ="StackPanel.Visibility" Value="Collapsed"></Setter>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Style>
        </StackPanel>
    </Grid>
</UserControl>