<Page xmlns:local="clr-namespace:ForzaUI"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
      x:Class="ForzaUI.A_LoadSavePhoto"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>

    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_StackPanel_DescriptionBlock" TargetType="StackPanel" BasedOn="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}" >
                <Setter Property="Canvas.Bottom" Value="291" />
                <Setter Property="Width" Value="436" />
                <Setter Property="Orientation" Value="Vertical" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_ImageName"
                   TargetType="local:FZTextBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
                <Setter Property="CapHeight"
                        Value="16" />
                <Setter Property="Color" 
                        Value="{StaticResource A_Color_Body_Text}" />
                <Setter Property="VerticalAlignment"
                        Value="Center" />
            </Style>

            <Style x:Key="A_Style_FrameworkElement_CollapseIfNoCategories"
                   BasedOn="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                   TargetType="FrameworkElement">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=(ItemsControl.Items).(ItemCollection.Count), ElementName=GalleryCategoryList, Converter={StaticResource A_CompareConverter}, ConverterParameter=2}"
                                    Value="-1">
                        <Setter Property="Visibility"
                                Value="Collapsed" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_Carousel_PhotoItemContent">
                <ContentControl Template="{StaticResource A_ControlTemplate_CarouselItemContent_WithBottomHighlightTag}"
                                Tag="{Binding Source={local:Loc ScreenTitles.IDS_Save_Photo}, Converter={StaticResource A_StringToUpper}}"
                                IsEnabled="{Binding IsSavingMode, RelativeSource={RelativeSource AncestorType=Page}}">
                    <Grid Height="213">
                        <Decorator Visibility="{Binding IsReady, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Visible}">
                            <Grid Margin="6">
                                <local:FZMaterial CaptureSubgraph="True"
                                                  Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_InnerAll}">
                                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Carousel_DefaultItemContent}"
                                                      VerticalAlignment="Center"
                                                      HorizontalAlignment="Center"
                                                      GreedyMeasure="True"
                                                      Stretch="UniformToFill" />
                                </local:FZMaterial>
                                <local:FZMaterial Color="#80000000"
                                                  Height="46"
                                                  VerticalAlignment="Bottom"
                                                  Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_InnerBottomOnly}">
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_ImageName}"
                                                       Text="{Binding DisplayName, Converter={StaticResource A_StringToUpper}}"
                                                       Margin="16,0" />
                                </local:FZMaterial>
                            </Grid>
                        </Decorator>
                        <ProgressBar x:Name="Loading"
                                     IsIndeterminate="True"
                                     Style="{StaticResource A_Style_ProgressBar_WaitSpinnerDark}"
                                     Visibility="{Binding IsReady, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}, FallbackValue=Collapsed}"
                                     HorizontalAlignment="Center"
                                     VerticalAlignment="Center" />
                    </Grid>
                </ContentControl>
            </DataTemplate>

            <Style x:Key="A_Style_ContentControl_Carousel_ContainerStyle_PhotoGallery"
                   TargetType="{x:Type ContentControl}"
                   BasedOn="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle_Internal}">
                <Style.Resources>
                    <local:FZMaterialPresetRoundtangleStroke x:Key="A_FZMaterialPresetRoundtangleStroke_CarouselContainerHighlight"
                                                             BasedOn="{StaticResource A_FZMaterialPresetRoundtangleStroke_Rollover}"
                                                             CornerRadius="14"
                                                             Thickness="8,8,8,48" />
                    <Style x:Key="A_FZMaterial_CarouselContainerHighlight_Dynamic"
                           TargetType="{x:Type local:FZMaterial}">
                        <Setter Property="GreedyMeasure" Value="True" />
                        <Setter Property="Margin" Value="-6,-6,-6,-46" />
                        <Setter Property="local:ZPanel.DisableClipping" Value="True" />
                        <Setter Property="IsHitTestVisible" Value="False" />
                        <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangleStroke_CarouselContainerHighlight}" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsSavingMode, RelativeSource={RelativeSource AncestorType=Page}}"
                                         Value="False">
                                <Setter Property="Margin"
                                        Value="-6" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Style.Resources>
            </Style>

            <Size x:Key="A_Size_GamerPicSizeParams">342,342</Size>

        </ResourceDictionary>
    </Page.Resources>

    <Grid x:Name="LayoutRoot">
        <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="DefaultHelpPanel" Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding}">
            <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                        Margin="15,40,0,56"
                        VerticalAlignment="Top">
                <ContentControl x:Name="ContentControl_SceneTitle"
                                Content="{Binding Title}"
                                local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Photo.png"
                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                HorizontalAlignment="Left" />
                <Grid Style="{StaticResource A_Style_FrameworkElement_CollapseIfNoCategories}">
                    <local:ItemsSelector x:Name="GalleryCategoryList"
                                         ItemsSource="{Binding CategoryItems}"
                                         Style="{StaticResource A_Style_TextTabMenuList}"
                                         Focusable="False"
                                         HorizontalAlignment="Left"
                                         Margin="0,0,0,12" />
                </Grid>

                <Grid>
                    <local:WrapListBox Style="{StaticResource A_Style_CommonListBox_FullScreenCarousel}"
                                         ItemContainerStyle="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle_PhotoGallery}"
                                         ItemTemplate="{StaticResource A_DataTemplate_Carousel_PhotoItemContent}"
                                         x:Name="ItemList" />
                    <DockPanel LastChildFill="False"
                               Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                               HorizontalAlignment="Left">
                        <local:FZMaterialGlassCapture />
                        <ContentControl DockPanel.Dock="Left"
                                        Style="{StaticResource A_Style_FrameworkElement_FullScreenCarousel_SidePanel}"
                                        Template="{StaticResource A_ControlTemplate_SidePanel}"
                                        x:Name="InformationPanel"
                                        Tag="{Binding Source={local:Loc Livery.IDS_CreatorInfo}, Converter={StaticResource A_StringToUpper}}">
                            <DockPanel DataContext="{Binding SelectedItem, ElementName=ItemList}">
                                <Grid x:Name="CreatorInfo"
                                      DockPanel.Dock="Top">
                                    <local:FZMaterial x:Name="GamerPicMaterial"
                                        ImageSource="{Binding UserProfile, Converter={StaticResource A_GamerPicConverter}, ConverterParameter={StaticResource A_Size_GamerPicSizeParams}}"
                                        Height="342"
                                        Visibility="{Binding Downloaded, RelativeSource={RelativeSource Self}, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}" />
                                    <ProgressBar Style="{StaticResource A_Style_ProgressBar_WaitSpinner}"
                                            HorizontalAlignment="Center"
                                            VerticalAlignment="Center"
                                            Visibility="{Binding Downloaded, ElementName=GamerPicMaterial, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"/>
                                    <local:FZMaterial VerticalAlignment="Bottom"
                                                      Height="96"
                                                      Color="#80000000">
                                        <local:FZTextBlock Text="{Binding UserProfile.FormattedGamertag, FallbackValue=-}"
                                                           Style="{StaticResource A_Style_FZTextBlock_CreatorInfo_Gamertag}" />
                                    </local:FZMaterial>
                                </Grid>
                                <local:FZMaterial x:Name="FooterPanel"
                                                  Style="{StaticResource A_Style_FZMaterial_FlatPanel_FooterPanel}"
                                                  Height="72"
                                                  DockPanel.Dock="Bottom">
                                    <DockPanel x:Name="DateInfo_Panel"
                                               Margin="30,0">
                                        <local:FZTextBlock Text="{local:Loc Storefront.IDS_LabelDate}"
                                                           Style="{StaticResource A_Style_FZTextBlock_CreatorInfo_CreatedDate}"
                                                           MaxWidth="140"
                                                           DockPanel.Dock="Left" />
                                        <local:FZTextBlock Text="{Binding DateCreated, FallbackValue=-}"
                                                           Style="{StaticResource A_Style_FZTextBlock_CreatorInfo_CreatedDate}"
                                                           HorizontalAlignment="Right" />
                                    </DockPanel>
                                </local:FZMaterial>
                                <Grid x:Name="PopularityInfo_Panel">
                                    <StackPanel Margin="30"
                                                VerticalAlignment="Top">
                                        <Grid Margin="0,0,0,20">
                                            <local:FZTextBlock Text="{Binding Source={local:Loc Storefront.IDS_NumberLikes}, Converter={StaticResource A_StringToUpper}}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel}"
                                                               Margin="0,0,15,0" />
                                            <local:FZTextBlock Text="{Binding LikeCount, FallbackValue=-}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoValue}" />
                                        </Grid>
                                        <Grid Margin="0,0,0,20">
                                            <local:FZTextBlock Text="{Binding Source={local:Loc Storefront.IDS_NumberDownloads}, Converter={StaticResource A_StringToUpper}}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel}"
                                                               Margin="0,0,15,0" />
                                            <local:FZTextBlock Text="{Binding DownloadCount, FallbackValue=-}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoValue}" />
                                        </Grid>
                                        <Grid>
                                            <local:FZTextBlock Text="{Binding Source={local:Loc Storefront.IDS_LabelPopularity}, Converter={StaticResource A_StringToUpper}}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel}"
                                                               Margin="0,0,15,0" />
                                            <Viewbox Width="106"
                                                     Height="18"
                                                     HorizontalAlignment="Right">
                                                <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Popularity}"
                                                                        BaseValue="{Binding Popularity}"
                                                                        NewValue="{Binding Popularity}" />
                                            </Viewbox>
                                        </Grid>
                                    </StackPanel>
                                </Grid>
                            </DockPanel>
                        </ContentControl>
                    </DockPanel>

                    <local:NavigationArrows Style="{StaticResource A_Style_Control_NavigationArrows}"
                                            Margin="-40,0,-20,0"
                                            CanSelectPrev="{Binding CanSelectPrev, ElementName=ItemList}"
                                            CanSelectNext="{Binding CanSelectNext, ElementName=ItemList}"
                                            ScrollPagePrevCommand="{Binding ScrollPagePrevCommand, ElementName=ItemList}"
                                            ScrollPageNextCommand="{Binding ScrollPageNextCommand, ElementName=ItemList}" />
                </Grid>

            </StackPanel>
        </Border>
    </Grid>
</Page>