<featurebase:FeaturePage
    x:Class="was.touchcopy.features.photos.PhotosExportPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.touchcopy.features.photos"
    xmlns:export="using:was.touchcopy.features.photos.export"
    xmlns:featurebase="using:was.touchcopy.features"
    xmlns:utilities="using:was.touchcopy.features.utilities"
    xmlns:converters="using:was.touchcopy.features.converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DataContext="{d:DesignInstance Type=local:PhotosExportPage}"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <ResourceDictionary>
            <CollectionViewSource x:Key="GroupsCVS" IsSourceGrouped="True" />
            <converters:ValueToVisibilityConverter x:Key="ValueToVisibilityConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Border Style="{ThemeResource PageHeaderBorderStyle}">
            <Grid>
                <CommandBar Style="{ThemeResource PageHeaderCommandBarStyle}">
                    <featurebase:CopyProgressAppBarUserController x:Name="copyProgressUserControl" Visibility="Collapsed" OnCancelTapped="_copyProgressUserControl_OnCancelTapped" MaxWidth="350" />
                    <AppBarElementContainer x:Name="appBarElementIdentification" VerticalContentAlignment="Center" Margin="10,0,10,0" Visibility="Collapsed">
                        <StackPanel VerticalAlignment="Center" Spacing="5">
                            <TextBlock x:Name="textBlockIdentificationProgress" Style="{ThemeResource CaptionTextBlockStyle}" TextAlignment="Right" FontWeight="SemiBold" />
                            <ProgressBar x:Name="progressBarIdentificationProgress" IsIndeterminate="True" />
                        </StackPanel>
                    </AppBarElementContainer>
                    <AppBarSeparator Visibility="{Binding Visibility, ElementName=appBarElementIdentification, Mode=OneWay}" />
                    <AppBarButton x:Name="appBarButtonSave" x:Uid="AppBarButtonExportSave" Label="XX Save to PC" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonSave_Click" Visibility="{Binding Visibility, ElementName=gridContent}" IsEnabled="{x:Bind IsExportAvailable, Mode=OneWay}">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE78C;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonSave.IsEnabled), Mode=OneWay}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarSeparator Visibility="{Binding Visibility, ElementName=gridContent}" />
                    <AppBarButton x:Name="appBarButtonSelectAll" x:Uid="AppBarButtonExportSelectAll" Label="XX Select All" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonSelectAll_Click" Visibility="{Binding Visibility, ElementName=gridContent}" IsEnabled="{x:Bind IsSelectionAvailable, Mode=OneWay}">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE73A;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonSelectAll.IsEnabled), Mode=OneWay}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarButton x:Name="appBarButtonClearSelection" x:Uid="AppBarButtonExportClearSelection" Label="XX Clear Selection" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonClearSelection_Click" Visibility="{Binding Visibility, ElementName=gridContent}" IsEnabled="{x:Bind IsSelectionAvailable, Mode=OneWay}">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE739;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonClearSelection.IsEnabled), Mode=OneWay}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                    <AppBarSeparator Visibility="{Binding Visibility, ElementName=gridContent}" />
                    <AppBarButton x:Name="appBarButtonCancel" x:Uid="AppBarButtonExportCancel" Label="XX Cancel" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonCancel_Click">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE711;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonCancel.IsEnabled), Mode=OneWay}"/>
                        </AppBarButton.Content>
                    </AppBarButton>
                </CommandBar>
                <TextBlock Text="{Binding PageTitle}" Style="{ThemeResource PageHeaderTitleStyle}"/>
            </Grid>
        </Border>
        <Grid Grid.Row="1" BorderBrush="{ThemeResource SystemControlPageBackgroundListLowBrush}" BorderThickness="1" CornerRadius="{ThemeResource HyperlinkFocusRectCornerRadius}">
            <Grid x:Name="gridSearching">
                <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                    <TextBlock x:Uid="TextBlockIdentifyingNewPhotos" Text="XX Identifying new photos..." Style="{ThemeResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap"  />
                    <ProgressRing IsIndeterminate="{Binding IsIndeterminate, ElementName=progressBarIdentificationProgress, Mode=OneWay}" Visibility="{Binding IsIndeterminate, ElementName=progressBarIdentificationProgress, Converter={StaticResource ValueToVisibilityConverter}, Mode=OneWay}" Margin="0,20,0,0" />
                    <ProgressBar IsIndeterminate="{Binding IsIndeterminate, ElementName=progressBarIdentificationProgress, Mode=OneWay}" Maximum="{Binding Maximum, ElementName=progressBarIdentificationProgress, Mode=OneWay}" Value="{Binding Value, ElementName=progressBarIdentificationProgress, Mode=OneWay}" Visibility="{Binding IsIndeterminate, ElementName=progressBarIdentificationProgress, Converter={StaticResource ValueToVisibilityConverter}, ConverterParameter='invert', Mode=OneWay}" Margin="0,20,0,0" />
                </StackPanel>
            </Grid>
            <Grid x:Name="gridContent">
                <GridView ItemsSource="{x:Bind ExportGroups.View, Mode=OneWay}" Padding="10" SelectionMode="None" ContainerContentChanging="_itemsGridView_ContainerContentChanging">
                    <GridView.GroupStyle>
                        <GroupStyle HidesIfEmpty="True">
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate x:DataType="export:PhotosExportGroup">
                                    <CheckBox IsChecked="{x:Bind IsSelectedForExport, Mode=TwoWay}" Margin="-2,0,0,0">
                                        <TextBlock Text="{x:Bind Title}" FontWeight="SemiBold" />
                                    </CheckBox>
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                        </GroupStyle>
                    </GridView.GroupStyle>
                    <GridView.ItemTemplate>
                        <DataTemplate x:DataType="export:PhotosExportGroupItem">
                            <Grid Width="128" Height="128" Margin="10,10,10,10">
                                <local:PhotosThumbnailControl x:Name="thumbnailControl" Width="128" Height="128" />
                            </Grid>
                        </DataTemplate>
                    </GridView.ItemTemplate>
                    <GridView.ContextFlyout>
                        <MenuFlyout>
                            <MenuFlyoutItem x:Name="menuFlyoutItemSelectAll" x:Uid="MenuFlyoutItemSelectAll" Text="XX Select All" Click="_menuFlyoutItemSelectAll_Click">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon Glyph="&#xE73A;" Foreground="{ThemeResource AppBarItemForegroundThemeBrush}"/>
                                </MenuFlyoutItem.Icon>
                            </MenuFlyoutItem>
                            <MenuFlyoutItem x:Name="menuFlyoutItemClearSelection" x:Uid="MenuFlyoutItemClearSelection" Text="XX Clear Selection" Click="_menuFlyoutItemClearSelection_Click">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon Glyph="&#xE739;" Foreground="{ThemeResource AppBarItemForegroundThemeBrush}"/>
                                </MenuFlyoutItem.Icon>
                            </MenuFlyoutItem>
                        </MenuFlyout>
                    </GridView.ContextFlyout>
                </GridView>
            </Grid>
            <Grid x:Name="gridNoContentFound" Visibility="Collapsed">
                <StackPanel  HorizontalAlignment="Center" VerticalAlignment="Center">
                    <TextBlock x:Uid="TextBlockNoNewPhotosTitle" Text="XX No new photos were found!" Style="{ThemeResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap"  />
                    <TextBlock x:Uid="TextBlockNoNewPhotosDescription" Text="XX All of your device photos are already in your chosen export folder." Style="{ThemeResource BodyTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap"  />
                    <Button x:Uid="ButtonBackToPhotos"  Content="XX Back to Photos" Style="{ThemeResource AccentButtonStyle}" HorizontalAlignment="Center" Margin="0,40,0,0" Click="_buttonBackToPhotos_Click" />
                </StackPanel>
            </Grid>
            <Grid x:Name="gridExporting" Visibility="Collapsed">
                <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                    <TextBlock x:Name="textBlockExportingNewPhotos" x:Uid="TextBlockExportingNewPhotos" Text="XX Exporting photos..." Style="{ThemeResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap"  />
                    <ProgressRing IsIndeterminate="True" Margin="0,20,0,0" />
                </StackPanel>
            </Grid>
        </Grid>
    </Grid>
</featurebase:FeaturePage>
