<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_DangerSignLeaderboard"
      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>
            <GridLength x:Key="A_GridLength_Column_DriverLevel_Width">75</GridLength>
            <GridLength x:Key="A_GridLength_Column_DriverName_Width">410</GridLength>
            <GridLength x:Key="A_GridLength_Column_CarName_Width">202</GridLength>
            <GridLength x:Key="A_GridLength_Column_CarClass_Width">168</GridLength>
            <GridLength x:Key="A_GridLength_Column_Score_Width">148</GridLength>

            <!-- Row Templates -->
            <ControlTemplate x:Key="A_ControlTemplate_HeaderRow" TargetType="Control">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FlatPanel_HeaderPill_Green}" >
                    <Grid Margin="0,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverLevel_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverName_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_CarName_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_CarClass_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Score_Width}"/>
                        </Grid.ColumnDefinitions>
                        <local:FZTextBlock Grid.Column="1" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_DriverName}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="3" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_CarName}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="5" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_Class}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="7" Text="{Binding ScoreColumnTitle}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                    </Grid>
                </local:FZMaterial>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Row" TargetType="ListBoxItem">
                <Grid>
                    <StackPanel Name="Content" Orientation="Horizontal" Visibility="{Binding IsLoading, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                        <ContentControl Style="{StaticResource A_Style_ContentControl_SelectableRow}">
                            <Grid Margin="0,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverLevel_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverName_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_CarName_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_CarClass_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Score_Width}"/>
                                </Grid.ColumnDefinitions>
                                <ContentControl Grid.Column="0" Template="{StaticResource A_ControlTemplate_Cell_DriverLevel}" VerticalAlignment="Center"/>
                                <ContentControl Grid.Column="1" Template="{StaticResource A_ControlTemplate_Cell_DriverName}" VerticalAlignment="Center" />
                                <ContentControl Grid.Column="3" Template="{StaticResource A_ControlTemplate_Cell_CarName}" VerticalAlignment="Center" />
                                <ContentControl Grid.Column="5" Template="{StaticResource A_ControlTemplate_Cell_Class}" VerticalAlignment="Center" HorizontalAlignment="Left" />
                                <ContentControl Grid.Column="7" Template="{StaticResource A_ControlTemplate_Cell_AmbientChallengeScore}" VerticalAlignment="Center" />
                            </Grid>
                        </ContentControl>
                    </StackPanel>
                </Grid>
                <ControlTemplate.Triggers>
                   <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True">
                       <Setter Property="local:ZPanel.ZIndex" Value="1" />
                       <Setter Property="local:ZPanel.ClippingBias"  Value="10" />
                   </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <!-- Row Style -->
            <Style x:Key="A_Style_ListBoxItem_DriverList_StartingGrid" TargetType="ListBoxItem" BasedOn="{StaticResource A_Style_ListBoxItem_LeaderboardBase}">
                <Setter Property="Template" Value="{StaticResource A_ControlTemplate_Row}" />
            </Style>

            <Style x:Key="A_Style_ContentControl_AmbientChallengeLeaderboardButtonBar"
                   TargetType="ContentControl"
                   BasedOn="{StaticResource A_Style_ContentControl_DefaultButtonBar}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding HasPIClassLeaderboard}" Value="True">
                        <Setter Property="local:ControllerButtonPanel.BackDescription" Value="{Loc Scoreboard.IDS_SelectPIClassHelpButton}"/>
                    </DataTrigger>

                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding HasSeasonalLeaderboard}" Value="True"/>
                            <Condition Binding="{Binding ShowingSeasonalLeaderboard}" Value="True"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="local:ControllerButtonPanel.YDescription" Value="{Loc HelpButtons.IDS_ViewStandardLeaderboard}"/>
                    </MultiDataTrigger>

                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding HasSeasonalLeaderboard}" Value="True"/>
                            <Condition Binding="{Binding ShowingSeasonalLeaderboard}" Value="False"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="local:ControllerButtonPanel.YDescription" Value="{Loc HelpButtons.IDS_ViewSeasonalLeaderboard}"/>
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_ContentControl_AmbientChallengeLeaderboardTitleBlock"
                TargetType="ContentControl"
                BasedOn="{StaticResource A_Style_ContentControl_ScreenTitleBlock}">
                <Setter Property="local:BindingProxy.A" Value="/ForzaUI;component/Textures/Anthem/Icons/Titles/Leaderboards.png" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ShowingSeasonalLeaderboard}" Value="True">
                        <Setter Property="Content" Value="{Binding SeasonalLeaderboardName}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ShowingSeasonalLeaderboard}" Value="False">
                        <Setter Property="Content" Value="{Binding LeaderboardName}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <MappingConverter x:Key="A_MappingConverter_SceneEnum_To_ResetsInTimerVisibility" Default="{x:Static Visibility.Collapsed}">
                <MappingConverterEntry Key="{x:Static SceneEntryEnum.DragMeetLeaderboard}" Value="{x:Static Visibility.Visible}"/>
                <MappingConverterEntry Key="{x:Static SceneEntryEnum.TimeAttackLeaderboard}" Value="{x:Static Visibility.Visible}"/>
            </MappingConverter>
            
            <Style x:Key="A_Style_Decorator_ResetsWithSeason"
                   TargetType="{x:Type local:Decorator}">
                <Setter Property="Visibility"
                        Value="{Binding SceneEnum, Converter={StaticResource A_MappingConverter_SceneEnum_To_ResetsInTimerVisibility}}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ShowingSeasonalLeaderboard}" Value="True">
                        <Setter Property="Visibility"
                                Value="Visible"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
            <Style x:Key="A_Style_NetworkCountdownControl_ResetsWithSeason"
                   TargetType="{x:Type local:NetworkCountdownControl}"
                   BasedOn="{StaticResource A_Style_NetworkCountdownControl_Base}">
                <Setter Property="Template"
                        Value="{StaticResource A_ControlTemplate_CountdownSeriesEnds}" />
                <Setter Property="TimerDisplayName"
                        Value="{Loc ForzaEvents.IDS_ResetsIn}" />
                <Setter Property="CountdownType" 
                        Value="SeasonTimeRemaining"/>
                <Setter Property="GenerateFormattedString"
                        Value="True"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ShowingSeasonalLeaderboard}" Value="True">
                        <Setter Property="TimerDisplayName"
                                Value="{Loc ForzaEvents.IDS_TimeRemaining}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            
        </ResourceDictionary>
    </Page.Resources>

    <Border>
        <Grid x:Name="PART_LayoutRoot">
            <!-- Background Blur -->
           <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />
            <Grid Visibility="{Binding IsInPauseFlow, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                <local:FZMaterialGlassCapture />
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Popup_Background}"/>
            </Grid>

            <local:FZMaterialGlassCapture />

            <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
                <ContentControl x:Name="PART_DefaultHelpPanel"
                                local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                                local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_Filter}"
                                Style="{StaticResource A_Style_ContentControl_AmbientChallengeLeaderboardButtonBar}" />
            </ContentControl>

            <Border Style="{StaticResource A_Style_Border_ScenePadding}">
                <Grid>
                    <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
                        <StackPanel Orientation="Horizontal" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                            <ContentControl Style="{StaticResource A_Style_ContentControl_AmbientChallengeLeaderboardTitleBlock}" />
                        </StackPanel>

                        <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                                    Orientation="Vertical"
                                    HorizontalAlignment="Center">
                            <Control Style="{StaticResource A_Style_HeaderRow}"
                                     Template="{StaticResource A_ControlTemplate_HeaderRow}"
                                     Margin="0,0,0,5"/>
                            <local:CommonListBox x:Name="PART_ListBox_LeaderboardList" 
                                                 ItemsSource="{Binding LeadersList}" 
                                                 MaxHeight="540" 
                                                 ItemContainerStyle="{StaticResource A_Style_ListBoxItem_DriverList_StartingGrid}"  
                                                 Style="{StaticResource A_Style_CommonListBox_Leaderboard}" 
                                                 VerticalAlignment="Top"
                                                 VirtualizingStackPanel.VirtualizationMode="Recycling"
                                                 ScrollViewer.CanContentScroll="True"
                                                 Panel.ZIndex="2"/>
                            <Control Style="{StaticResource A_Style_FooterRow}" Template="{StaticResource A_ControlTemplate_FooterRow_Default}" />
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </Border>

            <Decorator Style="{StaticResource A_Style_Decorator_ResetsWithSeason}">
                <local:NetworkCountdownControl x:Name="ResetsInControl" Style="{StaticResource A_Style_NetworkCountdownControl_ResetsWithSeason}" Margin="0,0,10,16"/>
            </Decorator>
        </Grid>
    </Border>
</Page>
