<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_LoadSavePropPrefab"
      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>
            <DataTemplate x:Key="A_DataTemplate_Carousel_PropPrefabItemContent">
                <DataTemplate.Resources>
                    <Style x:Key="H_Style_PrimaryText"
                           TargetType="local:FZTextBlock"
                           BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
                        <Setter Property="CapHeight"
                                Value="23" />
                        <Setter Property="Color"
                                Value="{StaticResource H_Color_Primary_Purple}" />
                        <Setter Property="TextAlignment"
                                Value="Center" />
                    </Style>

                    <Style x:Key="H_Style_SecondaryText"
                           TargetType="local:FZTextBlock"
                           BasedOn="{StaticResource A_Style_FZTextBlock_HorizonB}">
                        <Setter Property="CapHeight"
                                Value="18" />
                        <Setter Property="Color"
                                Value="{StaticResource H_Color_Primary_Purple}" />
                        <Setter Property="TextAlignment"
                                Value="Center" />
                        <Setter Property="Opacity"
                                Value="0.5" />
                    </Style>
                </DataTemplate.Resources>
                <Grid>
                    <Grid Visibility="{Binding IsNewItem, Converter={FZBooleanToVisibilityConverter InvertResult=True}, FallbackValue=Visible}">
                        <DockPanel
                            Visibility="{Binding IsReady, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Visible}"
                            Margin="8,12">
                            <FZTextBlock
                                Style="{StaticResource H_Style_PrimaryText}"
                                Text="{Binding DisplayName, Converter={StaticResource A_StringToUpper}, FallbackValue=-}"
                                DockPanel.Dock="Top" />
                            <FrameworkElement Height="6" DockPanel.Dock="Top" />
                            <FZTextBlock
                                Style="{StaticResource H_Style_SecondaryText}"
                                Text="{Binding UserProfile.FormattedGamertag, FallbackValue=-}"
                                DockPanel.Dock="Top" />
                            <FZMaterial
                                ImageSource="{Binding Thumbnail}"
                                Margin="0,8,0,0"
                                Width="240"
                                Height="240"
                                Visibility="{Binding Downloaded, RelativeSource={RelativeSource Self}, Converter={FZBooleanToVisibilityConverter}}" />
                        </DockPanel>
                        <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>
                    <StackPanel
                        Visibility="{Binding IsNewItem, Converter={FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}"
                        Orientation="Vertical"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center">
                        <FZMaterial
                            ImageSource="game:\Media\UI\Textures\Data_Bound\ui_symbols\Save_Icon.png"
                            Width="110"
                            Height="144"
                            Margin="0,0,0,51"
                            Color="{StaticResource H_Color_Primary_Purple}"/>
                        <FZTextBlock
                            Style="{StaticResource H_Style_PrimaryText}"
                            Text="{Loc Storefront.IDS_SaveNewPropPrefab}"/>
                    </StackPanel>
                </Grid>
            </DataTemplate>


            <Style
                x:Key="H_Style_SidePanelItemWithHeader"
                TargetType="{Type HeaderedContentControl}">
                <Setter Property="Height" Value="74" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{Type HeaderedContentControl}">
                            <UniformGrid Columns="1" Margin="2">
                                <ContentPresenter ContentSource="Header"/>
                                <ContentPresenter ContentSource="Content"/>
                            </UniformGrid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="HeaderTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <FZTextBlock
                                Style="{StaticResource A_Style_FZTextBlock_InfoLabel}"
                                Text="{Binding Converter={StringToUpper}}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Setter Property="ContentTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <FZTextBlock
                                Style="{StaticResource A_Style_FZTextBlock_InfoValue}"
                                Text="{Binding Converter={StringToUpper}}" />
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_Carousel_PropPrefabItem">
                <Control Template="{StaticResource A_ControlTemplate_Carousel_PropPrefabItem}" />
            </DataTemplate>
        </ResourceDictionary>
    </Page.Resources>

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

        <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}">
            <StackPanel
                Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                VerticalAlignment="Center"
                HorizontalAlignment="Center">
                <StackPanel Margin="15,0,0,0">
                    <ContentControl
                        x:Name="ContentControl_SceneTitle"
                        Content="{Binding Title}"
                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                        HorizontalAlignment="Left" />

                    <FZTabButtonsSelector
                        x:Name="PART_PropPrefabCategoryList"
                        ItemsSource="{Binding PropPrefabCategories}"
                        SelectedItem="{Binding SelectedCategory}"
                        Style="{StaticResource H_Style_TabBar}"
                        HorizontalAlignment="Left" />
                </StackPanel>

                <Grid Margin="15,0,0,0">
                    <local:WrapListBox Style="{StaticResource H_Style_FullScreenCarousel_TwoRows}"
                                       ItemTemplate="{StaticResource A_DataTemplate_Carousel_PropPrefabItem}"
                                       ItemsSource="{Binding PropPrefabCollectionDataSource, RelativeSource={RelativeSource AncestorType=Page}}"
                                       SelectionLimitTop="310"
                                       Margin="-18,0,0,0"
                                       ItemContainerStyle="{StaticResource H_Style_ContentControl_CustomisationItem_ContainerStyle_TransparentBackground}"
                                       x:Name="PART_ItemList"/>
                    <ContentControl Template="{StaticResource A_ControlTemplate_UserContent_SidePanel}" 
                                    Style="{StaticResource A_Style_ControlTemplate_UserContent_SidePanel_TwoRowsCarousel}"
                                    DataContext="{Binding SelectedItem, ElementName=PART_ItemList}"
                                    VerticalAlignment="Top">
                        <StackPanel x:Name="PopularityInfo_Panel"
                                    Orientation="Vertical"
                                    VerticalAlignment="Top"
                                    Margin="12,0"
                                    DataContext="{Binding SelectedItem, ElementName=PART_ItemList}">
                            <HeaderedContentControl Style="{StaticResource H_Style_UserContent_SidePanelItemWithHeader}"
                                                    Header="{Loc Storefront.IDS_Downloads}"
                                                    Content="{Binding DownloadCount, Converter={NumUnitConverter FractionDigits=0}, FallbackValue=-}"/>
                            <FZMaterial Style="{StaticResource H_Style_StatDivider_InfoPanel}" />
                            <HeaderedContentControl Style="{StaticResource H_Style_UserContent_SidePanelItemWithHeader}"
                                                    Header="{Loc Storefront.IDS_Likes}"
                                                    Content="{Binding LikeCount, Converter={NumUnitConverter FractionDigits=0}, FallbackValue=-}"/>
                            <FZMaterial Style="{StaticResource H_Style_StatDivider_InfoPanel}" />
                            <StackPanel Visibility="{Binding UserProfile.IsLocalPlayer, Converter={StaticResource A_Converter_BoolToVis_Inverted}}">
                                <HeaderedContentControl Style="{StaticResource H_Style_UserContent_SidePanelItemFollower}"
                                                        Header="{Loc Storefront.IDS_LabelCreatorNotFollowed }"
                                                        Content="/ForzaUI;component/Textures/Data_Bound/CreativeHub/FollowedHeart.png"/>
                                <FZMaterial Style="{StaticResource H_Style_StatDivider_InfoPanel}" />
                            </StackPanel>
                        </StackPanel>
                    </ContentControl>

                    <local:NavigationArrows Style="{StaticResource A_Style_Control_NavigationArrows}"
                                            Template="{StaticResource A_ControlTemplate_NavigationArrows_FullscreenCarousel}"
                                            Height="205"
                                            Margin="290,0,0,80"
                                            VerticalAlignment="Center"
                                            CanSelectPrev="{Binding CanSelectPrev, ElementName=PART_ItemList}"
                                            CanSelectNext="{Binding CanSelectNext, ElementName=PART_ItemList}"
                                            ScrollPagePrevCommand="{Binding ScrollPagePrevCommand, ElementName=PART_ItemList}"
                                            ScrollPageNextCommand="{Binding ScrollPageNextCommand, ElementName=PART_ItemList}" />
                </Grid>
            </StackPanel>
        </Border>
    </Grid>
</Page>