<UserControl x:Class="CyberX8_Simulator.Views.WagoView"
             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_Simulator.Views"
             xmlns:commons="clr-namespace:MECF.Framework.Simulator.Core.Commons;assembly=MECF.Framework.Simulator.Core"
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
             mc:Ignorable="d" 
             d:DesignHeight="900"  d:DesignWidth="1200">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100"></RowDefinition>
            <RowDefinition Height="100"></RowDefinition>
            <RowDefinition />
            <RowDefinition Height="10"></RowDefinition>
        </Grid.RowDefinitions>

        <commons:SocketTitleView Grid.Row="0"></commons:SocketTitleView>
        <Canvas Grid.Row="1"  Width="1200">
            <StackPanel Orientation="Horizontal" Width="1200">
                <Button Content="Clear Log" Width="100" Height="35"   Command="{Binding ClearLogCommand}"></Button>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Width="600" Height="50" Canvas.Left="120">
                <Label Content="DO:" VerticalAlignment="Center"></Label>
                <ComboBox  Width="250" Height="30" VerticalContentAlignment="Center" ItemsSource="{Binding DONameItems}" SelectedItem="{Binding DOSelectedItem}" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding DOSelectionChangedCommand}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </ComboBox>
                <ComboBox  Width="100" Height="30" Margin="5,0,0,0" VerticalContentAlignment="Center" ItemsSource="{Binding DigitalInputSelected}" SelectedItem="{Binding DOInputValue}" HorizontalContentAlignment="Center"></ComboBox>
                <Button Content="DOInput" Height="30" Width="100" Margin="5,10,0,0" Command="{Binding SetDOCommand}"/>
                <Border Margin="5,0,0,0" Background="Black" Height="30" Width="80">
                    <TextBlock Text="{Binding DOCurrentValue}" Foreground="Lime"   FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </StackPanel>
            
            <StackPanel Orientation="Horizontal" Width="600" Height="50" Canvas.Left="740">
                <Label Content="DI:" VerticalAlignment="Center"></Label>
                <ComboBox  Width="250" Height="30" VerticalContentAlignment="Center" ItemsSource="{Binding DINameItems}" SelectedItem="{Binding DISelectedItem}" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding DISelectionChangedCommand}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </ComboBox>
                <ComboBox  Width="100" Height="30" Margin="5,0,0,0" VerticalContentAlignment="Center" ItemsSource="{Binding DigitalInputSelected}" SelectedItem="{Binding DIInputValue}" HorizontalContentAlignment="Center"></ComboBox>
                <Button Content="DIInput" Height="30" Width="100" Margin="5,10,0,0" Command="{Binding SetDICommand}"/>
                <Border Margin="5,0,0,0" Background="Black" Height="30" Width="80">
                    <TextBlock Text="{Binding DICurrentValue}" Foreground="Lime"   FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Width="600" Height="50" Canvas.Top="50" Canvas.Left="120">
                <Label Content="AO:" VerticalAlignment="Center"></Label>
                <ComboBox  Width="250" Height="30" VerticalContentAlignment="Center" ItemsSource="{Binding AONameItems}" SelectedItem="{Binding AOSelectedItem}" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding AOSelectionChangedCommand}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </ComboBox>
                <TextBox Text="{Binding AOInputValue,Mode=OneWayToSource}" Width="100" Height="30" Margin="5,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></TextBox>
                <Button Content="AOInput" Height="30" Width="100" Margin="5,10,0,0" Command="{Binding SetAOCommand}"/>
                <Border Margin="5,0,0,0" Background="Black" Height="30" Width="80">
                    <TextBlock Text="{Binding AOCurrentValue}" Foreground="Lime"   FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Width="600" Height="50" Canvas.Top="50" Canvas.Left="740">
                <Label Content="AI:" VerticalAlignment="Center"></Label>
                <ComboBox  Width="250" Height="30" VerticalContentAlignment="Center" ItemsSource="{Binding AINameItems}" SelectedItem="{Binding AISelectedItem}" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding AISelectionChangedCommand}"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </ComboBox>
                <TextBox Text="{Binding AIInputValue,Mode=OneWayToSource}" Width="100" Height="30" Margin="5,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></TextBox>
                <Button Content="AIInput" Height="30" Width="100" Margin="5,10,0,0" Command="{Binding SetAICommand}"/>
                <Border Margin="5,0,0,0" Background="Black" Height="30" Width="80">
                    <TextBlock Text="{Binding AICurrentValue}" Foreground="Lime"   FontSize="16" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
            </StackPanel>

        </Canvas>
        <DataGrid Grid.Row="2" FontSize="16" AutoGenerateColumns="False" CanUserAddRows="False" CanUserResizeRows="False" CanUserSortColumns="False"
              ItemsSource="{Binding TransactionLogItems}"
                  Width="1200" VerticalAlignment="Top" MaxHeight="780">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Time" Width="200" IsReadOnly="True" Binding="{Binding OccurTime, UpdateSourceTrigger=PropertyChanged}" />
                <DataGridTextColumn Header="Incoming" Width="500" IsReadOnly="True"  Binding="{Binding Incoming, UpdateSourceTrigger=PropertyChanged}">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextWrapping" Value="Wrap" />
                            <Setter Property="Height" Value="auto" />
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
                <DataGridTextColumn Header="Outgoing" Width="500" IsReadOnly="True"  Binding="{Binding Outgoing, UpdateSourceTrigger=PropertyChanged}">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextWrapping" Value="Wrap" />
                            <Setter Property="Height" Value="auto" />
                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</UserControl>