<?xml version="1.0" encoding="utf-8"?>
<Page
    x:Class="was.droidtransfer.features.photos.PhotosContentPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.droidtransfer.features.photos"
    xmlns:featurebase="using:was.droidtransfer.features"
    xmlns:converters="using:was.droidtransfer.features.photos.converters"
    xmlns:coreconverters="using:was.droidtransfer.features.converters"
    xmlns:data="using:was.droidtransfer.features.photos.data"
    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>
        <ResourceDictionary>
            <coreconverters:ValueToVisibilityConverter x:Key="ValueToVisibilityConverter" />
            <converters:IsMarkedForDeletionToOpacityConverter x:Key="IsMarkedForDeletionToOpacityConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Border Style="{ThemeResource FeatureContentPageBorder}" Padding="0">
        <Grid >
            <Grid x:Name="gridLoading" Visibility="{x:Bind IsLoading, Mode=OneWay}">
                <StackPanel VerticalAlignment="Center">
                    <TextBlock x:Uid="TextBlockLoadingMedia" Text="XX Loading Media..." Style="{ThemeResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap" />
                    <ProgressRing IsIndeterminate="{x:Bind IsLoading, Mode=OneWay}" Margin="0,20,0,0" />
                </StackPanel>
            </Grid>
            <Grid x:Name="gridContent" Visibility="{x:Bind IsLoading, Converter={StaticResource ValueToVisibilityConverter}, ConverterParameter=invert, Mode=OneWay}">
                <GridView x:Name="itemsGridView" ItemsSource="{x:Bind PhotoItems, Mode=OneWay}" SelectionMode="Extended" 
                  IsDoubleTapEnabled="True" DoubleTapped="_itemsGridView_DoubleTapped" PreviewKeyDown="_itemsGridView_PreviewKeyDown"
                  ContainerContentChanging="_itemsGridView_ContainerContentChanging" Padding="5">
                    <GridView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <ItemsWrapGrid CacheLength="0" Orientation="Horizontal" ScrollViewer.VerticalScrollMode="Auto" />
                        </ItemsPanelTemplate>
                    </GridView.ItemsPanel>
                    <GridView.ItemTemplate>
                        <DataTemplate x:DataType="data:PhotosItem" >
                            <Grid Width="128" Height="128" DataContext="{x:Bind}">
                                <local:PhotosThumbnailControl x:Name="thumbnailControl" Width="128" Height="128" Opacity="{x:Bind IsMarkedForDeletion, Converter={StaticResource IsMarkedForDeletionToOpacityConverter}}" />
                                <ProgressRing IsIndeterminate="True" Visibility="{x:Bind IsMarkedForDeletion, Converter={StaticResource ValueToVisibilityConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                <Grid.ContextFlyout>
                                    <MenuFlyout Opening="_gridViewItemMenuFlyout_Opening">
                                        <MenuFlyoutItem x:Uid="MenuFlyoutItemPreview" Text="XX Preview" Click="_menuFlyoutButtonView_Click">
                                            <MenuFlyoutItem.Icon>
                                                <FontIcon Glyph="&#xE890;" />
                                            </MenuFlyoutItem.Icon>
                                        </MenuFlyoutItem>
                                        <MenuFlyoutItem x:Uid="MenuFlyoutItemSaveToPC" Text="XX Save to PC" Click="_menuFlyoutButtonSave_Click">
                                            <MenuFlyoutItem.Icon>
                                                <FontIcon Glyph="&#xE78C;" />
                                            </MenuFlyoutItem.Icon>
                                        </MenuFlyoutItem>
                                        <MenuFlyoutSeparator />
                                        <MenuFlyoutItem x:Uid="MenuFlyoutItemDelete" Text="XX Delete" Click="_menuFlyoutButtonDelete_Click">
                                            <MenuFlyoutItem.Icon>
                                                <FontIcon Glyph="&#xE74D;" />
                                            </MenuFlyoutItem.Icon>
                                        </MenuFlyoutItem>
                                    </MenuFlyout>
                                </Grid.ContextFlyout>
                            </Grid>
                        </DataTemplate>
                    </GridView.ItemTemplate>
                    
                </GridView>
            </Grid>
            <featurebase:ImagePreviewPage x:Name="imagePreviewPage" Visibility="Collapsed" Padding="30"/>
        </Grid>
    </Border>
</Page>
