<Page x:Name="Page_Inventory"
    x:Class="Zebra_RFID_Mobile.PageInventory"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Zebra_RFID_Mobile"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <Flyout x:Name="InventoryFlyout" x:Key="InventoryFlyout">
            <TextBlock x:Name="TextInventoryStatus" FontSize="22" VerticalAlignment="Center" Margin="0,0,0,10" Width="340" TextWrapping="Wrap" HorizontalAlignment="Center" Height="80"/>
        </Flyout>
    </Page.Resources>
    <Page.BottomAppBar>
        <CommandBar >
            <CommandBar.PrimaryCommands>
                <AppBarButton x:Name="AppBarButtonRapidRead" x:Uid="RapidRead" Label="RapidRead" Click="AppBarButtonGoToRapidRead">
                    <AppBarButton.Icon>
                        <BitmapIcon UriSource="Assets/tab_rapidread.png"/>
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarButton x:Name="AppBarButtonInventory" x:Uid="Inventory" Label="Inventory" Click="AppBarButtonGoToInventory" >
                    <AppBarButton.Icon>
                        <BitmapIcon UriSource="Assets/tab_inventory.png"/>
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarButton x:Name="AppBarButtonAccess1" x:Uid="Access" Label="Access" Click="AppBarButtonGoToAccess" >
                    <AppBarButton.Icon>
                        <BitmapIcon UriSource="Assets/tab_access.png"/>
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarButton x:Name="s" x:Uid="Locate Tag" Label="LocateTag" Click="AppBarButtonGoToLocateTag">
                    <AppBarButton.Icon>
                        <BitmapIcon UriSource="Assets/tab_locate.png"/>
                    </AppBarButton.Icon>
                </AppBarButton>
            </CommandBar.PrimaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

    <Grid>
        <TextBlock x:Name="TextInventory" HorizontalAlignment="Left" Margin="80,10,0,0" TextWrapping="Wrap" Text="Inventory" VerticalAlignment="Top" FontSize="30"/>
        <AppBarButton x:Name="AppBarButtonHome" HorizontalAlignment="Left" Icon="Back" Label="Home" Margin="10,0,0,0" VerticalAlignment="Top" Width="Auto" Click="AppBarButton_Click"/>
        <AppBarButton x:Name="AppBarSearchButton" HorizontalAlignment="Left" Icon="find" Margin="320,10,0,0"
                       VerticalAlignment="Top" Click="AppBarSearchButton_Click" Width="40" Height="50"/>
        <AutoSuggestBox x:Name="AppBarSearch" PlaceholderText="Search" TextChanged="AutoSuggestBox_TextChanged" HorizontalAlignment="Left" Margin="60,10,0,0" Width="256" Height="46" Visibility="Collapsed"/>
        <!--<AutoSuggestBox x:Name="" PlaceholderText="Search" TextChanged="AutoSuggestBox_TextChanged" SuggestionChosen="AutoSuggestBox_SuggestionChosen" Margin="80,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="220" Height="40" Canvas.ZIndex="1" BorderThickness="2" Background="White" BorderBrush="Black" Visibility="Collapsed"/>-->
        <TextBlock x:Name="TextBlockUniqueTags" HorizontalAlignment="Left" Margin="140,90,0,0" TextWrapping="Wrap" Text="{Binding UniqueCount}" FontSize="22" Width="103.719" TextAlignment="Center" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" d:LayoutRounding="Auto" VerticalAlignment="Top" >
            <TextBlock.RenderTransform>
                <CompositeTransform Rotation="0.11"/>
            </TextBlock.RenderTransform>
        </TextBlock>
        <TextBlock x:Name="TectBlockReadCount" HorizontalAlignment="Left" Margin="250,89,0,0" TextWrapping="Wrap" FontSize="22" Text="{Binding ReadTags}" Width="92" TextAlignment="Center" VerticalAlignment="Top"/>
        <TextBlock x:Name="TectBlockHeadingMemBank" HorizontalAlignment="Left" Margin="10,60,0,0" TextWrapping="Wrap" Text="Memory Bank" VerticalAlignment="Top" Width="126" FontSize="18"/>
        <TextBlock x:Name="TectBlockHeadingUniqueCount" HorizontalAlignment="Left" Margin="140,60,0,0" TextWrapping="Wrap" Text="Unique Tags" VerticalAlignment="Top" Width="112" FontSize="18"/>
        <TextBlock x:Name="TectBlockHeadingTotalReads" HorizontalAlignment="Left" Margin="250,60,10,0" TextWrapping="Wrap" Text="Total Reads" VerticalAlignment="Top" FontSize="18"/>
        <ListView x:Name="ListViewInventoryItems"  Margin="5,110,5,80" DataContext="{Binding}" IsItemClickEnabled="True" ItemClick="ListViewInventoryItems_ItemClick" Height="360" Visibility="{Binding UniqueCountVisible}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0.8*"/>
                            <RowDefinition Height="0.8*"/>
                        </Grid.RowDefinitions>
                        <Grid Grid.Row="0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="275"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock x:Name="TextDisplayName"  Grid.Column="0"  Text="{Binding EPCID}" TextWrapping="Wrap" FontSize="16"/>
                            <TextBlock x:Name="TextServiceName"  Grid.Column="2" Text="{Binding Count}" FontSize="16" />
                        </Grid>
                        <Grid Visibility="{Binding Visible}" Grid.Row="1">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <TextBlock x:Name="TextAccessDataLabel" Grid.Row="0" Text="{Binding AccessDataLabel}" FontSize="12" Visibility="{Binding AccessDataVisible}"/>
                            <TextBlock x:Name="TextAccessData" Grid.Row="1" Text="{Binding AccessData}" TextWrapping="Wrap" FontSize="16" Visibility="{Binding AccessDataVisible}"/>
                            <Grid Grid.Row="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock x:Name="TextPCLabel" Grid.Column="0" Text="PC" FontSize="12" Visibility="{Binding PCVisible}"/>
                                <TextBlock x:Name="TextRSSILabel" Grid.Column="1" Text="RSSI" FontSize="12" Visibility="{Binding RSSIVisible}"/>
                                <TextBlock x:Name="TextPhaseLabel" Grid.Column="2" Text="Phase" FontSize="12" Visibility="{Binding PhaseVisible}"/>
                                <TextBlock x:Name="TextChannelLabel" Grid.Column="3" Text="Channel" FontSize="12" Visibility="{Binding ChannelVisible}"/>
                            </Grid>
                            <Grid Grid.Row="3">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <TextBlock x:Name="TextPC" Grid.Column="0" Text="{Binding PC}" FontSize="14" Visibility="{Binding PCVisible}"/>
                                <TextBlock x:Name="TextRSSI" Grid.Column="1" Text="{Binding RSSI}" FontSize="14" Visibility="{Binding RSSIVisible}"/>
                                <TextBlock x:Name="TextPhase" Grid.Column="2" Text="{Binding Phase}" FontSize="14"  Visibility="{Binding PhaseVisible}"/>
                                <TextBlock x:Name="TextChannel" Grid.Column="3" Text="{Binding Channel}" FontSize="14" Visibility="{Binding ChannelVisible}"/>
                            </Grid>
                        </Grid>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <Button x:Name="ButtonStart" Content="{Binding STARTSTATUS}" HorizontalAlignment="Center" Margin="0,0,0,20" VerticalAlignment="Bottom" Width="340" Click="ButtonStart_Click" Height="60" FontSize="22" FlyoutBase.AttachedFlyout="{StaticResource InventoryFlyout}"/>
        <ComboBox x:Name="ComboBoxMemoryBank" ItemsSource="{Binding MemoryBanks}"  HorizontalAlignment="Left" Margin="10,90,0,0" IsEnabled="{Binding isBankListEnabled}" FontSize="12" Width="110" SelectionChanged="ComboBoxMemoryBank_SelectionChanged" SelectedIndex="-1" VerticalAlignment="Top" />
        <TextBlock x:Name="TextBlockBatchModeMessage" HorizontalAlignment="Center" Margin="0" TextWrapping="Wrap" Text="Inventory is running in batch mode" VerticalAlignment="Center" FontSize="22" TextAlignment="Center" Visibility="{Binding BatchModeEnable}"/>
    </Grid>
</Page>