<UserControl
    x:Class="MECF.Framework.Simulator.Core.LoadPorts.TKPMView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:commons="clr-namespace:MECF.Framework.Simulator.Core.Commons"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:deviceControl="clr-namespace:MECF.Framework.UI.Core.DeviceControl;assembly=MECF.Framework.UI.Core"
    xmlns:local="clr-namespace:MECF.Framework.Simulator.Core.Aligners"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Width="900"
    Height="900">
    <UserControl.Resources>
        <DataTemplate x:Key="DataTemplate1">
            <StackPanel
                Width="200"
                Height="15"
                Orientation="Horizontal">
                <TextBox Text="{Binding Index}" />
                <TextBox Text="{Binding State}" />
                <Button
                    Width="100"
                    Height="15"
                    Margin="0"
                    VerticalAlignment="Center"
                    Background="LightBlue"
                    Content="{Binding State}" />
                <TextBox Text="{Binding Index}" />

            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100" />
            <RowDefinition Height="350" />
            <RowDefinition Height="50" />
            <RowDefinition Height="400" />
        </Grid.RowDefinitions>

        <commons:SerialPortTitleView Grid.Row="0" />

        <Canvas
            Grid.Row="1"
            Width="900"
            Height="350">
            <Label
                Canvas.Left="32"
                Canvas.Top="50"
                Width="300"
                Height="30"
                HorizontalContentAlignment="Center"
                Background="LightBlue"
                BorderThickness="2"
                Content="{Binding WaferMap}" />
            <Label
                Canvas.Left="32"
                Canvas.Top="197"
                Width="161"
                Height="30"
                HorizontalContentAlignment="Center"
                Background="Transparent"
                BorderThickness="2"
                Content="InfoPad Status" />

            <Label
                Canvas.Left="198"
                Canvas.Top="194"
                Width="82"
                Height="41"
                HorizontalContentAlignment="Center"
                Background="LightBlue"
                BorderThickness="2"
                Content="{Binding InfoPadStatus}" />

            <TextBox
                Canvas.Left="285"
                Canvas.Top="198"
                Width="69"
                Height="38"
                Margin="0"
                IsReadOnly="False"
                RenderTransformOrigin="0.471,-0.188"
                Text="{Binding InfoPadSet}" />
            <Button
                Canvas.Left="400"
                Canvas.Top="194"
                Width="138"
                Height="42"
                Margin="0"
                Command="{Binding SetInfoPadCommand}"
                Content="SetInfoPad" />

            <Button
                Canvas.Left="10"
                Canvas.Top="136"
                Width="100"
                Height="35"
                Margin="0"
                Command="{Binding PlaceCommand}"
                Content="Place" />
            <Button
                Canvas.Left="141"
                Canvas.Top="136"
                Width="100"
                Height="35"
                Margin="0"
                Command="{Binding RemoveCommand}"
                Content="Remove" />

            <ItemsControl
                Canvas.Left="576"
                Width="300"
                Height="300"
                Background="LightGray"
                ItemTemplate="{DynamicResource DataTemplate1}"
                ItemsSource="{Binding WaferList}" />

            <Button
                Canvas.Left="513"
                Canvas.Top="305"
                Width="100"
                Height="35"
                Margin="0"
                Command="{Binding SetAllCommand}"
                Content="SetAll" />
            <Button
                Canvas.Left="646"
                Canvas.Top="305"
                Width="100"
                Height="35"
                Margin="0"
                Command="{Binding RandomCommand}"
                Content="Random" />
            <Button
                Canvas.Left="766"
                Canvas.Top="305"
                Width="100"
                Height="35"
                Margin="0"
                Command="{Binding ClearCommand}"
                Content="Clear" />

        </Canvas>


        <StackPanel
            Grid.Row="2"
            Width="900"
            Orientation="Horizontal">
            <Button
                Width="100"
                Height="35"
                Command="{Binding ClearLogCommand}"
                Content="Clear Log" />

        </StackPanel>


        <DataGrid
            Grid.Row="3"
            Width="900"
            Height="380"
            VerticalAlignment="Top"
            AutoGenerateColumns="False"
            CanUserAddRows="False"
            CanUserResizeRows="False"
            CanUserSortColumns="False"
            FontSize="16"
            ItemsSource="{Binding TransactionLogItems}"
            ScrollViewer.CanContentScroll="True"
            ScrollViewer.HorizontalScrollBarVisibility="Auto"
            ScrollViewer.VerticalScrollBarVisibility="Auto">
            <DataGrid.Columns>

                <DataGridTextColumn
                    Width="160"
                    Binding="{Binding OccurTime, UpdateSourceTrigger=PropertyChanged}"
                    Header="Time"
                    IsReadOnly="True" />

                <DataGridTextColumn
                    Width="350"
                    Binding="{Binding Incoming, UpdateSourceTrigger=PropertyChanged}"
                    Header="Incoming"
                    IsReadOnly="True">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextWrapping" Value="Wrap" />
                            <Setter Property="Height" Value="auto" />
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>


                <DataGridTextColumn
                    Width="350"
                    Binding="{Binding Outgoing, UpdateSourceTrigger=PropertyChanged}"
                    Header="Outgoing"
                    IsReadOnly="True">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextWrapping" Value="Wrap" />
                            <Setter Property="Height" Value="auto" />
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>

            </DataGrid.Columns>
        </DataGrid>
    </Grid>

</UserControl>