<Window x:Class="RFID_Sample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:globalization="clr-namespace:System.Globalization;assembly=mscorlib"
        xmlns:local="clr-namespace:RFID_Sample"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:s="clr-namespace:System;assembly=mscorlib"
        xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
        xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
        mc:Ignorable="d"
        Closed="MainWindow_OnClosed"
        d:DesignHeight="1500"
        d:DesignWidth="1920"
        Name="RootWindow"
        Title="RFID Sample"
        MinHeight="600"
        MinWidth="1200"
        >

    <Window.Resources>
        <globalization:NumberFormatInfo x:Key="NumberFormatInfo" NumberDecimalDigits="0" />
        <Style TargetType="{x:Type Button}">
            <Setter Property="Background" Value="DodgerBlue" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontWeight" Value="Bold" />
        </Style>
        <Style TargetType="Expander">
            <Setter Property="FontSize" Value="15" />
            <Setter Property="Background" Value="DodgerBlue" />
            <Setter Property="Foreground" Value="White" />
        </Style>
        <Style TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="InputMethod.IsInputMethodEnabled" Value="False"/>
        </Style>
    </Window.Resources>

    <DockPanel>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="0.6*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                    <RowDefinition Height="1*" />
                </Grid.RowDefinitions>

                <ComboBox
                    x:Name="ComboBoxIPAddress"
                    Grid.Row="0"
                    Grid.RowSpan="1"
                    Grid.Column="0"
                    Grid.ColumnSpan="5"
                    Margin="5"
                    DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
                    FontSize="18"
                    ItemsSource="{Binding IpList, IsAsync=True}">
                </ComboBox>
                <Button
                    x:Name="Connect"
                    Grid.Row="0"
                    Grid.RowSpan="1"
                    Grid.Column="5"
                    Grid.ColumnSpan="2"
                    Margin="5"
                    Click="Connect_OnClick"
                    Content="Connect" />
                <TextBlock
                    x:Name="ConnectionStatusLabel"
                    Grid.Row="0"
                    Grid.RowSpan="1"
                    Grid.Column="7"
                    Grid.ColumnSpan="9"
                    VerticalAlignment="Center"
                    FontSize="20"
                    Text="No RFID reader is connected" />

                <Button
                    x:Name="SetProfile"
                    Grid.Row="1"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Margin="5"
                    Click="SetProfile_OnClick"
                    Content="Set Profile" />
                <TextBlock
                    x:Name="SetProfileLabel"
                    Grid.Row="1"
                    Grid.Column="2"
                    Grid.ColumnSpan="4"
                    VerticalAlignment="Center"
                    FontSize="18"
                    Text="Set the Profile to Profile 1" />

                <GroupBox
                    Grid.Row="0"
                    Grid.RowSpan="16"
                    Grid.Column="12"
                    Grid.ColumnSpan="4"
                    Background="White"
                    BorderThickness="0"
                    FontSize="20"
                    FontWeight="Bold"
                    Foreground="Black"
                    Header="Log">
                    <ListBox
                        x:Name="ListBoxLog"
                        
                        FontSize="12"
                        FontWeight="Normal"
                        
                        VirtualizingPanel.IsVirtualizing="True"
                        VirtualizingPanel.VirtualizationMode="Recycling" />
                </GroupBox>


                <TextBlock
                    x:Name="AntennaPowerLevelLable"
                    Grid.Row="2"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    FontSize="20"
                    Text="Antenna Power" />
                <ComboBox
                    x:Name="antennaPowerLevel"
                    Grid.Row="2"
                    Grid.Column="2"
                    Grid.ColumnSpan="1"
                    VerticalAlignment="Center"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    Foreground="Black">
                </ComboBox>

                <Button
                    x:Name="SetInventorySetting"
                    Grid.Row="3"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Margin="5"
                    Click="SetInventorySetting_OnClick"
                    Content="Setup inventory setting" />
                <Grid Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="7">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="1*" />
                    </Grid.RowDefinitions>

                    <TextBlock
                        Grid.Row="0"
                        VerticalAlignment="Center"
                        FontSize="15"
                        Text="For example: Antenna:1, DwellTime:500, Session:S0, Algorithm:DynamicQ, Q Value:5" Grid.ColumnSpan="2" Margin="0,4,0,3" />
                    <TextBlock
                        Grid.Row="1"
                        VerticalAlignment="Center"
                        FontSize="15"
                        Text="State Aware:SL, Toggle Targe:True, Target:A, RSSI Filter:0" Grid.ColumnSpan="2" Margin="0,4,0,3" />

                </Grid>
                <Button
                    x:Name="StartInventory"
                    Grid.Row="4"
                    Grid.Column="0"
                    Grid.ColumnSpan="2"
                    Margin="5"
                    Click="StartInventory_OnClick"
                    Content="Start Inventory">
                </Button>


                <Grid Grid.Column="0" Grid.ColumnSpan="6" Grid.Row="5" Grid.RowSpan="11">
                    <Grid.Resources>
                        <Style TargetType="{x:Type TextBox}">
                            <Setter Property="VerticalContentAlignment" Value="Center" />
                        </Style>
                    </Grid.Resources>
                    <Grid>
                        <DataGrid
                                    x:Name="tagDataGrid"
                                    AutoGenerateColumns="False"
                                    CanUserSortColumns="True"
                                    DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
                                    EnableColumnVirtualization="True"
                                    EnableRowVirtualization="True"
                                    HorizontalScrollBarVisibility="Visible"
                                    IsReadOnly="True"
                                    ItemsSource="{Binding ReceivedTagSet, IsAsync=True, Mode=OneWay}"
                                    SelectionMode="Single"
                                    Margin="5"
                                    VerticalScrollBarVisibility="Auto"
                                    VirtualizingPanel.IsVirtualizing="True"
                                    VirtualizingPanel.VirtualizationMode="Recycling">
                            <DataGrid.Columns>
                                <DataGridTextColumn Binding="{Binding EPC}" Header="EPC" />
                                <DataGridTextColumn Binding="{Binding Count}" Header="Count" />
                                <DataGridTextColumn Binding="{Binding RSSI}" Header="RSSI" />
                                <DataGridTextColumn Binding="{Binding PC}" Header="PC" />
                                <DataGridTextColumn Binding="{Binding LastSeen, StringFormat=\{0:HH:mm:ss\}}" Header="Last seen" />
                                <DataGridTextColumn Binding="{Binding FirstSeen, StringFormat=\{0:HH:mm:ss\}}" Header="First seen" />
                                <DataGridTextColumn Binding="{Binding Antenna}" Header="Antenna" />
                            </DataGrid.Columns>
                        </DataGrid>
                    </Grid>
                </Grid>

                <Grid Grid.Row="5" Grid.RowSpan="3" Grid.Column="6" Grid.ColumnSpan="6">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="1*" />
                        <RowDefinition Height="1*" />
                    </Grid.RowDefinitions>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock
                        Grid.Row="0"
                        Grid.Column="0"
                        Grid.ColumnSpan="9"
                        VerticalAlignment="Center"
                        FontSize="18"
                        Text="Read the tag with" />
                    <TextBlock
                        Grid.Row="1"
                        Grid.Column="0"
                        Grid.ColumnSpan="9"
                        VerticalAlignment="Center"
                        FontSize="18"
                        Text="Offset:2, Length:6, Bank:EPC, Password:00000000" />
                    <TextBlock
                        Grid.Row="2"
                        Grid.Column="0"
                        Grid.ColumnSpan="1"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Text="EPC" />
                    <TextBox
                        x:Name="ReadTagID"
                        Grid.Row="2"
                        Grid.Column="1"
                        Grid.ColumnSpan="5"
                        VerticalAlignment="Center"
                        FontSize="16"
                        IsReadOnly="False"
                        Text="{Binding Path=tagOpTagID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,ElementName=RootWindow}"/>
                    <TextBlock
                        Grid.Row="3"
                        Grid.Column="0"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        FontSize="16"
                        Text="Data" />
                    <TextBox
                        x:Name="ReadData"
                        Grid.Row="3"
                        Grid.Column="1"
                        Grid.ColumnSpan="5"
                        VerticalAlignment="Center"
                    
                        IsReadOnly="True"
                        FontSize="16"
                        Text="{Binding Path=tagOpData, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,ElementName=RootWindow}" />
                    <Button
                        Grid.Row="2"
                        Grid.RowSpan="2"
                        Grid.Column="6"
                        Grid.ColumnSpan="2"
                        Margin="5"
                        Click="TagOPRead_onClick"
                        Name="TagOPReadButton">
                        Read
                    </Button>

                </Grid>
            </Grid>

    </DockPanel>
</Window>
