<Page xmlns:local="clr-namespace:ForzaUI;assembly="
      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"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      x:Class="ForzaUI.A_MarketplacePackSelect"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <Page.Resources>
        <ResourceDictionary>

            <System:Double x:Key="A_Double_MarketplacePackSelect_ContentHeight">456</System:Double>

            <Style x:Key="A_Style_Run_MarketplacePackText_THIN"
                TargetType="{x:Type local:FZRun}">
                <Setter Property="FontFamily" Value="Horizon_A"/>
            </Style>

            <Style x:Key="A_Style_Run_MarketplacePackText_BOLD"
                TargetType="{x:Type local:FZRun}">
                <Setter Property="FontFamily" Value="Horizon_A"/>
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_Green}" />
                <Setter Property="CapHeight" Value="40"/>
            </Style>

            <Style x:Key="A_Style_Run_MarketplacePackText_SMALL"
                TargetType="{x:Type local:FZRun}">
                <Setter Property="FontFamily" Value="Horizon_A"/>
                <Setter Property="CapHeight" Value="40"/>
            </Style>

            <Style x:Key="A_Style_Run_MarketplacePackText_BOLDDEFAULTSIZE"
                TargetType="{x:Type local:FZRun}">
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_Green}" />
            </Style>

            <!-- 
            to maintain compat with any other existing uses of the strings in the content DB, we are making our "BOLD" case 'small' for this scene
            so the 'default' case can be the regular size. we add 'SMALL' for strings that don't want their top line (or whatever) to be bold but still want it small (such as the Autoshow Car Vouchers)
            and finally adding BOLDDEFAULTSIZE, though currently unused, for any DLC that wants to highlight a keyword on the second line
    
            While this approach isn't as 'pure' as I'd like since it ties the DisplayNameMarkup in ContentOffers.sql a bit more closely to the places it is displayed in-game, that is already true 
            since it includes a newline char specifically for display and I couldn't find any other places it is used than here and Shared_FeaturedLiveTile's A_MappingConverter_FeaturedHeaderText, which I'm also updating.
            - plus the alternative would be either 
                a) having FeaturedMarketplaceLiveTileItem do string splitting on newline characters to make the top and bottom lines separate string properties, 
                   which would THEN require a new "TitleLineTwo" property on BaseFeaturedLiveTileItem, which we could put in a different textblock and style separately without requiring markup in the source strings
                or
                b) adding a second string to the db schema and making the strings authored for line1/line2. and they already have a "title"/"subtitle" for other purposes so that also feels a tad weird
            -->            
            <MappingConverter x:Key="A_MappingConverter_MarketplacePackText">
                <MappingConverterEntry Key="{NoCase THIN}" Value="{StaticResource A_Style_Run_MarketplacePackText_THIN}" />
                <MappingConverterEntry Key="{NoCase BOLD}" Value="{StaticResource A_Style_Run_MarketplacePackText_BOLD}" />
                <MappingConverterEntry Key="{NoCase SMALL}" Value="{StaticResource A_Style_Run_MarketplacePackText_SMALL}" />
                <MappingConverterEntry Key="{NoCase BOLDDEFAULTSIZE}" Value="{StaticResource A_Style_Run_MarketplacePackText_BOLDDEFAULTSIZE}" />
            </MappingConverter>

            <FZMaterialPresetRoundtangle
                x:Key="A_FZMaterialPresetRoundtangle_FlatPanel_All_MarketPlace"
                BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                CornerRadius="1" />

            
            <Style x:Key="A_Style_MarketPlaceBlammo_Purchased" TargetType="{x:Type ContentControl}" BasedOn="{StaticResource A_Style_MarketPlaceBlammoWithIcon}">
                <Style.Resources>
                    <Style x:Key="A_Style_BlammoText_Dynamic" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_CarSelectCarouseItem_StatusText}">
                        <Setter Property="Visibility" Value="Visible"/>
                        <Setter Property="Color" Value="{Binding Path=(local:BindingProxy.B), RelativeSource={RelativeSource TemplatedParent}}"/>
                        <Setter Property="Margin" Value="7,0"/>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"
                                         Value="{x:Static local:MarketplaceBlammoType.Purchased}">
                                <Setter Property="Margin"
                                        Value="24,0,7,0" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>

                    <Style x:Key="A_Style_BlammoIcon_Dynamic" TargetType="local:FZMaterial">
                        <Setter
                            Property="Visibility"
                            Value="Collapsed" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"
                                         Value="{x:Static local:MarketplaceBlammoType.Purchased}">
                                <Setter Property="ImageSource"
                                        Value="/ForzaUI;component/Textures/Data_Bound/Checkbox/Tick_Icon.png" />
                                <Setter Property="Color"
                                        Value="{StaticResource H_Color_Primary_Black}" />
                                <Setter Property="Visibility"
                                        Value="Visible" />
                                <Setter Property="Width"
                                        Value="22" />
                                <Setter Property="Height"
                                        Value="22" />
                                <Setter Property="HorizontalAlignment"
                                        Value="Left" />
                                <Setter Property="Margin"
                                        Value="2,0" />
                                                                
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                    
                </Style.Resources>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource Self}}" Value="{x:Static local:MarketplaceBlammoType.Purchased}">
                        <Setter Property="local:BindingProxy.A" Value="{StaticResource H_Color_Primary_Green}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <!-- ControlTemplates -->
            <DataTemplate x:Key="A_DataTemplate_Carousel_ThumbPathThumbnailItemContent">
                <Grid Name="ItemContainer" Margin="0">
                    <local:FZMaterial x:Name="Icon"
                                      ImageSource="{Binding ThumbPath}"
                                      Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_All_MarketPlace}"/>
                    <ContentControl Tag="{Binding BlammoType}"
                                    VerticalAlignment="Bottom"
                                    HorizontalAlignment="Right"
                                    Margin="4"
                                    Style="{StaticResource A_Style_MarketPlaceBlammo_Purchased}"/>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsFocused, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}}" Value="True">
                        <Setter TargetName="Icon" Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll}"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <Style BasedOn="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle}"
                   TargetType="ContentControl"
                   x:Key="A_Style_Carousel_ItemContainer">
                <Setter Property="Margin" Value="0,0,4,4"/>
            </Style>

            <Style x:Key="A_Style_ContentControl_AvailabilityDisplay" TargetType="{x:Type Control}">
                <Setter Property="Visibility" Value="{Binding DataValue, Converter={StaticResource A_StringVisConverter}}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Control}">
                            <StackPanel Name="AvailabilityDisplay" Orientation="Horizontal"
                                        Margin="0,30,0,0">
                                <local:FZTextBlock Name="AvailabilityText"
                                                       Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                                                       HorizontalAlignment="Center"
                                                       VerticalAlignment="Center"
                                                       CapHeight="20"
                                                       Color="{StaticResource H_Color_Primary_Green}"
                                                       Text="{Binding DataValue}"/>
                                <local:FZTextBlock Text="{Binding DataTitle}"
                                                       Style="{StaticResource A_Style_FZTextBlock_HorizonA}" CapHeight="20" VerticalAlignment="Center"
                                                       Margin="10,0,0,0" Color="{StaticResource A_Color_Tile_Title_Alternate}"/>
                            </StackPanel>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>


    
            <local:MappingConverter x:Key="A_MappingConverter_SceneEnumToSceneTitle">
                <local:MappingConverterEntry Key="{x:Static local:SceneEntryEnum.MarketplaceCarPacks}" Value="{local:Loc InGameMarketplace.IDS_CarPacks}" />
                <local:MappingConverterEntry Key="{x:Static local:SceneEntryEnum.MarketplaceExpansionPacks}" Value="{local:Loc InGameMarketplace.IDS_ExpansionPacks}"/>
            </local:MappingConverter>


            <Style x:Key="A_Style_FZTextBlock_AutoScroll_OptionsDescription" BasedOn="{StaticResource A_Style_FZTextBlock_DescriptionBlockBody}" TargetType="local:FZTextBlock">
                <Style.Resources>
                    <Style x:Key="A_Style_FZRun_Description_Markup_BOLD" TargetType="local:FZRun">
                        <Setter Property="FontFamily" Value="Horizon_C"/>
                        <Setter Property="Color" Value="{StaticResource H_Color_Primary_Green}" />
                    </Style>
                    <Style x:Key="A_Style_FZRun_Description_Markup_SUPERSCRIPT" TargetType="local:FZRun">
                        <Setter Property="SubscriptScale" Value="-0.75" />
                    </Style>
                    <MappingConverter x:Key="A_MappingConverter_Description" >
                        <MappingConverterEntry Key="{NoCase BOLD}" Value="{StaticResource A_Style_FZRun_Description_Markup_BOLD}" />
                        <MappingConverterEntry Key="{NoCase SUPERSCRIPT}" Value="{StaticResource A_Style_FZRun_Description_Markup_SUPERSCRIPT}" />
                    </MappingConverter>
                </Style.Resources>

                <Setter Property="Color" Value="{StaticResource A_Color_Body_Text}" />
                <Setter Property="MarkupConverter" Value="{StaticResource A_MappingConverter_Description}" />
                <Setter Property="TextWrapping" Value="Wrap" />
                <Setter Property="AutoScroll" Value="{StaticResource H_AutoScrollSettings_Descriptions}" />
                <Setter Property="AutoScroll.AllowScrolling" Value="True" />    
            </Style>
            
        </ResourceDictionary>
    </Page.Resources>

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

    <Grid x:Name="PART_LayoutRoot">
        <!-- Background Blur -->
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <!-- Bars -->
        <local:PlayerBarControl x:Name="TopBar"
                        Style="{StaticResource A_Style_PlayerBarControl}" />
        <ContentControl x:Name="BottomBar"
                        Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="PART_DefaultHelpPanel"
                            local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>

        <Border x:Name="Frame"
                Style="{StaticResource A_Style_Border_ScenePadding_Opus}">
            <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}">
                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                    <StackPanel Margin="44,54,44,0">
                        <Grid VerticalAlignment="Top">
                            <ContentControl x:Name="TitleBlock"
                                            Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                            Content="{Binding SceneEnum, Converter={StaticResource A_MappingConverter_SceneEnumToSceneTitle}}"
                                            Tag="{local:Loc ScreenTitles.IDS_Marketplace}"
                                            HorizontalAlignment="Left" />
                        </Grid>

                        <DockPanel x:Name="CenterContent"
                                   LastChildFill="True" Margin="0,0,0,8"
                                   DataContext="{Binding SelectedItem, ElementName=PART_PackList}"
                                   Height="{StaticResource A_Double_MarketplacePackSelect_ContentHeight}">

                            <ContentControl Template="{StaticResource A_ControlTemplate_DescriptionPanel}"
                                            x:Name="RightPanel"
                                            Width="364"
                                            Tag="{local:Loc InGameMarketplace.IDS_Description}"
                                            Content="{Binding Description}"
                                            DockPanel.Dock="Right"
                                            Margin="4,0,0,0">
                            </ContentControl>
                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}" Width="1308"
                                              Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterAll}">
                                <Grid ClipToBounds="True">
                                    <local:FZMaterial ImageSource="{Binding ImagePath}" Width="1308"
                                                      Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_All_MarketPlace}"/>
                                    <DockPanel>
                                        <StackPanel Margin="25" Orientation="Vertical"
                                                    HorizontalAlignment="Left"
                                                    VerticalAlignment="Bottom">
                                            <local:FZTextBlock CapHeight="48"
                                                               TextWrapping="Wrap"
                                                               TextAlignment="Left"
                                                               LineAdjust="-0.65"
                                                               Color="{StaticResource A_Color_Tile_Title_Alternate}"
                                                               Style="{StaticResource A_Style_FZTextBlock_Heading}"
                                                               FontFamily="Horizon_C"
                                                               Text="{Binding DisplayNameMarkup}"
                                                               MarkupConverter="{StaticResource A_MappingConverter_MarketplacePackText}" />
                                            <Control HorizontalAlignment="Left"
                                                     Style="{StaticResource A_Style_ContentControl_AvailabilityDisplay}"/>
                                        </StackPanel>
                                        <Grid Margin="14,14,14,12">
                                            <ContentControl Tag="{Binding BlammoType}"
                                                VerticalAlignment="Bottom"
                                                HorizontalAlignment="Right"
                                                Style="{StaticResource A_Style_MarketPlaceBlammo_Purchased}"/>
                                        </Grid>
                                    </DockPanel>
                                </Grid>
                            </local:FZMaterial>
                        </DockPanel>
                        <local:WrapListBox x:Name="PART_PackList"
                                               Focusable="False"
                                               Style="{StaticResource A_Style_Carousel_7Item}"
                                               ItemsSource="{Binding Collection}"
                                               ItemWidth="240"
                                               SelectionLimitTop="240"
                                               ItemHeight="156"
                                               Width="1676"
                                               ItemContainerStyle="{StaticResource A_Style_Carousel_ItemContainer}"
                                               ItemTemplate="{StaticResource A_DataTemplate_Carousel_ThumbPathThumbnailItemContent}"
                                               VerticalAlignment="Bottom" 
                                               SelectedItem="1"
                                               local:FocusOnPageFocusGained.SelectorSelectedItem="True">
                            <local:WrapListBox.EmptyItemStyle>
                                <Style TargetType="Control">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate>
                                                <local:FZMaterial Preset="{StaticResource H_GlassRoundtangle_3px}"
                                                                  Color="{StaticResource H_Color_Glass_Purple_20pc}"
                                                                  Margin="0,0,4,4"/>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </local:WrapListBox.EmptyItemStyle>
                        </local:WrapListBox>
                    </StackPanel>
                </Grid>
            </Grid>
        </Border>
    </Grid>
</Page>
