<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.Scenes.Anthem.A_PostRacePodiumFinishPanel"
      mc:Ignorable="d"
      x:Name="Page"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_PostRace}" />
    </local:UIPageTransitionManager.TransitionManager>
    <Page.Resources>

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

        <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_PostRace_Gamerpic"
                                           Saturation="1" />

        <ImageBrush x:Key="A_Brush_GamerpicOpacity"
                    ImageSource="/ForzaUI;component/Textures/Data_Bound/PostRace/Gamerpic_Mask.png" />

        <Style x:Key="A_Style_Control_PostRace_TotalLabelBlock"
               TargetType="Control"
               BasedOn="{StaticResource A_Style_FrameworkElement_PostRace_TotalLabelBlock}">
            <Setter Property="Tag"
                    Value="" />
            <Setter Property="HorizontalContentAlignment"
                    Value="Left" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <local:FZTextBlock Style="{DynamicResource A_Style_FZTextBlock_PostRace_TotalText}"
                                           Text="{TemplateBinding Tag}"
                                           CapHeight="52"
                                           VerticalAlignment="Center"
                                           HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="local:ZPanel.Transform">
                <Setter.Value>
                    <Transform3DGroup>
                        <RotateTransform3D />
                        <TranslateTransform3D OffsetZ="0" />
                    </Transform3DGroup>
                </Setter.Value>
            </Setter>
        </Style>

        <System:Double x:Key="A_Double_TeamNameLabelCapHeight">134</System:Double>

        <Style x:Key="A_Style_Control_PostRace_TeamNameBlock"
               TargetType="Control"
               BasedOn="{StaticResource A_Style_Control_PostRace_TotalLabelBlock}">
            <Setter Property="HorizontalAlignment"
                    Value="Left" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Viewbox Stretch="Uniform"
                                 HorizontalAlignment="Left"
                                 StretchDirection="DownOnly">
                            <Grid>
                                <StackPanel Orientation="Horizontal">
                                    <!--The additive presets in here only work when you null the motionblur effect on the control root.  This is used by impact bloom on the total values-->
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_PostRace_TotalText}"
                                                       Preset="{StaticResource A_FZMaterialPresetAdditive}"
                                                       CapHeight="{DynamicResource A_Double_TeamNameLabelCapHeight}"
                                                       x:Name="TickerValue"
                                                       Text="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"
                                                       VerticalAlignment="Center" />

                                </StackPanel>
                            </Grid>
                        </Viewbox>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <local:OffsetKeyTime x:Key="A_KeyTime_TeamScore_Begin"
                             KeyTime="0:0:0" />

        <local:OffsetKeyTime x:Key="A_KeyTime_TeamScore_EventWinner_Begin"
                             KeyTime="{StaticResource A_KeyTime_TeamScore_Begin}" />
        <local:OffsetKeyTime x:Key="A_KeyTime_TeamScore_EventWinner_Gamerpic_In"
                             KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_Begin}"
                             Offset="0:0:0.3" />
        <local:OffsetKeyTime x:Key="A_KeyTime_TeamScore_EventWinner_End"
                             KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_Begin}"
                             Offset="0:0:4" />

        <local:OffsetKeyTime x:Key="A_KeyTime_TeamScore_EventWinner_NextPage"
                             KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_End}"
                             Offset="-0:0:0.0" />


        <local:UIStoryboard x:Key="A_Storyboard_GamerpicIn"
                            DurationOverride="{StaticResource A_Duration_Transition_ElementIn}">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(local:ZPanel.Transform).(Transform3DGroup.Children)[1].(TranslateTransform3D.OffsetX)"
                                           Storyboard.TargetName="{x:Null}">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="-1000" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.43"
                                      Value="0"
                                      EasingFunction="{local:ExponentialEasing EasingMode=EaseIn}" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity"
                                           Storyboard.TargetName="{x:Null}">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="0" />
                <LinearDoubleKeyFrame KeyTime="0:0:0.129"
                                      Value="1" />
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <local:OffsetKeyTime x:Key="A_KeyTime_Continue"
                             Offset="0:0:20" />

        <local:UIStoryboard x:Key="A_Storyboard_PostRace_SeriesComplete">
            <local:UIStoryboard.TriggerAnimation>
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_Gamerpic_In}"
                                         Storyboard.TargetName="Gamerpic"
                                         Storyboard="{StaticResource A_Storyboard_GamerpicIn}" />
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_Begin}"
                                         Storyboard.TargetName="TotalLabel"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshInFromLeft_Slide}" />
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_Begin}"
                                         Storyboard.TargetName="TotalValue"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshInFromLeft}" />
                <local:AudioEventFireTrigger local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_Begin}"
                                             AudioEvent="/Master/UI/PostRace/HZ2_SFX_HUD_PostRace_CashRewardsTotalOn_01" />
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_Begin}"
                                         Storyboard.TargetName="BalanceValue"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshInFromRight_Slide}" />

                <!--local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_End}"
                                         Storyboard.TargetName="TotalLabel"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshOutToRight}" />
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_End}"
                                         Storyboard.TargetName="TotalValue"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshOutToRight}" />
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_End}"
                                         Storyboard.TargetName="BalanceValue"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshOutToLeft}" />
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_End}"
                                         Storyboard.TargetName="Gamerpic"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshOutToLeft}" />

                <local:RaiseFzEvent Storyboard.TargetName="EventFire"
                                    EventName="deprecated"
                                    local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Continue}" />
                <local:RaiseFzEvent Storyboard.TargetName="EventFire"
                                    EventName="deprecated2"
                                    local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Continue}" /-->
            </local:UIStoryboard.TriggerAnimation>
        </local:UIStoryboard>

        <Color x:Key="A_Colour_Background1">#FF064b98</Color>
        <Color x:Key="A_Colour_Background2">#FF00965b</Color>

        <local:MappingConverter x:Key="A_Converter_PodiumText"
                                Default="{local:Loc InGame.IDS_PostRace_Podium}">
            <local:MappingConverterEntry Key="1"
                                         Value="{local:Loc InGame.IDS_PostRace_PodiumWinner}" />
        </local:MappingConverter>
        
    </Page.Resources>

    <Grid Height="540"
          Width="1920">


        <local:FZMaterial>
            <local:FZMaterial.Preset>
                <local:FZMaterialPresetRoundtangle BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                                                   GradientColorA="{StaticResource A_Colour_Background1}"
                                                   GradientColorB="{StaticResource A_Colour_Background2}"
                                                   GradientAngle="90" />
            </local:FZMaterial.Preset>
        </local:FZMaterial>
        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PostRace_Hatching}"
                          x:Name="Hatching" />

        <!-- Content -->
        <Grid Width="878"
              Height="540"
              Margin="80,0,0,0"
              HorizontalAlignment="Left"
              x:Name="Gamerpic"
              Style="{StaticResource A_Style_FrameworkElement_PostRace_SmallAnimatedBlock}"
              local:UIPageTransitionManager.TransitionIndex="0">
            <local:FZMaterial OpacityMask="{StaticResource A_Brush_GamerpicOpacity}">
                <Grid>
                    <Grid Height="540"
                          Width="878"
                          ClipToBounds="True">
                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_PostRace_Gamerpic}"
                                          Height="878"
                                          Width="878"
                                          ClipToBounds="True"
                                          VerticalAlignment="Center"
                                          HorizontalAlignment="Center"
                                          x:Name="Pic"
                                          Margin="0,0,-0.5,-0.5"
                                          GreedyMeasure="True"
                                          ImageSource="{Binding UserProfile, Converter={StaticResource A_GamerPicOrTeamProfileConverter}, ConverterParameter={StaticResource A_Size_PostRace_GamerPicSizeParams}}"
                                          Stretch="UniformToFill" />
                    </Grid>
                    <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/PostRace/Gamerpic_Vignette.png" />
                </Grid>
            </local:FZMaterial>
        </Grid>

        <Decorator HorizontalAlignment="Right"
                   VerticalAlignment="Center"
                   Margin="0,50,40,0"
                   Width="1000">
            <local:ZPanel.Transform>
                <local:ZRotation Angle="-6" />
            </local:ZPanel.Transform>
            <StackPanel Orientation="Vertical"
                        MaxWidth="900"
                        HorizontalAlignment="Center"
                        RenderTransform="{StaticResource A_Transform_Italic}">
                <Control x:Name="TotalLabel"
                           Margin="50,0,0,0"
                           Style="{StaticResource A_Style_Control_PostRace_TotalLabelBlock}"
                           MinHeight="43" />

                <Decorator Height="22" />

                <Control x:Name="TotalValue"
                         Style="{StaticResource A_Style_Control_PostRace_TeamNameBlock}"
                         Tag="{Binding UserProfile.FormattedGamertag, Converter={StaticResource A_StringToUpper}}" />

                <Decorator Height="22" />

                <Control x:Name="BalanceValue"
                         Margin="0,0,70,0"
                         HorizontalAlignment="Right"
                         Style="{StaticResource A_Style_Control_PostRace_TotalLabelBlock}"
                         Tag="{Binding FinishPosition, Converter={StaticResource A_Converter_PodiumText}}">
                    <Control.Resources>

                        <Style x:Key="A_Style_FZTextBlock_PostRace_TotalText"
                               TargetType="local:FZTextBlock"
                               BasedOn="{StaticResource A_Style_FZTextBlock_PostRace_TotalText}">
                            <Setter Property="FontFamily"
                                    Value="Horizon_B" />
                        </Style>

                    </Control.Resources>
                </Control>
            </StackPanel>
        </Decorator>
        
        <local:FZMaterial Color="#000000"
                          Opacity="0.3"
                          Height="27"
                          VerticalAlignment="Bottom" />
        <local:FZMaterial Color="#000000"
                          Opacity="0.3"
                          Height="27"
                          VerticalAlignment="Top" />

        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PostRacePanel_Vignette}" />

        <local:EventFire x:Name="EventFire" />

    </Grid>
    <local:EventFire.FzTriggers>
        <local:BeginUIStoryboard Storyboard="{StaticResource A_Storyboard_PostRace_SeriesComplete}"
                                 local:EventFireTrigger.Event="StartPanelAnimation" />
        <local:RaiseEntityModelEvent local:EventFireTrigger.Event="StartPanelAnimation"
                                     EventName="PostRacePodiumPanel" />
    </local:EventFire.FzTriggers>
</Page>
