<Page xmlns:local="clr-namespace:ForzaUI;assembly="
      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_UpgradePresets"
      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_QuickUpgradeSelectContent">
                <Grid ClipToBounds="True">
                    <local:FZMaterial x:Name="Icon"
                                      Style="{StaticResource A_Style_FZMaterial_Carousel_DefaultItemContent}"
                                      ImageSource="{Binding SmallThumbnail}"
                                      Color="{Binding Colour}"
                                      HorizontalAlignment="Center"
                                      VerticalAlignment="Center"
                                      GreedyMeasure="True"
                                      Stretch="Uniform">
                    </local:FZMaterial>
                    <Grid Visibility="{Binding Breadcrumb, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue={x:Static Visibility.Collapsed}}"
                        Height="36"
                        HorizontalAlignment="Right"
                        VerticalAlignment="Top">
                        <FZMaterial Preset="{StaticResource H_Roundtangle_Outer_1px}" Color="{StaticResource H_Color_Primary_Yellow}"/>
                        <local:FZTextBlock Text="{local:Loc InGameMarketplace.IDS_New}"
                                           Style="{StaticResource A_Style_FZTextBlock_CarSelectCarouseItem_StatusText}"
                                           Color="{StaticResource H_Color_Primary_Purple}" />
                    </Grid>
                </Grid>
                <DataTemplate.Triggers>
                    <!-- Set a fixed width for the first item, which is a car thumbnail and doesn't want to be scaled up -->
                    <DataTrigger Binding="{Binding Path=(Selector.AlternationIndex), RelativeSource={RelativeSource AncestorType=ContentControl}}"
                                 Value="0">
                        <Setter TargetName="Icon"
                                Property="Width"
                                Value="224" />
                        <Setter TargetName="Icon"
                                Property="Height"
                                Value="126" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

        </ResourceDictionary>
    </Page.Resources>

    <Grid>
        <!-- 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="PART_LayoutRoot" Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="VisualStateGroup">
                    <VisualState x:Name="PART_DefaultState" />
                    <VisualState x:Name="PART_NoClassSelectState">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainContent"
                                                           Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0"
                                                        Value="{x:Static Visibility.Collapsed}" />
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid x:Name="MainContent"
                  Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                  Width="{StaticResource A_Double_Carousel_7Item_Total_Width}"
                  Margin="96,0"
                  Height="{StaticResource H_Height_Upgrades}">
                <Grid.RowDefinitions>
                    <RowDefinition
                        Height="Auto" />
                    <RowDefinition
                        Height="Auto" />
                    <RowDefinition
                        Height="*" />
                </Grid.RowDefinitions>
                <ContentControl x:Name="ContentControl_SceneTitle"
                                    Content="{local:Loc ScreenTitles.IDS_UpgradePresets}"
                                    Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                    local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Upgrades.png"
                                    HorizontalAlignment="Left"
                                    Width="{StaticResource H_Width_Upgrades}" />

                <DockPanel Grid.Row="2"
                           HorizontalAlignment="Left"
                           Width="{StaticResource H_Width_Upgrades}"
                           DataContext="{Binding SelectedItem, ElementName=PART_UpgradesList}">
                    <ContentControl x:Name="Description"
                                    Style="{StaticResource A_Style_ContentControl_Header_Custom}"
                                    DockPanel.Dock="Top"
                                    HorizontalContentAlignment="Left"
                                    Width="{StaticResource H_Width_Upgrades}">
                        <FZTextBlock Style="{StaticResource H_Style_Text_DescriptionTitle}"
                                     FontFamily="Horizon_A"
                                     Text="{Binding Title}"/>
                    </ContentControl>
                    <ContentControl Template="{StaticResource A_ControlTemplate_SidePanelContent}"
                                    Width="{StaticResource H_Width_Upgrades}"
                                    DockPanel.Dock="Top">
                        <Decorator ClipToBounds="True" Margin="24">
                            <FZTextBlock Style="{StaticResource H_Style_Text_Description_Body_12px_Scrolling}" 
                                         CapHeight="14"
                                         TextAlignment="Left"
                                         Text="{Binding Description}"
                                         Margin="0,4"/>
                        </Decorator>
                    </ContentControl>
                </DockPanel>

                <DockPanel Margin="0,0,0,4" HorizontalAlignment="Left" Grid.Row="1">
                    <ScrollBar Style="{StaticResource H_Style_ScrollBar}"
                        Margin="8,0,0,0"
                        Minimum="{Binding ScrollWindowMin, ElementName=PART_UpgradesList}"
                        Maximum="{Binding ScrollWindowMax, ElementName=PART_UpgradesList}"
                        Value="{Binding ScrollWindowValue, ElementName=PART_UpgradesList, Mode=TwoWay}"
                        ViewportSize="{Binding ScrollWindowSize, ElementName=PART_UpgradesList}"
                        DockPanel.Dock="Right">
                        <DynamicData.Data>
                            <DynamicDataItem
                                Name="ScrollBarHideWhenNotNeeded"
                                DataType="Boolean"
                                Value="True" />
                        </DynamicData.Data>
                    </ScrollBar>
                    <local:WrapListBox x:Name="PART_UpgradesList"
                        Style="{StaticResource H_Style_UpgradeGrid_Square_3x3}"
                        ScrollOrientation="Vertical"
                        ItemsSource="{Binding Collection}"
                        SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                        ItemTemplate="{StaticResource A_DataTemplate_Carousel_QuickUpgradeSelectContent}"
                        AlternationCount="10000"
                        RoutedEventCommand.Action="{Binding ElementName=ButtonBarDisableMouseCursorMovement}"
                        RoutedEventCommand.Action2="{Binding ElementName=ButtonBarEnableMouseCursorMovement}" 
                        FocusOnPageFocusGained.SelectorSelectedItem="True"/>
                </DockPanel>
                
            </Grid>
        </Border>
    </Grid>
</Page>