<Page x:Class="ForzaUI.Scenes.Anthem.A_PlayerSpotlightPanel"
      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"  
      mc:Ignorable="d"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
	  Style="{StaticResource A_Style_Page_Generic}">
    <Page.Resources>

        <Size x:Key="A_Size_PostRace_GamerPicSizeParams">424,424</Size>

        <CornerRadius x:Key="A_CornerRadius_Line">5</CornerRadius>
        <local:FZMaterialPresetRoundtangle x:Key="A_Preset_Line"
                                           CornerRadius="{StaticResource A_CornerRadius_Line}" />

        <Style x:Key="A_Style_FZMaterial_Line"
               TargetType="local:FZMaterial">
            <Setter Property="Height"
                    Value="10" />
            <Setter Property="Preset"
                    Value="{StaticResource A_Preset_Line}" />
        </Style>

        <System:Double x:Key="A_Double_ContentMaxWidth">1000</System:Double>

        <System:Double x:Key="A_Double_LineMinWidth">30</System:Double>
        <System:Double x:Key="A_Double_TeamTitle_SpacerWidth">36</System:Double>
        <GridLength x:Key="A_GridLength_TeamTitle_SpacerWidth">36</GridLength>

        <Color x:Key="A_Colour_Blue1">#00D8FF</Color>
        <Color x:Key="A_Colour_Blue2">#007FFF</Color>
        <Color x:Key="A_Colour_Red1">#FF393D</Color>
        <Color x:Key="A_Colour_Red2">#D20005</Color>

        <local:MappingConverter x:Key="A_Converter_TeamToGradientStop1"
                                Default="{StaticResource A_Colour_Red1}">
            <local:MappingConverterEntry Key="1"
                                         Value="{StaticResource A_Colour_Blue1}" />
        </local:MappingConverter>
        <local:MappingConverter x:Key="A_Converter_TeamToGradientStop2"
                                Default="{StaticResource A_Colour_Red2}">
            <local:MappingConverterEntry Key="1"
                                         Value="{StaticResource A_Colour_Blue2}" />
        </local:MappingConverter>

        <local:LinearTransformConverter x:Key="A_Converter_Identity" />

        <ControlTemplate x:Key="A_Template_SplitGradientLine"
                         TargetType="Control">
            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Line}"
                              CaptureSubgraph="True"
                              VerticalAlignment="Bottom"
                              Preset="{StaticResource A_Preset_Line}">
                <Decorator ClipToBounds="True">
                    <Decorator Width="0"
                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                        <local:FZMaterial Width="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource A_Converter_Identity}}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
                            <local:FZMaterial.Preset>
                                <local:FZMaterialPresetRoundtangle GradientAngle="90"
                                                                   GradientColorA="{Binding TeamID, Converter={StaticResource A_Converter_TeamToGradientStop1}}"
                                                                   GradientColorB="{Binding TeamID, Converter={StaticResource A_Converter_TeamToGradientStop2}}" />
                            </local:FZMaterial.Preset>
                        </local:FZMaterial>
                    </Decorator>
                </Decorator>
            </local:FZMaterial>
        </ControlTemplate>

    </Page.Resources>
    <Grid>

        <DockPanel Width="{StaticResource A_Double_ContentMaxWidth}">
            <Decorator Width="{StaticResource A_Double_LineMinWidth}"
                       DockPanel.Dock="Left" />
            <Decorator Width="{StaticResource A_Double_LineMinWidth}"
                       DockPanel.Dock="Left" />
            <Decorator Width="{StaticResource A_Double_TeamTitle_SpacerWidth}"
                       DockPanel.Dock="Left" />
            <Decorator Width="{StaticResource A_Double_TeamTitle_SpacerWidth}"
                       DockPanel.Dock="Left" />
            <Decorator x:Name="ComputedTeamTitleTextWidth" />
        </DockPanel>


        <StackPanel HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    MaxWidth="{StaticResource A_Double_ContentMaxWidth}">
            <local:FZMaterial ImageSource="{Binding UserProfile, Converter={StaticResource A_GamerPicOrTeamProfileConverter}, ConverterParameter={StaticResource A_Size_PostRace_GamerPicSizeParams}}"
                              Height="200"
                              Width="200">
                <local:FZMaterial.Preset>
                    <local:FZMaterialPresetRoundtangle CornerRadius="10" />
                </local:FZMaterial.Preset>
            </local:FZMaterial>

            <Decorator Height="30" />

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="{StaticResource A_Double_LineMinWidth}" />
                    <ColumnDefinition Width="{StaticResource A_GridLength_TeamTitle_SpacerWidth}" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="{StaticResource A_GridLength_TeamTitle_SpacerWidth}" />
                    <ColumnDefinition MinWidth="{StaticResource A_Double_LineMinWidth}" />
                </Grid.ColumnDefinitions>

                <Control Template="{StaticResource A_Template_SplitGradientLine}"
                         Tag="{Binding ActualWidth, ElementName=BottomLine}"
                         Grid.Column="0"
                         HorizontalContentAlignment="Left" />
                <Control Template="{StaticResource A_Template_SplitGradientLine}"
                         Tag="{Binding ActualWidth, ElementName=BottomLine}"
                         Grid.Column="4"
                         HorizontalContentAlignment="Right" />

                <Decorator RenderTransformOrigin="0.5,0.5"
                           Grid.Column="2"
                           RenderTransform="{StaticResource A_Transform_Italic}">
                    <local:FZTextBlock Text="{Binding TeamTitle, Converter={StaticResource A_StringToUpper}}"
                                       Style="{StaticResource A_Style_FZTextBlock_HorizonC}"
                                       CapHeight="36"
                                       Stretch="Uniform"
                                       StretchDirection="DownOnly"
                                       MaxWidth="{Binding ActualWidth, ElementName=ComputedTeamTitleTextWidth}"
                                       TextAlignment="Center"
                                       Color="#fff" />

                </Decorator>
            </Grid>


            <Decorator Height="30" />

            <Decorator RenderTransformOrigin="0.5,0.5"
                       RenderTransform="{StaticResource A_Transform_Italic}">
                <local:FZTextBlock Text="{Binding UserProfile.FormattedGamertag, Converter={StaticResource A_StringToUpper}}"
                                   Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                                   CapHeight="100"
                                   Color="#fff"
                                   StretchDirection="DownOnly"
                                   TextAlignment="Center" />
            </Decorator>

            <Decorator Height="30" />

            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Line}"
                              x:Name="BottomLine">
                <local:FZMaterial.Preset>
                    <local:FZMaterialPresetRoundtangle BasedOn="{StaticResource A_Preset_Line}"
                                                       GradientAngle="90"
                                                       GradientColorA="{Binding TeamID, Converter={StaticResource A_Converter_TeamToGradientStop1}}"
                                                       GradientColorB="{Binding TeamID, Converter={StaticResource A_Converter_TeamToGradientStop2}}" />
                </local:FZMaterial.Preset>
            </local:FZMaterial>

            <local:FZMaterial Width="128"
                              Height="128"
                              Margin="0,-15,0,0"
                              ImageSource="/ForzaUI;component/Textures/Anthem/Icons/Spatial/Driverlabel/Arrow.png" />
        </StackPanel>
    </Grid>

</Page>
