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

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

    <Page.Resources>

        <local:MappingConverter x:Key="A_Converter_RaceModeIcon">
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.LapsRace}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Circuit.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.P2P}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/P2P.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.CrossCountry}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Cross_Country.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.CrossCountryCircuit}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Cross_Country_Circuit.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.Scramble}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Scramble.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.TrailRace}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Trail.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.StreetRace}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Street_Race.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.King}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/King.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.TeamKing}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/King.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.Infection}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Infected.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.TeamInfected}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Survival.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.FlagRush}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Flag_Rush.png" />
            <local:MappingConverterEntry Key="{x:Static local:RaceMode.TeamFlagRush}"
                                     Value="/ForzaUI;component/Textures/Data_Bound/RaceMode/Flag_Rush.png" />
        </local:MappingConverter>

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

        <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_PostRace_FinishIcon"
                                           CornerRadius="6" />

        <Thickness x:Key="A_Thickness_BucketListInfoMargin">0,10,0,0</Thickness>
        <Thickness x:Key="A_Thickness_BucketListInfoMargin_CHS">0,18,0,0</Thickness>
        <Thickness x:Key="A_Thickness_BucketListInfoMargin_CHT">0,18,0,0</Thickness>
        <Thickness x:Key="A_Thickness_BucketListInfoMargin_JP">0,18,0,0</Thickness>
        <Thickness x:Key="A_Thickness_BucketListInfoMargin_KO">0,18,0,0</Thickness>

        <Style x:Key="A_Style_Animations"
               TargetType="{x:Type FrameworkElement}">
            <Style.Resources>
                <local:UIStoryboard x:Key="transition_in">
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Tag"
                                                   Storyboard.TargetName="Top">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                Value="1" />
                        <DiscreteDoubleKeyFrame KeyTime="0:0:1"
                                                Value="1" />
                        <LinearDoubleKeyFrame KeyTime="0:0:1.16"
                                              Value="0" />
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Tag"
                                                   Storyboard.TargetName="Bottom">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                Value="1" />
                        <DiscreteDoubleKeyFrame KeyTime="0:0:1"
                                                Value="1" />
                        <LinearDoubleKeyFrame KeyTime="0:0:1.16"
                                              Value="0" />
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"
                                                   Storyboard.TargetName="Icon">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                Value="0.0" />
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.8"
                                                Value="0.16" />
                        <EasingDoubleKeyFrame KeyTime="0:0:1.4"
                                              Value="1.0"
                                              EasingFunction="{local:ElasticEasing EasingMode=EaseOut, Oscillations=2, Springiness=7}" />
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)"
                                                   Storyboard.TargetName="Icon">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                Value="0.0" />
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.8"
                                                Value="0.16" />
                        <EasingDoubleKeyFrame KeyTime="0:0:1.4"
                                              Value="1.0"
                                              EasingFunction="{local:ElasticEasing EasingMode=EaseOut, Oscillations=2, Springiness=7}" />
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                Value="1" />
                        <DiscreteDoubleKeyFrame KeyTime="0:0:7.16"
                                                Value="1" />
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="MaxWidth"
                                                   Storyboard.TargetName="Titles">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                Value="0" />
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.76"
                                                Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:1.16"
                                              Value="1920"
                                              EasingFunction="{local:CubicEasing EasingMode=EaseIn}" />
                    </DoubleAnimationUsingKeyFrames>
                </local:UIStoryboard>
                <local:UIStoryboard x:Key="transition_out_forward">
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="MaxWidth"
                                                   Storyboard.TargetName="Titles">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.10"
                                                Value="1920" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.5"
                                              Value="0"
                                              EasingFunction="{local:CubicEasing EasingMode=EaseOut}" />
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.16"
                                                Value="1" />
                        <LinearDoubleKeyFrame KeyTime="0:0:0.6"
                                              Value="0" />
                    </DoubleAnimationUsingKeyFrames>

                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Tag"
                                                   Storyboard.TargetName="Top">
                        <!--Animate off-->
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                Value="0" />
                        <LinearDoubleKeyFrame KeyTime="0:0:0.16"
                                              Value="1" />
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Tag"
                                                   Storyboard.TargetName="Bottom">
                        <!--Animate off-->
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                Value="0" />
                        <LinearDoubleKeyFrame KeyTime="0:0:0.16"
                                              Value="1" />
                    </DoubleAnimationUsingKeyFrames>

                </local:UIStoryboard>
                <!--<local:UIStoryboard x:Key="transition_out_back"
                                    DurationOverride="0:0:0.3">
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Tag"
                                                   Storyboard.TargetName="{x:Null}">
                        <EasingDoubleKeyFrame KeyTime="0:0:0"
                                              Value="1" />
                    </DoubleAnimationUsingKeyFrames>
                </local:UIStoryboard>-->
            </Style.Resources>
            <Setter Property="local:UIPageTransitionManager.TransitionIndex"
                    Value="0" />
        </Style>

        <DropShadowEffect x:Key="A_DropShadowEffect_Default"
                          Color="{StaticResource A_Color_DropShadow}"
                          BlurRadius="0"
                          ShadowDepth="3" />

        <System:Double x:Key="A_Double_TopLineHeight">26</System:Double>
        <System:Double x:Key="A_Double_BottomLineHeight">50</System:Double>

        <Style BasedOn="{StaticResource A_Style_FZTextBlock_HorizonC}"
               x:Key="A_Style_PreRaceBucketList_Top"
               TargetType="local:FZTextBlock">
            <Setter Property="TrackingAdjust"
                    Value="0.12" />
            <Setter Property="Color"
                    Value="#fff" />
            <Setter Property="CapHeight"
                    Value="23" />
            <Setter Property="VerticalAlignment"
                    Value="Center" />
        </Style>
        <Style BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}"
               x:Key="A_Style_PreRaceBucketList_Bottom"
               TargetType="local:FZTextBlock">
            <Setter Property="Color"
                    Value="#fff" />
            <Setter Property="CapHeight"
                    Value="{StaticResource A_Double_BottomLineHeight}" />
        </Style>

        <local:MappingConverter x:Key="A_Converter_NullCollapsed"
                                Default="{x:Static Visibility.Visible}">
            <local:MappingConverterEntry Key="{x:Null}"
                                         Value="{x:Static Visibility.Collapsed}" />
        </local:MappingConverter>
        <local:MappingConverter x:Key="A_Converter_NullVisible"
                                Default="{x:Static Visibility.Collapsed}">
            <local:MappingConverterEntry Key="{x:Null}"
                                         Value="{x:Static Visibility.Visible}" />
        </local:MappingConverter>
    </Page.Resources>

    <Grid x:Name="LayoutRoot">
        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetScreenShadow_ARUI}" />

        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <Decorator>
                <Decorator HorizontalAlignment="Left"
                           VerticalAlignment="Bottom"
                           Margin="0,0,0,207">
                    <Decorator Width="1780"
                               HorizontalAlignment="Left"
                               Margin="53,0,0,0">
                        <StackPanel Orientation="Horizontal"
                                    Style="{StaticResource A_Style_Animations}"
                                    Opacity="0">
                            <local:FZMaterial Height="108"
                                              Width="108"
                                              Preset="{StaticResource A_FZMaterialPresetRoundtangle_PostRace_FinishIcon}"
                                              Color="{Binding InfluenceThread.Color}"
                                              x:Name="Icon"
                                              RenderTransformOrigin="0.5,0.5">
                                <local:FZMaterial.RenderTransform>
                                    <ScaleTransform />
                                </local:FZMaterial.RenderTransform>
                                <Grid>
                                    <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_PostRace_FinishIcon}"
                                                      ImageSource="{Binding RaceMode, Converter={StaticResource A_Converter_RaceModeIcon}}"
                                                      Stretch="UniformToFill" />
                                    <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_PostRace_FinishIcon}"
                                                      ImageSource="{Binding UserProfile, Converter={StaticResource A_GamerPicOrTeamProfileConverter}, ConverterParameter={StaticResource A_Size_PostRace_GamerPicSizeParams}}"
                                                      Visibility="{Binding UserProfile, Converter={StaticResource A_Converter_NullCollapsed}}"
                                                      Stretch="UniformToFill" />
                                </Grid>
                            </local:FZMaterial>
                            <Decorator Width="16" />
                            <StackPanel x:Name="Titles" Margin="0,2,0,0">
                                <ContentControl Style="{StaticResource A_Style_ContentControl_AnimatedTagSlideFromBottom}"
                                                x:Name="Top"
                                                Margin="-5,-5,-5,6">
                                    <Grid Margin="5"
                                          Height="{StaticResource A_Double_TopLineHeight}">
                                        <StackPanel Margin="3,0,0,2"
                                                    Orientation="Horizontal">
                                            <StackPanel Orientation="Horizontal"
                                                        RenderTransform="{StaticResource A_Transform_Italic}">
                                                <local:FZTextBlock Text="{Binding TopLine}"
                                                                   Style="{StaticResource A_Style_PreRaceBucketList_Top}" />
                                            </StackPanel>
                                        </StackPanel>
                                    </Grid>
                                </ContentControl>
                                <local:FZMaterial Height="7">
                                    <local:FZMaterial.Preset>
                                        <local:FZMaterialPresetRoundtangle CornerRadius="3.5" />
                                    </local:FZMaterial.Preset>
                                </local:FZMaterial>
                                <ContentControl Style="{StaticResource A_Style_ContentControl_AnimatedTagSlideFromTop}"
                                                Margin="-5,6,-5,-5"
                                                x:Name="Bottom">
                                    <Grid Margin="5"
                                          Height="{StaticResource A_Double_BottomLineHeight}"
                                          RenderTransform="{StaticResource A_Transform_Italic}">
                                        <Grid Margin="7,2,-3,0">
                                            <local:FZTextBlock Text="{Binding BottomLine, Converter={StaticResource A_StringToUpper}}"
                                                               Style="{StaticResource A_Style_PreRaceBucketList_Bottom}"
                                                               Visibility="{Binding UserProfile, Converter={StaticResource A_Converter_NullVisible}}"/>
                                            <local:FZTextBlock Text="{Binding UserProfile.FormattedGamertag, Converter={StaticResource A_StringToUpper}}"
                                                               Style="{StaticResource A_Style_PreRaceBucketList_Bottom}"
                                                               Visibility="{Binding UserProfile, Converter={StaticResource A_Converter_NullCollapsed}}"/>
                                        </Grid>
                                    </Grid>
                                </ContentControl>
                            </StackPanel>
                        </StackPanel>
                    </Decorator>
                </Decorator>
            </Decorator>

        </Grid>
    </Grid>
</Page>
