<UserControl
    x:Class="SicUI.Controls.Parts.Wafer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Parts="clr-namespace:SicUI.Controls.Parts"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:SicUI.Controls.Parts"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    d:DesignHeight="300"
    d:DesignWidth="300"
    mc:Ignorable="d">
    <Grid x:Name="root">
        <Grid.ContextMenu>
            <ContextMenu>
                <MenuItem
                    Command="{Binding CreateDeleteWaferCommand}"
                    CommandParameter="CreateWafer"
                    Header="Create Wafer" />
                <MenuItem
                    Command="{Binding CreateDeleteWaferCommand}"
                    CommandParameter="DeleteWafer"
                    Header="Delete Wafer" />
            </ContextMenu>
        </Grid.ContextMenu>
        <Border
            Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}"
            Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}"
            Background="Transparent"
            Drop="Wafer_Drop"
            MouseMove="Wafer_MouseMove"
            Visibility="{Binding WaferStyle, Converter={StaticResource VisibilityConverter}}">
            <Border.AllowDrop>
                <MultiBinding Converter="{StaticResource WaferDropConverter}">
                    <Binding Path="WaferItem.Status" />
                    <Binding Path="WaferItem.IsDestination" />
                </MultiBinding>
            </Border.AllowDrop>
            <Border.ToolTip>
                <TextBlock>
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource WaferConverter}">
                            <Binding Path="WaferItem.Status" />
                            <Binding Path="WaferIDDisplayMode" />
                            <Binding Path="WaferItem.WaferOrigin" />
                            <Binding Path="WaferItem.LaserMarker" />
                            <Binding Path="WaferItem.T7Code" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
            </Border.ToolTip>
            <Ellipse
                Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}"
                Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}"
                Stretch="Fill"
                Stroke="#FF00641D"
                StrokeLineJoin="Round"
                StrokeThickness="0"
                Visibility="{Binding WaferItem.Status, Converter={StaticResource WaferVisibilityConverter}}">
                <Ellipse.Fill>
                    <MultiBinding Converter="{StaticResource WaferColorConverter}">
                        <Binding Path="WaferItem.Status" />
                        <Binding Path="WaferItem.ProcessState" />
                        <Binding Path="WaferItem.IsDestination" />
                        <Binding Path="WaferItem.IsSource" />
                    </MultiBinding>
                </Ellipse.Fill>
            </Ellipse>
        </Border>
        <Border
            Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}"
            Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualHeight}"
            Background="Transparent"
            BorderBrush="CadetBlue"
            BorderThickness="0"
            DragLeave="Border_DragLeave"
            DragOver="Border_DragOver"
            Drop="Wafer_Drop"
            MouseMove="Wafer_MouseMove"
            Visibility="{Binding WaferStyle, Converter={StaticResource VisibilityConverter}, ConverterParameter=0}">
            <Border.AllowDrop>
                <MultiBinding Converter="{StaticResource WaferDropConverter}">
                    <Binding Path="WaferItem.Status" />
                    <Binding Path="WaferItem.IsDestination" />
                </MultiBinding>
            </Border.AllowDrop>
            <Grid>
                <Parts:Slot
                    Margin="-158,0,0,0"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Visibility="{Binding ShowSlot, Converter={StaticResource BoolVisibilityConverter}}" />
                <Rectangle
                    x:Name="green"
                    Canvas.Left="16"
                    Width="146"
                    Height="14"
                    Stretch="Fill"
                    Stroke="{Binding WaferItem.Status, Converter={StaticResource WaferStatusConverter}}"
                    StrokeLineJoin="Round"
                    StrokeThickness="2"
                    Visibility="{Binding WaferItem.Status, Converter={StaticResource WaferVisibilityConverter}}">
                    <Rectangle.Fill>
                        <MultiBinding Converter="{StaticResource WaferColorConverter}">
                            <Binding Path="WaferItem.Status" />
                            <Binding Path="WaferItem.ProcessState" />
                            <Binding Path="WaferItem.IsDestination" />
                            <Binding Path="WaferItem.IsSource" />
                        </MultiBinding>
                    </Rectangle.Fill>
                </Rectangle>
                <TextBlock FontSize="8" Foreground="Black">
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource WaferConverter}">
                            <Binding Path="WaferItem.Status" />
                            <Binding Path="WaferIDDisplayMode" />
                            <Binding Path="WaferItem.WaferOrigin" />
                            <Binding Path="WaferItem.LaserMarker" />
                            <Binding Path="WaferItem.T7Code" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>
            </Grid>
        </Border>
    </Grid>
</UserControl>
