<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.Scenes.Anthem.A_UserContentShowroom"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <Page.Resources>
        <ResourceDictionary>
            <local:TileMenuDataItem x:Key="A_MenuDataItem_HorizonLife"
                Description="{local:Loc TiledMenus.IDS_UserContentShowroom_TileText_HorizonLife}"
                Icon="/ForzaUI;component/Textures/Data_Bound/CreativeHub/Horizon_life.png" />

            <Style x:Key="A_Style_FZTextBlock_SharedCount"
                TargetType="{x:Type local:FZTextBlock}"
                BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
                <Setter Property="Color" Value="{StaticResource A_Color_Tile_Text}"/>
                <Setter Property="FontSize" Value="130"/>
                <Setter Property="TextAlignment" Value="Left"/>
                <Setter Property="Margin" Value="12"/>
            </Style>

            <ControlTemplate x:Key="A_ControlTemplate_IconTileWithCount"
                             TargetType="{x:Type local:FZButton}">
                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                      local:UIPageTransitionManager.TransitionIndex="{Binding (local:UIPageTransitionManager.TransitionIndex), RelativeSource={RelativeSource TemplatedParent}}" >
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_TileShadow}" />
                    <Grid Style="{StaticResource A_Style_Grid_MotionBlur}">
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_MotionBlurExpander}" />
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_TileBackground}"/>
                        <local:FZMaterial x:Name="SharedCountShadow"
                            Style="{StaticResource A_Style_FZMaterial_TitleShadow}"
                            CaptureSubgraph="False">
                            <DockPanel VerticalAlignment="Bottom">
                                <Decorator DockPanel.Dock="Right"
                                    Width="{Binding ActualWidth, ElementName=RankContainer}"
                                    Margin="0,0,12,0"/>
                                <local:FZTextBlock x:Name="SharedCountText"
                                    Style="{StaticResource A_Style_FZTextBlock_SharedCount}"
                                    Text="{Binding DataContext.SharedCountValue, RelativeSource={RelativeSource TemplatedParent}}"/>
                            </DockPanel>
                        </local:FZMaterial>
                        <Grid Margin="12">
                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_TileText}"
                                               local:TextBlockInlineMarkup.Markup="{Binding DataContext.SharedCountTitle, RelativeSource={RelativeSource TemplatedParent}}"
                                               HorizontalAlignment="Left"
                                               VerticalAlignment="Top" />
                            <Control x:Name="RankContainer" Tag="{Binding Tag, RelativeSource={RelativeSource AncestorType={x:Type local:FZButton}}}"
                                     HorizontalAlignment="Right" VerticalAlignment="Bottom" DataContext="{Binding UserProfile, RelativeSource={RelativeSource AncestorType=Page}}"
                                     Template="{StaticResource A_ControlTemplate_RankLevel_Pill}"/>
                        </Grid>
                    </Grid>
                    <ContentControl Style="{StaticResource A_Style_ContentControl_TileSelectionStroke}" />
                </Grid>
                <ControlTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource Self}}" Value="True">
                        <Setter TargetName="SharedCountText" Property="Color" Value="{StaticResource A_Color_Tile_Selected}"/>
                        <!-- Workaround for TFS 180502, CaptureSubgraph causing incorrect scale/position around AlignToCapAndBaseLines text. Uncomment this setter to restore the selection streak shadow once the bug is fixed. -->
                        <!--<Setter TargetName="SharedCountShadow" Property="CaptureSubgraph" Value="True"/>-->
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <local:LinearTransformConverter x:Key="A_LinearTransformConverter_CreativeHubTile_XPositionTransform" Scale="660"/>
            <local:LinearTransformConverter x:Key="A_LinearTransformConverter_CreativeHubTile_YPositionTransform" Scale="96"/>

            <Style x:Key="A_Style_Button_CreativeHubTile"
                BasedOn="{StaticResource A_Style_Button_RootTile}"
                TargetType="{x:Type local:FZButton}">
                <Setter Property="Width" Value="306"/>
                <Setter Property="Height" Value="186"/>
                <Setter Property="local:TileMenuNavigationManager.GridWidth" Value="1"/>
                <Setter Property="local:TileMenuNavigationManager.GridHeight" Value="2"/>
                <Setter Property="Canvas.Left" Value="{Binding Path=(local:TileMenuNavigationManager.GridX) ,RelativeSource={RelativeSource Self}, Converter={StaticResource A_LinearTransformConverter_CreativeHubTile_XPositionTransform}}"/>
                <Setter Property="Canvas.Top" Value="{Binding Path=(local:TileMenuNavigationManager.GridY) ,RelativeSource={RelativeSource Self}, Converter={StaticResource A_LinearTransformConverter_CreativeHubTile_YPositionTransform}}"/>
                <Setter Property="Template" Value="{StaticResource A_ControlTemplate_IconTileWithCount}"/>
            </Style>

            <Style x:Key="A_Style_Button_CreativeHubIconTile"
                BasedOn="{StaticResource A_Style_Button_IconTile}"
                TargetType="{x:Type local:FZButton}">
                <Setter Property="Width" Value="306"/>
                <Setter Property="Height" Value="90"/>
                <Setter Property="local:TileMenuNavigationManager.GridWidth" Value="1"/>
                <Setter Property="local:TileMenuNavigationManager.GridHeight" Value="1"/>
                <Setter Property="Canvas.Left" Value="{Binding Path=(local:TileMenuNavigationManager.GridX) ,RelativeSource={RelativeSource Self}, Converter={StaticResource A_LinearTransformConverter_CreativeHubTile_XPositionTransform}}"/>
                <Setter Property="Canvas.Top" Value="{Binding Path=(local:TileMenuNavigationManager.GridY) ,RelativeSource={RelativeSource Self}, Converter={StaticResource A_LinearTransformConverter_CreativeHubTile_YPositionTransform}}"/>
            </Style>

            <Style x:Key="A_Style_Button_CreativeHubToggleIconTile"
                BasedOn="{StaticResource A_Style_Button_ToggleIconTile}"
                TargetType="{x:Type local:FZButton}">
                <Setter Property="Width" Value="306"/>
                <Setter Property="Height" Value="90"/>
                <Setter Property="local:TileMenuNavigationManager.GridWidth" Value="1"/>
                <Setter Property="local:TileMenuNavigationManager.GridHeight" Value="1"/>
                <Setter Property="Canvas.Left" Value="{Binding Path=(local:TileMenuNavigationManager.GridX) ,RelativeSource={RelativeSource Self}, Converter={StaticResource A_LinearTransformConverter_CreativeHubTile_XPositionTransform}}"/>
                <Setter Property="Canvas.Top" Value="{Binding Path=(local:TileMenuNavigationManager.GridY) ,RelativeSource={RelativeSource Self}, Converter={StaticResource A_LinearTransformConverter_CreativeHubTile_YPositionTransform}}"/>
            </Style>

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

            <Style x:Key="A_Style_FZTextBlock_FollowerCountValue"
                BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}"
                TargetType="{x:Type local:FZTextBlock}">
                <Setter Property="FontSize" Value="48"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Color" Value="{StaticResource A_Color_Header_Text}"/>
                <Setter Property="Text" Value="{Binding FollowerCount, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}}"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_FollowerCountTitle"
                BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}"
                TargetType="{x:Type local:FZTextBlock}">
                <Setter Property="FontSize" Value="26"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="Color" Value="{StaticResource A_Color_Header_Text}"/>
                <Setter Property="Text" Value="{local:Loc TiledMenus.IDS_Followers_Plural}"/>
                <Setter Property="Margin" Value="16,0,0,0"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding FollowerCount}" Value="1">
                        <Setter Property="Text" Value="{local:Loc TiledMenus.IDS_Followers_Singular}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_DownloadCountItem">
                <Viewbox StretchDirection="DownOnly"
                    Stretch="Uniform">
                    <DockPanel MinWidth="294">
                        <local:FZTextBlock DockPanel.Dock="Left"
                            Text="{Binding DownloadCountTitle}"
                            Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                            FontSize="24"
                            Color="{StaticResource A_Color_Header_Text}"
                            Stretch="None"
                            VerticalAlignment="Center"
                            TextWrapping="NoWrap"/>
                        <local:FZTextBlock Text="{Binding DownloadCountValue}"
                            Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                            FontSize="24"
                            Color="{StaticResource A_Color_Header_Text}"
                            Stretch="None"
                            TextAlignment="Right"
                            TextWrapping="NoWrap"
                            VerticalAlignment="Center"
                            Margin="24,0,0,0"/>
                    </DockPanel>
                </Viewbox>
            </DataTemplate>

            <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_FlatPanel_PlayerLevelBorder"
                                               BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                                               CornerRadius="12"/>

        </ResourceDictionary>
    </Page.Resources>

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

    <Grid>
        <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <local:PlayerBarControl x:Name="TopBar"
                        Style="{StaticResource A_Style_PlayerBarControl}"
                        Visibility="{Binding IsInPauseFlow, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}" />
        <ContentControl x:Name="BottomBar"
                        Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="DefaultHelpPanel"
                            local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                            local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_ShowGamercard}"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding}">
            <Grid x:Name="LayoutRoot"
                  KeyboardNavigation.DirectionalNavigation="Contained">

                <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}">
                    <StackPanel Orientation="Vertical"
                                VerticalAlignment="Center"
                                HorizontalAlignment="Center">
                        <Decorator Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                            Margin="72,0,0,0"
                            HorizontalAlignment="Left">
                            <ContentControl Content="{local:Loc ScreenTitles.IDS_UserContentShowroom}"
                                            Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}" 
                                            local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Storefront.png" />
                        </Decorator>

                        <Grid>
                            <Decorator Width="342"
                                       Height="642"
                                       Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                                <DockPanel>
                                    <Grid DockPanel.Dock="Top"
                                        Height="342"
                                        Width="342">
                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_HeaderPanel}"/>
                                        <local:FZMaterial x:Name="GamerPicMaterial"
                                            ShouldWaitForImageSource="False"
                                            Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterTopOnly}"
                                            ImageSource="{Binding UserProfile, Converter={StaticResource A_GamerPicConverter}, ConverterParameter={StaticResource A_Size_CreativeHub_GamerPicSizeParams}}"
                                            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 Style="{StaticResource A_Style_FZMaterial_TileTintedPanel_Shallow}">
                                            <Viewbox Margin="12"
                                                StretchDirection="DownOnly"
                                                Stretch="Uniform"
                                                HorizontalAlignment="Center"
                                                VerticalAlignment="Center">
                                                <StackPanel Orientation="Horizontal">
                                                    <local:FZTextBlock Text="{Binding UserProfile.FormattedClubTag}"
                                                        Style="{StaticResource A_Style_FZTextBlock_TileTitle_Large_Sub}"/>
                                                    <local:FZTextBlock Text="{Binding UserProfile.FormattedGamertag}"
                                                        Style="{StaticResource A_Style_FZTextBlock_TileTitle_Large}"/>
                                                </StackPanel>
                                            </Viewbox>
                                        </local:FZMaterial>
                                        <local:FZMaterial HorizontalAlignment="Right"
                                                          VerticalAlignment="Top"
                                                          Margin="12"
                                                          Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_PlayerLevelBorder}"
                                                          Color="{StaticResource A_Color_ButtonBar_Background}">
                                            <StackPanel Orientation="Horizontal"
                                                        Margin="4">
                                                <Control Style="{Binding XP, Converter={StaticResource A_XPConverter}}"
                                                    Height="56"
                                                    Width="56" />
                                                <Control Style="{StaticResource A_Style_Control_PlayerPrestigeLevel}"   
                                                         Height="40"
                                                         Margin="4,0,2,0" />
                                            </StackPanel>
                                        </local:FZMaterial>
                                    </Grid>

                                    <local:FZMaterial DockPanel.Dock="Bottom"
                                        Style="{StaticResource A_Style_FZMaterial_FlatPanel_FooterPanel}"
                                        Height="72">
                                        <Grid HorizontalAlignment="Center">
                                            <StackPanel Orientation="Horizontal">
                                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_FollowerCountValue}"
                                                    Opacity="0"/>
                                                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_FollowerCountTitle}"/>
                                            </StackPanel>
                                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_HighlightShadow}">
                                                <StackPanel Orientation="Horizontal">
                                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_FollowerCountValue}"/>
                                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_FollowerCountTitle}"
                                                        Opacity="0"/>
                                                </StackPanel>
                                            </local:FZMaterial>
                                        </Grid>
                                    </local:FZMaterial>

                                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_NonInteractive}">
                                        <ItemsControl ItemsSource="{Binding Collection}"
                                            ItemTemplate="{StaticResource A_DataTemplate_DownloadCountItem}"
                                            Margin="24,24">
                                            <ItemsControl.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <UniformGrid Columns="1"/>
                                                </ItemsPanelTemplate>
                                            </ItemsControl.ItemsPanel>
                                        </ItemsControl>
                                    </local:FZMaterial>
                                </DockPanel>
                            </Decorator>

                            <StackPanel x:Name="PART_MenuContent"
                                        RenderTransformOrigin="0.5,0.5">
                                <local:AutoSizeCanvas x:Name="PART_SCOPE_Main">
                                    <local:FZButton x:Name="PART_Button_Blueprint"
                                                    DataContext="{Binding Collection[0]}"
                                                    Tag="{x:Static local:UGCThreadType.Blueprint}"
                                                    Style="{StaticResource A_Style_Button_CreativeHubTile}"
                                                    local:TileMenuNavigationManager.GridX="0"
                                                    local:TileMenuNavigationManager.GridY="0"/>
                                    <local:FZButton x:Name="PART_Button_Livery"
                                                    DataContext="{Binding Collection[1]}"
                                                    Tag="{x:Static local:UGCThreadType.Livery}"
                                                    Style="{StaticResource A_Style_Button_CreativeHubTile}"
                                                    local:TileMenuNavigationManager.GridX="0"
                                                    local:TileMenuNavigationManager.GridY="2"/>
                                    <local:FZButton x:Name="PART_Button_Tuning"
                                                    DataContext="{Binding Collection[2]}"
                                                    Tag="{x:Static local:UGCThreadType.Tuning}"
                                                    Style="{StaticResource A_Style_Button_CreativeHubTile}"
                                                    local:TileMenuNavigationManager.GridX="0"
                                                    local:TileMenuNavigationManager.GridY="4"/>
                                    <local:FZButton x:Name="PART_Button_Vinyl"
                                                    DataContext="{Binding Collection[3]}"
                                                    Tag="{x:Static local:UGCThreadType.Vinyl}"
                                                    Style="{StaticResource A_Style_Button_CreativeHubTile}"
                                                    local:TileMenuNavigationManager.GridX="1"
                                                    local:TileMenuNavigationManager.GridY="0"/>
                                    <local:FZButton x:Name="PART_Button_Photo"
                                                    DataContext="{Binding Collection[4]}"
                                                    Tag="{x:Static local:UGCThreadType.Photo}"
                                                    Style="{StaticResource A_Style_Button_CreativeHubTile}"
                                                    local:TileMenuNavigationManager.GridX="1"
                                                    local:TileMenuNavigationManager.GridY="2"/>
                                    <local:FZButton x:Name="PART_Button_HorizonLife"
                                                    DataContext="{StaticResource A_MenuDataItem_HorizonLife}"
                                                    Style="{StaticResource A_Style_Button_CreativeHubIconTile}"
                                                    local:TileMenuNavigationManager.GridX="1"
                                                    local:TileMenuNavigationManager.GridY="4"
                                                    local:TileMenuNavigationManager.LockState="{Binding IsHorizonLifeUnlocked, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_Converter_Boolean_To_LockState}}"
                                                    local:TileMenuNavigationManager.TileState="{Binding IsSelf, Converter={StaticResource A_Converter_BooleanToTileState}, RelativeSource={RelativeSource AncestorType=Page}, FallbackValue={x:Static local:TileState.Disabled}}"/>
                                    <local:FZButton x:Name="PART_Button_FollowPlayerToggle"
                                                    DataContext="{Binding FollowPlayerToggleDataItem}"
                                                    Style="{StaticResource A_Style_Button_CreativeHubToggleIconTile}"
                                                    local:TileMenuNavigationManager.GridX="1"
                                                    local:TileMenuNavigationManager.GridY="4"
                                                    local:TileMenuNavigationManager.TileState="{Binding IsSelf, Converter={StaticResource A_Converter_BooleanToTileState_Inverse}, RelativeSource={RelativeSource AncestorType=Page}, FallbackValue={x:Static local:TileState.Disabled}}"/>
                                </local:AutoSizeCanvas>
                            </StackPanel>
                        </Grid>
                    </StackPanel>
                </Grid>
            </Grid>
        </Border>
    </Grid>

</Page>
