<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_PreRaceEncounter"
      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>

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

        <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_PostRace_Gamerpic"
                                           CornerRadius="4" />


        <Style x:Key="A_Style_Animations"
               TargetType="{x:Type FrameworkElement}">
            <Style.Resources>
                <local:UIStoryboard x:Key="PART_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="PART_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="PART_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>


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

        <Style BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}"
               x:Key="A_Style_PreRaceBucketList_Top"
               TargetType="local:FZTextBlock">
            <Setter Property="TrackingAdjust"
                    Value="0.02" />
            <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>
    </Page.Resources>

    <Grid x:Name="PART_LayoutRoot">
        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <Decorator>
                <Decorator HorizontalAlignment="Left"
                           VerticalAlignment="Bottom"
                           Margin="0,0,0,207">
                    <Decorator HorizontalAlignment="Left"
                               Margin="53,0,0,0">
                        <DockPanel  Style="{StaticResource A_Style_Animations}"
                                    Opacity="0">
                            <local:FZMaterial Height="108"
                                              Width="108"
                                              Preset="{StaticResource A_FZMaterialPresetRoundtangle_PostRace_Gamerpic}"
                                              ImageSource="{Binding UserProfile, Converter={StaticResource A_GamerPicConverter}, ConverterParameter={StaticResource A_Size_PostRace_GamerPicSizeParams}}"
                                              Stretch="UniformToFill"    
                                              x:Name="Icon"
                                              RenderTransformOrigin="0.5,0.5">
                                <local:FZMaterial.RenderTransform>
                                    <ScaleTransform />
                                </local:FZMaterial.RenderTransform>
                            </local:FZMaterial>
                            <Decorator Width="16" />
                            <Grid x:Name="Titles" 
                                  DockPanel.Dock="Right">
                                <ContentControl Style="{StaticResource A_Style_ContentControl_AnimatedTagSlideFromBottom}"
                                                x:Name="Top"
                                                Margin="-5,0,0,0"
                                                VerticalAlignment="Top">
                                    <Grid Margin="5,0,0,0">
                                        <StackPanel Margin="3,0,0,0"
                                                    Orientation="Horizontal" >
                                            <ContentControl Style="{StaticResource H_Style_TemplatedElement_CarClassBadge_White}"
                                                            VerticalAlignment="Center"
                                                            Height="40"
                                                            local:BindingProxy.B="{Binding ClassID}"
                                                            local:BindingProxy.A="{Binding PerformanceIndex}">
                                            </ContentControl>
                                            <Decorator Width="14" />
                                            <StackPanel Orientation="Horizontal">
                                                <local:FZTextBlock Text="{Binding CarManufacturer}"
                                                                   Style="{StaticResource A_Style_PreRaceBucketList_Top}" />
                                                <Decorator Width="9" />
                                                <local:FZTextBlock Text="{Binding CarMediaName}"
                                                                   FontFamily="Horizon_B"
                                                                   Style="{StaticResource A_Style_PreRaceBucketList_Top}" />
                                            </StackPanel>
                                        </StackPanel>
                                    </Grid>
                                </ContentControl>
                                <ContentControl x:Name="Bottom"
                                                Style="{StaticResource A_Style_ContentControl_AnimatedTagSlideFromTop}"
                                                Margin="0,-15,0,-15"
                                                VerticalAlignment="Bottom">
                                    <Grid Height="{StaticResource A_Double_BottomLineHeight}"
                                          Margin="0,15,0,15"
                                          RenderTransform="{StaticResource A_Transform_Italic}">
                                        <local:FZTextBlock Text="{Binding UserProfile.FormattedGamertag}"
                                                           Style="{StaticResource A_Style_PreRaceBucketList_Bottom}" 
                                                           Margin="7,0,0,0"/>
                                    </Grid>
                                </ContentControl>
                            </Grid>
                        </DockPanel>
                    </Decorator>
                </Decorator>
            </Decorator>

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