<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"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

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

    <Page.Resources>
        <Double x:Key="A_Double_ListItem_Width">398</Double>
        <Double x:Key="A_Double_ListItem_Height">520</Double>
        <Thickness x:Key="A_Margin_ListItem">4,0</Thickness>

        <ItemsPanelTemplate x:Key="A_ItemsPanel_RaceMode">
            <StackPanel IsItemsHost="True"
                        Orientation="Horizontal"
                        Margin="{Convert {StaticResource A_Margin_ListItem}, Converter={StaticResource H_InvertConverter}}"/>
        </ItemsPanelTemplate>

        <Style x:Key="A_Style_FZMaterial_ShadowBase_Dynamic"
               TargetType="{Type FZMaterial}"
               BasedOn="{StaticResource A_Style_FZMaterial_ShadowBase_Dynamic}">
            <Setter Property="Margin" Value="-10"/>
        </Style>


         <Style x:Key="A_Style_ContentControl_RaceMode_ContainerStyle"
                TargetType="ContentControl"
                BasedOn="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle_SelectOnMouseHover}">
            <Style.Resources>
                <CornerRadius x:Key="A_CornerRadius_Dynamic_CarouselTile">3</CornerRadius>
                <Style x:Key="H_Style_TemplatedElement_MouseRollover"
                       BasedOn="{StaticResource A_Style_Control_CarouselItem_MouseRollover_AlwaysSelectWhenClicked}"
                       TargetType="{x:Type Control}">
                    <Setter Property="DynamicData.Data">
                        <Setter.Value>
                            <DynamicDataSource>
                                <DynamicDataItem Name="MouseRolloverCornerRadius"
                                                 DataType="CornerRadius"
                                                 Value="3" />
                                <DynamicDataItem Name="MouseRolloverDisableWhenSelected"
                                                 DataType="Boolean"
                                                 Value="False" />
                            </DynamicDataSource>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Style.Resources>
            <Setter Property="Margin" Value="{StaticResource A_Margin_ListItem}"/>
         </Style>

         <MappingConverter x:Key="A_RaceModeToBackgroundPathConverter">
            <MappingConverterEntry Key="{Static RaceMode.RallyRace}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyRaceImage.png" />
            <MappingConverterEntry Key="{Static RaceMode.RallyCross}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyCrossImage.png" />
         </MappingConverter>

        <MappingConverter x:Key="A_RaceModeToCompletedBackgroundPathConverter">
            <MappingConverterEntry Key="{Static RaceMode.RallyRace}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyRaceImage_Complete.png" />
            <MappingConverterEntry Key="{Static RaceMode.RallyCross}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyCrossImage_Complete.png" />
         </MappingConverter>

         <MappingConverter x:Key="A_RaceModeToLockedBackgroundPathConverter">
            <MappingConverterEntry Key="{Static RaceMode.RallyRace}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyRaceImage_Locked.png" />
            <MappingConverterEntry Key="{Static RaceMode.RallyCross}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyCrossImage_Locked.png" />
         </MappingConverter>

         <Style x:Key="A_Style_FZMaterial_RaceMode_Background" TargetType="{Type FZMaterial}">
            <Setter Property="ImageSource" Value="{Binding RaceMode, Converter={StaticResource A_RaceModeToBackgroundPathConverter}}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding State}" Value="{Static XAMLCampaignRaceModeOptionState.Complete}">
                    <Setter Property="ImageSource" Value="{Binding RaceMode, Converter={StaticResource A_RaceModeToCompletedBackgroundPathConverter}}"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding State}" Value="{Static XAMLCampaignRaceModeOptionState.Locked}">
                    <Setter Property="ImageSource" Value="{Binding RaceMode, Converter={StaticResource A_RaceModeToLockedBackgroundPathConverter}}"/>
                </DataTrigger>
            </Style.Triggers>
         </Style>

         <MappingConverter x:Key="A_RaceModeToBannerPathConverter">
            <MappingConverterEntry Key="{Static RaceMode.RallyRace}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyRace_Banner.png" />
            <MappingConverterEntry Key="{Static RaceMode.RallyCross}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyCross_Banner.png" />
         </MappingConverter>

         <MappingConverter x:Key="A_RaceModeToCompletedBannerPathConverter">
            <MappingConverterEntry Key="{Static RaceMode.RallyRace}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyRace_Banner_Complete.png" />
            <MappingConverterEntry Key="{Static RaceMode.RallyCross}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyCross_Banner_Complete.png" />
         </MappingConverter>

         <MappingConverter x:Key="A_RaceModeToLockedBannerPathConverter">
            <MappingConverterEntry Key="{Static RaceMode.RallyRace}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyRace_Banner_Locked.png" />
            <MappingConverterEntry Key="{Static RaceMode.RallyCross}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\RallyCross_Banner_Locked.png" />
         </MappingConverter>

         <Style x:Key="A_Style_FZMaterial_RaceMode_Banner" TargetType="{Type FZMaterial}">
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="GreedyMeasure" Value="True"/>
            <Setter Property="Stretch" Value="Uniform"/>
            <Setter Property="ImageSource" Value="{Binding RaceMode, Converter={StaticResource A_RaceModeToBannerPathConverter}}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding State}" Value="{Static XAMLCampaignRaceModeOptionState.Complete}">
                    <Setter Property="ImageSource" Value="{Binding RaceMode, Converter={StaticResource A_RaceModeToCompletedBannerPathConverter}}"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding State}" Value="{Static XAMLCampaignRaceModeOptionState.Locked}">
                    <Setter Property="ImageSource" Value="{Binding RaceMode, Converter={StaticResource A_RaceModeToLockedBannerPathConverter}}"/>
                </DataTrigger>
            </Style.Triggers>
         </Style>

         <MappingConverter x:Key="A_StateToFooterPathConverter" CheckEnumKey="XAMLCampaignRaceModeOptionState">
            <MappingConverterEntry Key="{Static XAMLCampaignRaceModeOptionState.Incomplete}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\Footer.png" />
            <MappingConverterEntry Key="{Static XAMLCampaignRaceModeOptionState.Complete}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\Footer_Complete.png" />
            <MappingConverterEntry Key="{Static XAMLCampaignRaceModeOptionState.Locked}" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\Footer_Locked.png" />
         </MappingConverter>

         <Style x:Key="A_Style_FZMaterial_RaceMode_Footer" TargetType="{Type FZMaterial}">
            <Setter Property="VerticalAlignment" Value="Bottom"/>
            <Setter Property="GreedyMeasure" Value="True"/>
            <Setter Property="Stretch" Value="Uniform"/>
            <Setter Property="ImageSource" Value="{Binding State, Converter={StaticResource A_StateToFooterPathConverter}}"/>
         </Style>

         <Style x:Key="A_Style_FZMaterial_RaceMode_FooterIcon" TargetType="{Type FZMaterial}">
            <Setter Property="HorizontalAlignment" Value="Right"/>
            <Setter Property="GetSizeFromTexture" Value="True"/>
            <Setter Property="ImageSource" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\Tick.png"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding State}" Value="{Static XAMLCampaignRaceModeOptionState.Locked}">
                    <Setter Property="ImageSource" Value="game:\media\UI\Textures\Data_Bound\PDLC2\RaceModeSelect\locked_padlock.png"/>
                </DataTrigger>
            </Style.Triggers>
         </Style>

        <MappingConverter x:Key="A_StateToFooterStringConverter" CheckEnumKey="XAMLCampaignRaceModeOptionState">
            <MappingConverterEntry Key="{Static XAMLCampaignRaceModeOptionState.Incomplete}" Value="{Loc Expansions.IDS_RaceModeSelect_Incomplete}" />
            <MappingConverterEntry Key="{Static XAMLCampaignRaceModeOptionState.Complete}" Value="{Loc Expansions.IDS_RaceModeSelect_Complete}" />
            <MappingConverterEntry Key="{Static XAMLCampaignRaceModeOptionState.Locked}" Value="{Loc Expansions.IDS_RaceModeSelect_Locked}" />
         </MappingConverter>

        <MappingConverter x:Key="A_StateToFooterStringColorConverter" Default="{StaticResource H_Color_Primary_White}">
            <MappingConverterEntry Key="{Static XAMLCampaignRaceModeOptionState.Complete}" Value="{StaticResource H_Color_Primary_Purple}" />
        </MappingConverter>

        <MappingConverter x:Key="A_StateToFooterStringOpacityConverter" Default="0.5">
            <MappingConverterEntry Key="{Static XAMLCampaignRaceModeOptionState.Complete}" Value="1" />
        </MappingConverter>

         <Style x:Key="A_Style_FZTextBlock_RaceMode_Footer" TargetType="{Type FZTextBlock}">
            <Setter Property="Text" Value="{Binding State, Converter={StaticResource A_StateToFooterStringConverter}}"/>
            <Setter Property="Color" Value="{Binding State, Converter={StaticResource A_StateToFooterStringColorConverter}}"/>
            <Setter Property="Opacity" Value="{Binding State, Converter={StaticResource A_StateToFooterStringOpacityConverter}}"/>
            <Setter Property="FontFamily" Value="Horizon_B"/>
            <Setter Property="CapHeight" Value="17"/>
            <Setter Property="Margin" Value="0,8"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
         </Style>

        <DataTemplate x:Key="A_DataTemplate_RaceModeItem">
            <Grid Width="{StaticResource A_Double_ListItem_Width}"
                  Height="{StaticResource A_Double_ListItem_Height}"
                  Margin="4"
                  IsHitTestVisible="False">
                <FZMaterial Style="{StaticResource A_Style_FZMaterial_RaceMode_Background}"/>
                <FZMaterial Style="{StaticResource A_Style_FZMaterial_RaceMode_Banner}"/>
                <FZMaterial Style="{StaticResource A_Style_FZMaterial_RaceMode_Footer}">
                    <Grid Margin="20,0"
                          VerticalAlignment="Center">
                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_RaceMode_Footer}"/>
                        <FZMaterial Style="{StaticResource A_Style_FZMaterial_RaceMode_FooterIcon}"/>
                    </Grid>
                </FZMaterial>
            </Grid>
        </DataTemplate>

        <Style x:Key="A_Style_FZRun_Description_BOLD" TargetType="local:FZRun">
            <Setter Property="FontFamily" Value="Horizon_C" />
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_Yellow}" />
        </Style>
        <MappingConverter x:Key="A_MappingConverter_BoldDescription">
            <MappingConverterEntry Key="{NoCase BOLD}" Value="{StaticResource A_Style_FZRun_Description_BOLD}" />
        </MappingConverter>
    </Page.Resources>

    <Grid>
        <FZMaterialGlassCapture />
        <FZMaterial Style="{StaticResource A_Style_FZMaterial_Popup_Background}" />
        <FZMaterialGlassCapture />
        <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
            <ControllerButtonPanel x:Name="PART_HelpPanel"
                Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <ControllerButtonControl
                    Button="{Binding Button, ElementName=SelectButtonInput}"
                    Description="{Loc HelpButtons.IDS_Select}" />
            </ControllerButtonPanel>
        </ContentControl>

        <Grid x:Name="PART_LayoutRoot">
            <Border Style="{StaticResource A_Style_Border_ScenePadding}">
                <DockPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Bottom"
                           Margin="0,0,0,74">
                    <ContentControl Content="{Loc ScreenTitles.IDS_Astra_RaceModeSelect}"
                                    Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                    HorizontalAlignment="Left"
                                    DockPanel.Dock="Top"/>
                    <FZMaterial x:Name="DescriptionPanel" DataContext="{Binding SelectedItem, ElementName=PART_ItemListBox}"
                                Style="{StaticResource H_Style_Container_GlassHighBlur_Description}"
                                Height="88" Margin="0,12,0,0"
                                Width="{Binding ActualWidth, ElementName=PART_ItemListBox}"
                                DockPanel.Dock="Bottom">
                        <local:FZTextBlock Text="{Binding Description}"
                                           MarkupConverter="{StaticResource A_MappingConverter_BoldDescription}"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Top"
                                           Margin="24,18"
                                           CapHeight="17"
                                           TextWrapping="Wrap"
                                           Color="{StaticResource A_Color_White}"
                                           local:ScreenReader.Event="OnChange"
                                           local:ScreenReader.ControlType="None"
                                           local:ScreenReader.Line="{Binding DescriptionScreenReader, Converter={StaticResource A_Converter_TrimInlineMarkup}}"
                                           local:ScreenReader.LineType="ItemDescription"/>
                    </FZMaterial>
                    <CommonListBox x:Name="PART_ItemListBox"
                                   ItemsPanel="{StaticResource A_ItemsPanel_RaceMode}"
                                   ItemContainerStyle="{StaticResource A_Style_ContentControl_RaceMode_ContainerStyle}"
                                   ItemTemplate="{StaticResource A_DataTemplate_RaceModeItem}"
                                   ItemsSource="{Binding Items}"
                                   local:FocusOnPageFocusGained.SelectorSelectedItem="True"
                                   SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                        <CommonListBox.Template>
                            <ControlTemplate TargetType="ItemsControl">
                                <ItemsPresenter/>
                            </ControlTemplate>
                        </CommonListBox.Template>
                    </CommonListBox>
                </DockPanel>
            </Border>
        </Grid>
    </Grid>
</Page>
