<Page
    x:Class="testApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:testApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Width="640" Height="480">

    <Page.DataContext>
        <local:ReaderViewModel/>
    </Page.DataContext>
    
    <Page.Resources>
        <local:ConverterIsConnecting x:Key="IsConnecting"/>
        <local:ConverterIsConnected x:Key="IsConnected"/>
        <local:ConverterConnStateToBoolForButtonEnable x:Key="ButtonEnable"/>
        <local:ConverterConnStateToString x:Key="ConnStateToString"/>
    </Page.Resources>
    
    <Grid Margin="10,10,10,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <ListView Margin="0,0,0,193" ItemsSource="{Binding Path=TagList}">
            <ListView.Header>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.2*"/>
                        <ColumnDefinition Width="0.6*"/>
                        <ColumnDefinition Width="0.2*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Column="0" Text="No" HorizontalAlignment="Center"/>
                    <TextBlock Grid.Column="1" Text="Data" HorizontalAlignment="Center"/>
                    <TextBlock Grid.Column="2" Text="#" HorizontalAlignment="Center"/>
                </Grid>
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="0.2*"/>
                            <ColumnDefinition Width="0.6*"/>
                            <ColumnDefinition Width="0.2*"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{Binding No}" TextAlignment="Center"/>
                        <TextBlock Grid.Column="1" Text="{Binding Data}" TextAlignment="Center"/>
                        <TextBlock Grid.Column="2" Text="{Binding Count}" TextAlignment="Center"/>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    <Setter Property="MinHeight" Value="10"/>
                    <Setter Property="Height" Value="20"/>

                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <TextBlock HorizontalAlignment="Left" Margin="426,272,0,0" Text="Total :" TextWrapping="Wrap" VerticalAlignment="Top"/>
        <TextBlock HorizontalAlignment="Right" Margin="488,272,0,0" 
                   Text="{Binding Path=TotalCount}" TextWrapping="Wrap" VerticalAlignment="Top" Width="114" Height="28"/>
        <ComboBox HorizontalAlignment="Left" Margin="4,422,0,0" VerticalAlignment="Top" Width="94" 
                  SelectedIndex="{Binding Path=DeviceIndex, Mode=TwoWay}">
            <ComboBoxItem Content="AT188N"/>
            <ComboBoxItem Content="AT388"/>
            <ComboBoxItem Content="ATS100"/>
            <ComboBoxItem Content="ATD100"/>
        </ComboBox>
        <TextBox HorizontalAlignment="Left" Margin="103,422,0,0" 
                 Text="{Binding Path=PortName, Mode=TwoWay}"
                 VerticalAlignment="Top" Width="82"/>

        <Button Command="{Binding ConnectClick}"
                Content="{Binding Path=ConnectStateTextForButton}"
                IsEnabled="True"
                HorizontalAlignment="Left" VerticalAlignment="Top" 
                Height="32" Width="100" Margin="191,422,0,0" RenderTransformOrigin="-5.138,-8.156"/>
        <Button Command="{Binding InventoryClick}"
                Content="{Binding Path=InventoryStateTextForButton}" 
                HorizontalAlignment="Left" VerticalAlignment="Top" 
                Height="32" Width="100" Margin="300,422,0,0" RenderTransformOrigin="-5.138,-8.156"
                IsEnabled="{Binding Path=ConnState, Converter={StaticResource IsConnected}}"/>
        <Button Command="{Binding DecodeClick}"
                Content="{Binding Path=DecodeStateTextForButton}" 
                HorizontalAlignment="Left" VerticalAlignment="Top" 
                Height="32" Width="100" Margin="407,422,0,0" RenderTransformOrigin="-5.138,-8.156"
                IsEnabled="{Binding Path=ConnState, Converter={StaticResource IsConnected}}"/>
        <Button Command="{Binding ClearClick}"
                Content="Clear" HorizontalAlignment="Left" VerticalAlignment="Top" 
                Height="32" Width="100" Margin="513,422,0,0" RenderTransformOrigin="-5.138,-8.156"/>

        <ProgressRing HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="230,164,251,180"
                      IsActive="{Binding Path=ConnState, Converter={StaticResource IsConnecting}}"/>
        <Grid HorizontalAlignment="Left" Height="60" Margin="5,341,0,0" VerticalAlignment="Top" Width="167">
            <TextBlock HorizontalAlignment="Left" Margin="12,4,0,0" Text="Connection State" TextWrapping="Wrap" VerticalAlignment="Top"/>
            <TextBox HorizontalAlignment="Left" Margin="5,25,0,0" VerticalAlignment="Top" Width="152" IsReadOnly="True"
                     Text="{Binding Path=ConnState}"/>
        </Grid>
        <Grid HorizontalAlignment="Left" Height="60" Margin="191,341,0,0" VerticalAlignment="Top" Width="167">
            <TextBlock HorizontalAlignment="Left" Margin="12,4,0,0" Text="Action State" TextWrapping="Wrap" VerticalAlignment="Top"/>
            <TextBox HorizontalAlignment="Center" Margin="5,25,0,0" VerticalAlignment="Top" Width="152" IsReadOnly="True"
                     Text="{Binding Path=ActState}"/>
        </Grid>
        <Grid HorizontalAlignment="Left" Height="60" Margin="396,341,0,0" VerticalAlignment="Top" Width="167">
            <TextBlock HorizontalAlignment="Left" Margin="12,4,0,0" Text="Battery State" TextWrapping="Wrap" VerticalAlignment="Top"/>
            <TextBox HorizontalAlignment="Left" Margin="5,25,0,0" VerticalAlignment="Top" Width="152" IsReadOnly="True"
                     Text="{Binding Path=BattState}"/>
        </Grid>
        <Grid HorizontalAlignment="Left" Height="60" Margin="5,282,0,0" VerticalAlignment="Top" Width="167">
            <TextBlock HorizontalAlignment="Left" Margin="12,4,0,0" Text="Firmware" TextWrapping="Wrap" VerticalAlignment="Top"/>
            <TextBox HorizontalAlignment="Left" Margin="5,25,0,0" VerticalAlignment="Top" Width="152" IsReadOnly="True"
                     Text="{Binding Path=Version}"/>
        </Grid>
        <Grid HorizontalAlignment="Left" Height="60" Margin="197,282,0,0" VerticalAlignment="Top" Width="167">
            <TextBlock HorizontalAlignment="Left" Margin="12,4,0,0" Text="Serial Number" TextWrapping="Wrap" VerticalAlignment="Top"/>
            <TextBox HorizontalAlignment="Left" Margin="5,25,0,0" VerticalAlignment="Top" Width="152" IsReadOnly="True"
                     Text="{Binding Path=SerialNumber}"/>
        </Grid>










    </Grid>

</Page>
