<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_BucketListLeaderboard"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Name="p1"
      >

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

    <Page.Resources>
        <ResourceDictionary>
            <GridLength x:Key="A_GridLength_Column_Position_Width">52</GridLength>
            <GridLength x:Key="A_GridLength_Column_PositionSpacer_Width">18</GridLength>
            <GridLength x:Key="A_GridLength_Column_DriverName_Width">790</GridLength>
            <GridLength x:Key="A_GridLength_Column_Score_Width">148</GridLength>

            <Style x:Key="A_Style_SpacedCell" TargetType="ContentControl" BasedOn="{StaticResource A_Style_Cell}">
                <Setter Property="Margin" Value="26,0,95.5,0" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_BucketListChallengeScoreHeading" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_DriverListHeading}">
                <Setter Property="Text" Value="{local:Loc Scoreboard.IDS_Time}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.SpeedTrap}">
                        <Setter Property="Text" Value="{local:Loc PreRaceMenu.IDS_Speed}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.SpeedZone}">
                        <Setter Property="Text" Value="{local:Loc PreRaceMenu.IDS_Speed}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.MultiSpeedTrap}">
                        <Setter Property="Text" Value="{local:Loc PreRaceMenu.IDS_Speed}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.MultiSpeedZone}">
                        <Setter Property="Text" Value="{local:Loc PreRaceMenu.IDS_Speed}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.DangerSign}">
                        <Setter Property="Text"
                                Value="{local:Loc MyProfile.IDS_Distance}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.DriftZone}">
                        <Setter Property="Text"
                                Value="{local:Loc InGame.IDS_Points}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.SkillScore}">
                        <Setter Property="Text"
                                Value="{local:Loc InGame.IDS_Points}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.SkillDrive}">
                        <Setter Property="Text"
                                Value="{local:Loc InGame.IDS_Points}" />
                    </DataTrigger>

                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.StuntDrive}">
                        <Setter Property="Text"
                                Value="{local:Loc InGame.IDS_Header_Score}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ChallengeType}"
                                 Value="{x:Static local:BucketListChallengeType.SkillMastery}">
                        <Setter Property="Text"
                                Value="{local:Loc InGame.IDS_Header_Score}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <!-- Row Templates -->
            <ControlTemplate x:Key="A_ControlTemplate_HeaderRow" TargetType="Control">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FlatPanel_HeaderPill}" >
                    <Grid Margin="18,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Position_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_PositionSpacer_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverName_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Score_Width}"/>
                        </Grid.ColumnDefinitions>
                        <local:FZTextBlock Grid.Column="0" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_Position}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}"/>
                        <local:FZTextBlock Grid.Column="2" Text="{local:Loc PreRaceMenu.IDS_StartingGrid_DriverName}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="4" Style="{StaticResource A_Style_FZTextBlock_BucketListChallengeScoreHeading}" />
                    </Grid>
                </local:FZMaterial>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Cell_Score">
                <Grid>
                    <local:FZTextBlock Text="{Binding Score}" Style="{StaticResource A_Style_FZTextBlock_LeaderboardRow}"/>
                </Grid>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Row" TargetType="ListBoxItem">
                <Grid Margin="{StaticResource A_Thickness_LeaderboardRowMargin}">
                    <StackPanel Name="Content" Orientation="Horizontal" Visibility="{Binding IsLoading, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                        <ContentControl Style="{StaticResource A_Style_ContentControl_SelectableRow}">
                            <Grid Margin="18,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Position_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_PositionSpacer_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_DriverName_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_Position}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="-18,0,0,0"/>
                                <ContentControl Grid.Column="2" Template="{StaticResource A_ControlTemplate_Cell_DriverName}" VerticalAlignment="Center" />
                                <ContentControl Grid.Column="4" Template="{StaticResource A_ControlTemplate_Cell_Score}" VerticalAlignment="Center" />
                            </Grid>
                        </ContentControl>
                    </StackPanel>
                </Grid>
            </ControlTemplate>

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

        </ResourceDictionary>
    </Page.Resources>

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

            <Grid Visibility="{Binding ShowBlur, 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="DefaultHelpPanel"
                    local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                    local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                    local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_Filter}"
                    Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
            </ContentControl>

            <local:NetworkCountdownControl Style="{StaticResource A_Style_NetworkCountdownControl_BucketListSetup}" />

            <Border Style="{StaticResource A_Style_Border_ScenePadding}">
                <StackPanel Orientation="Vertical" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,90,0,0">
                    <StackPanel Orientation="Horizontal" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                        <ContentControl Content="{Binding LeaderboardName, Converter={StaticResource A_StringToUpper}}" Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                                local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Leaderboards.png" />
                    </StackPanel>

                    <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                                Orientation="Horizontal"
                                HorizontalAlignment="Center">
                        <StackPanel>
                            <Control Style="{StaticResource A_Style_HeaderRow}" Template="{StaticResource A_ControlTemplate_HeaderRow}" />
                            <local:CommonListBox x:Name="PART_ListBox_LeaderboardList" ItemsSource="{Binding LeadersList}" MaxHeight="561" 
                                                         ItemContainerStyle="{StaticResource A_Style_ListBoxItem_DriverList_Bucketlist}"  
                                                         Style="{StaticResource A_Style_CommonListBox_Leaderboard}" 
                                                         VerticalAlignment="Top"
                                                         VirtualizingStackPanel.VirtualizationMode="Recycling" ScrollViewer.CanContentScroll="true"/>
                            <Control Style="{StaticResource A_Style_FooterRow}" Template="{StaticResource A_ControlTemplate_FooterRow_Default}" />
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </Border>
        </Grid>
    </Border>
</Page>
