<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_PostRaceSeriesRewards"
      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>
        <Style x:Key="A_Style_Control_PostRace_BonusValueBlock_Cr"
               BasedOn="{StaticResource A_Style_Control_PostRace_BonusValueBlock}"
               TargetType="Control">
            <Setter Property="Width"
                    Value="200" />
            <Setter Property="Tag"
                    Value="/ForzaUI;component/Textures/Anthem/Icons/CRIcon/CR_85_FilledCircle.png" />
        </Style>

        <System:Double x:Key="A_Double_CreditRewardItem_Offset">48</System:Double>

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

        <local:TeamConverter x:Key="A_Converter_Team" />

        <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="43"
                                           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">122</System:Double>
        
        <System:TimeSpan x:Key="A_TimeSpan_Transition_Overlap">-0:0:0.3</System:TimeSpan>
        
        <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" />

        <Storyboard x:Key="A_Storyboard_ToDivided">
            <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
                             To="0"
                             Duration="0:0:0.2"
                             EasingFunction="{local:ExponentialEasing EasingMode=EaseIn}" />
        </Storyboard>
        <Storyboard x:Key="A_Storyboard_FromDivided">
            <DoubleAnimation Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)"
                             From="0"
                             Duration="0:0:0.2"
                             EasingFunction="{local:ExponentialEasing EasingMode=EaseIn}" />
        </Storyboard>

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

        <System:Double x:Key="A_Double_NewScore_Scale">2.4</System:Double>

        <local:OffsetKeyTime x:Key="A_KeyTime_Continue"
                             Offset="0:0:20" />
        
        <local:UIStoryboard x:Key="A_Storyboard_PostRace_SeriesComplete">
            <local:UIStoryboard.TriggerAnimation>
                <local:RaiseEntityModelEvent local:TriggerAnimation.KeyTime="0:0:0"
                                             EventName="PostRaceSeriesRewardsPanel" />
                <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:RaiseFzEvent Storyboard.TargetName="StarsSheet"
                                    EventName="StarRewards"
                                    local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_TeamScore_EventWinner_NextPage}" />

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

        <local:OffsetKeyTime x:Key="A_KeyTime_RewardsSequence"
                             Offset="0:0:3" />

        <local:UIStoryboard x:Key="A_Storyboard_PostRace_StarRewards">
            <local:UIStoryboard.TriggerAnimation>
                <local:RaiseFzEvent Storyboard.TargetName="TickerRewards"
                                    EventName="NextReward"
                                    local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_RewardsSequence}" />
            </local:UIStoryboard.TriggerAnimation>
        </local:UIStoryboard>

        <local:MappingConverter x:Key="A_Converter_Gradient1">
            <local:MappingConverterEntry Key="{x:Static local:SeriesRewardsContext.Default}"
                                         Value="#FF064b98" />
            <local:MappingConverterEntry Key="{x:Static local:SeriesRewardsContext.ObjectiveReward}"
                                         Value="{StaticResource A_Color_TrackSpecificCurrency_ExpansionOne_PostRace_B}" />
            <local:MappingConverterEntry Key="{x:Static local:SeriesRewardsContext.Super7}"
                                         Value="{StaticResource A_Color_InfluenceThread_BackgroundGradientA_super_7}" />
        </local:MappingConverter>
        
        <local:MappingConverter x:Key="A_Converter_Gradient2">
            <local:MappingConverterEntry Key="{x:Static local:SeriesRewardsContext.Default}"
                                         Value="#FF00965b" />
            <local:MappingConverterEntry Key="{x:Static local:SeriesRewardsContext.ObjectiveReward}"
                                         Value="{StaticResource A_Color_TrackSpecificCurrency_ExpansionOne_PostRace_A}" />
            <local:MappingConverterEntry Key="{x:Static local:SeriesRewardsContext.Super7}"
                                         Value="{StaticResource A_Color_InfluenceThread_BackgroundGradientB_super_7}" />                                         
        </local:MappingConverter>
        
        <local:OffsetKeyTime x:Key="A_KeyTime_StarObjective_FadeUp_Begin"
                             KeyTime="{StaticResource A_KeyTime_Star_Slam_MotionOn_End}"
                             Offset="-0:0:0.1" />
        <local:OffsetKeyTime x:Key="A_KeyTime_StarObjective_FadeUp_End"
                             KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"
                             Offset="0:0:0.2" />

        <local:OffsetKeyTime x:Key="A_KeyTime_StarObjective_Flash_On_Begin"
                             KeyTime="{StaticResource A_KeyTime_Star_Slam_MotionOn_End}"
                             Offset="0:0:0.2" />
        <local:OffsetKeyTime x:Key="A_KeyTime_StarObjective_Flash_On_End"
                             KeyTime="{StaticResource A_KeyTime_StarObjective_Flash_On_Begin}"
                             Offset="0:0:0.2" />
        <local:OffsetKeyTime x:Key="A_KeyTime_StarObjective_Flash_Off_Begin"
                             KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_End}"
                             Offset="0:0:0.2" />
        <local:OffsetKeyTime x:Key="A_KeyTime_StarObjective_Flash_Off_End"
                             KeyTime="{StaticResource A_KeyTime_StarObjective_Flash_Off_Begin}"
                             Offset="0:0:0.3" />

        <local:LinearTransformConverter x:Key="A_Converter_CompleteOffset"
                                        Add="-250" />

        <DataTemplate x:Key="A_ItemTemplate_BucketListStar">
            <DockPanel Width="500">
                <Viewbox Height="297"
                         DockPanel.Dock="Top">
                    <Control Style="{StaticResource A_Style_Control_BucketListStar}"
                             Tag="/ForzaUI;component/Textures/Data_Bound/PostRace/Star_Full_BG_NoShadow.png" />
                </Viewbox>
                <StackPanel VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Width="400"
                            x:Name="TextBits"
                            Opacity="0.5">
                    <Decorator local:ZPanel.TransformOrigin="0.5,0.5">
                        <local:ZPanel.Transform>
                            <local:ZRotation Angle="-5" />
                        </local:ZPanel.Transform>
                        <Decorator RenderTransform="{StaticResource A_Transform_Italic}"
                                   RenderTransformOrigin="0.5,0.5">
                            <local:FZTextBlock local:TextBlockInlineMarkup.Markup="{Binding Description, Converter={StaticResource A_StringToUpper}}"
                                               local:TextBlockInlineMarkup.ResourceBaseName="A_NonExistentResourceBaseName_"
                                               Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                                               TextAlignment="Center"
                                               LineAdjust="-0.4"
                                               TextWrapping="Wrap"
                                               CapHeight="36"
                                               Color="#fff"
                                               x:Name="ObjectiveText"/>
                        </Decorator>
                    </Decorator>
                    <Decorator Height="12" />
                    <Grid local:ZPanel.TransformOrigin="0.5,0.5">
                        <local:ZPanel.Transform>
                            <local:ZRotation Angle="-5" />
                        </local:ZPanel.Transform>
                        <Grid x:Name="MyScore"
                                   local:ZPanel.TransformOrigin="0.5,0.5"
                                   Effect="{StaticResource A_MotionBlurEffect}">
                            <local:ZPanel.Transform>
                                <TranslateTransform3D />
                            </local:ZPanel.Transform>
                            <Decorator RenderTransform="{StaticResource A_Transform_Italic}"
                                       RenderTransformOrigin="0.5,0.5">
                                <local:FZTextBlock Text="{Binding PlayerScore, Converter={StaticResource A_StringToUpper}}"
                                                   Style="{StaticResource A_Style_FZTextBlock_HorizonB}"
                                                   CapHeight="30"
                                                   Color="#fff"
                                                   TextAlignment="Center" />
                            </Decorator>
                        </Grid>
                        <Grid x:Name="ChallengeComplete"
                                   local:ZPanel.TransformOrigin="0.5,0.5"
                                   Opacity="0"
                                   Effect="{StaticResource A_MotionBlurEffect}"
                                   local:MotionBlurEffect.MotionBlurPositionXControl="{Binding Path=(local:MotionBlurEffect.MotionBlurPositionXControl), ElementName=MyScore}">
                            <local:ZPanel.Transform>
                                <TranslateTransform3D OffsetX="{Binding Path=(local:ZPanel.Transform).(TranslateTransform3D.OffsetX), ElementName=MyScore, Converter={StaticResource A_Converter_CompleteOffset}}"/>
                            </local:ZPanel.Transform>
                            <Decorator RenderTransform="{StaticResource A_Transform_Italic}"
                                       RenderTransformOrigin="0.5,0.5">
                                <local:FZTextBlock Text="{local:Loc InGame.IDS_PostRace_StarComplete}"
                                                   Style="{StaticResource A_Style_FZTextBlock_HorizonB}"
                                                   CapHeight="30"
                                                   Color="#fff"
                                                   TextAlignment="Center" />
                            </Decorator>
                        </Grid>
                    </Grid>
                </StackPanel>
            </DockPanel>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=(local:TickerItemsControlItem.Reached)}"
                             Value="True">
                    <DataTrigger.EnterActions>
                        <local:BeginUIStoryboard>
                            <local:UIStoryboard>
                                <local:UIStoryboard.TriggerAnimation>
                                    <local:BeginUIStoryboard Storyboard.TargetName="MyScore"
                                                             local:TriggerAnimation.KeyTime="0:0:0">
                                        <local:UIStoryboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(local:ZPanel.Transform).(TranslateTransform3D.OffsetX)">
                                                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                                        Value="0" />
                                                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"
                                                                        Value="0" />
                                                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_End}"
                                                                      Value="250"
                                                                      EasingFunction="{local:QuadraticEasing EasingMode=EaseOut}" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                                                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                                        Value="1" />
                                                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"
                                                                        Value="1" />
                                                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_End}"
                                                                      Value="0"
                                                                      EasingFunction="{local:QuadraticEasing EasingMode=EaseOut}" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                                           Storyboard.TargetName="ChallengeComplete">
                                                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                                        Value="0" />
                                                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"
                                                                        Value="1" />
                                                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_End}"
                                                                      Value="1"
                                                                      EasingFunction="{local:QuadraticEasing EasingMode=EaseIn}" />
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(local:MotionBlurEffect.MotionBlurPositionXControl)">
                                                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                                                        Value="0" />
                                                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"
                                                                        Value="0" />
                                                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_End}"
                                                                      Value="1000"
                                                                      EasingFunction="{local:QuadraticEasing EasingMode=EaseOut}" />
                                            </DoubleAnimationUsingKeyFrames>
                                        </local:UIStoryboard>
                                    </local:BeginUIStoryboard>
                                </local:UIStoryboard.TriggerAnimation>
                                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TextBits"
                                                               Storyboard.TargetProperty="Opacity">
                                    <DiscreteDoubleKeyFrame KeyTime="0"
                                                            Value="0.5" />
                                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"
                                                            Value="0.5" />
                                    <LinearDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_End}"
                                                            Value="1" />
                                </DoubleAnimationUsingKeyFrames>
                            </local:UIStoryboard>
                        </local:BeginUIStoryboard>
                    </DataTrigger.EnterActions>
                </DataTrigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Path=(local:TickerItemsControlItem.Reached)}"
                                   Value="True" />
                        <Condition Binding="{Binding Path=(local:TickerItemsControlItem.IsFinalItem)}"
                                   Value="True" />
                    </MultiDataTrigger.Conditions>
                    <MultiDataTrigger.EnterActions>
                        <local:RaiseFzEvent EventName="FinalStar" />
                    </MultiDataTrigger.EnterActions>
                </MultiDataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>

        <ItemsPanelTemplate x:Key="A_PanelTemplate_Rewards">
            <Grid IsItemsHost="True" />
        </ItemsPanelTemplate>

        <local:MappingConverter x:Key="A_VisibleWhenZero" Default="{x:Static Visibility.Hidden}">
            <local:MappingConverterEntry Key="0"
                                         Value="{x:Static Visibility.Visible}" />
        </local:MappingConverter>

        <local:LinearTransformConverter x:Key="A_Converter_XMinusOne"
                                        Add="-1" />

        <local:OffsetKeyTime x:Key="A_KeyTime_RewardItem_StayTime" Offset="0:0:4"/>
        <local:OffsetKeyTime x:Key="A_KeyTime_RewardItem_NextReward"
                             KeyTime="{StaticResource A_KeyTime_RewardItem_StayTime}"
                             Offset="-0:0:0.3" />
        <local:OffsetKeyTime x:Key="A_KeyTime_RewardItem_dummy"
                             KeyTime="{StaticResource A_KeyTime_RewardItem_StayTime}"
                             Offset="0:0:0.3" />


        <local:UIStoryboard FillBehavior="Stop"
                            x:Key="A_Storyboard_RewardAnimation">
            <local:UIStoryboard.TriggerAnimation>
                <local:RaiseFzEvent local:TriggerAnimation.KeyTime="0:0:0"
                                    EventName="WhooshIn"
                                    Storyboard.TargetName="TextBits" />
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="0:0:0"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshInFromRight}"
                                         Storyboard.TargetName="RewardBox" />
                <local:StartAudioTrigger local:TriggerAnimation.KeyTime="0:0:0"
                                         EventName="/Master/UI/E3/UI_Forzathon_Win" />
                <local:RaiseFzEvent local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_RewardItem_NextReward}"
                                    EventName="NextReward" />
                <local:RaiseFzEvent local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_RewardItem_StayTime}"
                                    EventName="WhooshOut"
                                    Storyboard.TargetName="TextBits" />
                <local:BeginUIStoryboard local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_RewardItem_StayTime}"
                                         Storyboard="{StaticResource A_Storyboard_PostRace_WhooshOutToRight}"
                                         Storyboard.TargetName="RewardBox" />
                <local:RaiseFzEvent local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_RewardItem_dummy}"
                                    EventName="dummy" />
            </local:UIStoryboard.TriggerAnimation>
        </local:UIStoryboard>

        <DataTemplate DataType="{x:Type local:XAMLReward}">
            <Grid local:CompareValue.A="{Binding Path=(local:TickerItemsControlItem.Value), Converter={StaticResource A_Converter_XMinusOne}}"
                  local:CompareValue.B="{Binding Path=(local:TickerItemsControlItem.Index)}"
                  x:Name="RewardRoot">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid HorizontalAlignment="Center"
                      Grid.Column="0"
                      Grid.ColumnSpan="2"
                      MaxWidth="1000"
                      VerticalAlignment="Center">
                    <Control Template="{StaticResource A_Template_RewardTextBits}"
                             x:Name="TextBits"/>
                </Grid>

                <Control x:Name="RewardBox"
                         Grid.ColumnSpan="3"
                         HorizontalAlignment="Right"
                         Margin="0,0,164,0"
                         Style="{StaticResource A_Style_Control_RewardBox}" />

                <local:EventFire.FzTriggers>
                    <local:BeginUIStoryboard local:EventFireTrigger.Event="DebugAnimate"
                                             Storyboard="{StaticResource A_Storyboard_RewardAnimation}" />
                </local:EventFire.FzTriggers>
            </Grid>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=(local:TickerItemsControlItem.IsFinalItem)}"
                             Value="True">
                    <Setter TargetName="RewardRoot"
                            Property="local:EventFire.FzTriggers">
                        <Setter.Value>
                            <local:EventFireTriggerCollection>
                                <local:RaiseFzEvent local:EventFireTrigger.Event="NextReward"
                                                    EventName="FinalReward" />
                            </local:EventFireTriggerCollection>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=(local:CompareValue.Result), ElementName=RewardRoot}"
                             Value="0">
                    <DataTrigger.EnterActions>
                        <local:BeginUIStoryboard Storyboard="{StaticResource A_Storyboard_RewardAnimation}" />
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
        
        <!-- For now this needs to be duplicated here because the XP rewards doesn't have an item block right now -->
        <Style x:Key="A_Style_Control_PostRace_CustomLabelBlock"
               TargetType="Control"
               BasedOn="{StaticResource A_Style_Control_PostRace_TeamNameBlock}">
            <Style.Resources>
                <System:Double x:Key="A_Double_TeamNameLabelCapHeight">134</System:Double>
            </Style.Resources>
            <Setter Property="Tag"
                    Value="" />
            <Setter Property="HorizontalContentAlignment"
                    Value="Left" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Control">
                        <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" />
                                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_PostRace_TotalText}"
                                                       Preset="{StaticResource A_FZMaterialPresetAdditive}"
                                                       CapHeight="{DynamicResource A_Double_TeamNameLabelCapHeight}"
                                                       Margin="30,0,0,0"
                                                       x:Name="Multiplier"
                                                       Text="{Binding Amount, Converter={StaticResource A_Converter_StringFormatConverter}, ConverterParameter={local:Loc InGame.IDS_Rewards_MultiplierFormat}}"
                                                       Visibility="{Binding RewardType, Converter={StaticResource A_Converter_RewardTypeMultiplierVisibility}}"
                                                       VerticalAlignment="Center" />
                                </StackPanel>
                            </Grid>
                        </Viewbox>
                        <ControlTemplate.Triggers>
                            <DataTrigger Binding="{Binding Amount, Converter={StaticResource A_CompareConverter}, ConverterParameter=2}"
                                         Value="-1">
                                <Setter TargetName="Multiplier"
                                        Property="Visibility"
                                        Value="Collapsed" />
                            </DataTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="A_Style_Control_TotalValue"
               TargetType="Control"
               BasedOn="{StaticResource A_Style_Control_PostRace_CustomLabelBlock}">
            <Setter Property="Tag"
                    Value="{Binding Path=(local:BindingProxy.A), RelativeSource={RelativeSource Self}, Converter={StaticResource A_StringToUpper}}" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=(local:BindingProxy.A), ElementName=TotalValue}"
                             Value="{x:Null}">
                    <Setter Property="Tag"
                            Value="{Binding Description, Converter={StaticResource A_StringToUpper}}" />
                </DataTrigger>
                <!-- Override the credits string here, but not in the influence rewards, which doesn't yet have the reward block (only the text bits) -->
                <DataTrigger Binding="{Binding RewardType}"
                             Value="{x:Static local:UIRewardType.Credits}">
                    <Setter Property="Tag"
                            Value="{Binding Source={local:Loc InGame.IDS_PostRace_CreditPrize}, Converter={StaticResource A_StringToUpper}}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

    </Page.Resources>
    
    <Grid Height="540"
          Width="1920">


        <local:FZMaterial>
            <local:FZMaterial.Preset>
                <local:FZMaterialPresetRoundtangle BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                                                   GradientColorA="{Binding Context, Converter={StaticResource A_Converter_Gradient1}}"
                                                   GradientColorB="{Binding Context, Converter={StaticResource A_Converter_Gradient2}}"
                                                   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}, FallbackValue={StaticResource A_BitmapImage_GamerPicFallback}}"
                                          Stretch="UniformToFill" />
                    </Grid>
                    <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/PostRace/Gamerpic_Vignette.png" />
                </Grid>
            </local:FZMaterial>
        </Grid>

        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="1.5*" />
            </Grid.ColumnDefinitions>
            <Decorator HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Grid.Column="1"
                       Margin="50,0,0,0"
                       MaxWidth="1000"
                       local:ZPanel.TransformOrigin="0.5,0.5">
                <local:ZPanel.Transform>
                    <local:ZRotation Angle="-6" />
                </local:ZPanel.Transform>
                <StackPanel Orientation="Vertical"
                            MaxWidth="900"
                            HorizontalAlignment="Center"
                            RenderTransform="{StaticResource A_Transform_Italic}"
                            Margin="100,0,0,0">
                    <Control x:Name="TotalLabel"
                             Margin="50,0,0,0"
                             Style="{StaticResource A_Style_Control_PostRace_TotalLabelBlock}"
                             MinHeight="43"
                             Tag="{Binding SeriesHeader, Converter={StaticResource A_StringToUpper}}">
                        <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" />
                                <Setter Property="CapHeight"
                                        Value="52" />
                            </Style>

                        </Control.Resources>
                    </Control>

                    <Decorator Height="22" />

                    <Control x:Name="TotalValue"
                             Style="{StaticResource A_Style_Control_PostRace_TeamNameBlock}"
                             Tag="{Binding SeriesText}"/>

                    <Decorator Height="22" />

                    <Control x:Name="BalanceValue"
                             Margin="0,0,40,0"
                             HorizontalAlignment="Right"
                             Style="{StaticResource A_Style_Control_PostRace_TotalLabelBlock}"
                             Tag="{Binding SeriesFooter}">
                        <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>
        </Grid>

        <!-- Stars -->
        <Grid Opacity="0"
              x:Name="GoldBackground">
            <Control Template="{StaticResource A_Template_StarsGoldBackground}" />

            <local:FZMediaElement Source="game:/Media/UI/Videos/Stars_Particles.bk2"
                                  local:FzMediaElementExtension.Loop="True"
                                  LoadedBehavior="Stop"
                                  UnloadedBehavior="Stop"
                                  Stretch="UniformToFill"
                                  Preset="{StaticResource A_FZMaterialPresetAdditive}"
                                  x:Name="Video" />
        </Grid>


        <Decorator x:Name="StarsSheet"
                   Opacity="0"
                   local:CompareValue.A="{Binding Path=(local:MinValue.A), ElementName=TickerStars}"
                   local:CompareValue.B="{Binding EarnedStars}">
            <FrameworkElement.Resources>
                <System:Int32 x:Key="A_Int_Zero">0</System:Int32>
                <local:LinearTransformConverter x:Key="A_Converter_Identity" />
                <local:UIStoryboard x:Key="A_Storyboard_NewStarsEarned">
                    <Int32AnimationUsingKeyFrames Storyboard.TargetName="TickerStars"
                                                  Storyboard.TargetProperty="(local:MinValue.A)">
                        <DiscreteInt32KeyFrame KeyTime="0:0:1"
                                               Value="1" />
                        <DiscreteInt32KeyFrame KeyTime="0:0:1.5"
                                               Value="2" />
                        <DiscreteInt32KeyFrame KeyTime="0:0:2"
                                               Value="3" />
                        <DiscreteInt32KeyFrame KeyTime="0:0:2.5"
                                               Value="4" />
                    </Int32AnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Hatching"
                                                   Storyboard.TargetProperty="Opacity">
                        <LinearDoubleKeyFrame KeyTime="0:0:0.6"
                                              Value="0" />
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StarsSheet"
                                                   Storyboard.TargetProperty="Opacity">
                        <LinearDoubleKeyFrame KeyTime="0:0:0.6"
                                              Value="1" />
                    </DoubleAnimationUsingKeyFrames>
                </local:UIStoryboard>

                <local:UIStoryboard x:Key="A_Storyboard_StarsComplete">
                    <local:UIStoryboard.TriggerAnimation>
                        <local:RaiseFzEvent Storyboard.TargetName="TickerRewards"
                                            EventName="NextReward"
                                            local:TriggerAnimation.KeyTime="0:0:3" />
                    </local:UIStoryboard.TriggerAnimation>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="Hatching"
                                                   Storyboard.TargetProperty="Opacity">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:3"
                                                Value="0" />
                        <LinearDoubleKeyFrame KeyTime="0:0:3.6"
                                              Value="{StaticResource A_Double_HatchingOpacity}" />
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetName="StarsSheet"
                                                   Storyboard.TargetProperty="Opacity">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:3"
                                                Value="1" />
                        <LinearDoubleKeyFrame KeyTime="0:0:3.6"
                                              Value="0" />
                    </DoubleAnimationUsingKeyFrames>
                </local:UIStoryboard>

                <local:EventFireTriggerCollection x:Key="AvoidErroneousParserError">
                    <local:RaiseFzEvent local:EventFireTrigger.Event="StarRewards"
                                        local:EventFireTrigger.TargetName="TickerRewards"
                                        EventName="NextReward" />
                </local:EventFireTriggerCollection>
            </FrameworkElement.Resources>
            <FrameworkElement.Style>
                <Style TargetType="Decorator">
                    <!-- case when there are some stars to display -->
                    <Setter Property="local:EventFire.FzTriggers">
                        <Setter.Value>
                            <local:EventFireTriggerCollection>
                                <local:BeginUIStoryboard local:EventFireTrigger.Event="StarRewards"
                                                         Storyboard="{StaticResource A_Storyboard_NewStarsEarned}" />
                                <local:BeginUIStoryboard local:EventFireTrigger.Event="StarsComplete"
                                                         Storyboard="{StaticResource A_Storyboard_StarsComplete}" />

                            </local:EventFireTriggerCollection>
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <!-- case when there are no stars, skip this sheet entirely -->
                        <DataTrigger Binding="{Binding Path=Stars.Count}"
                                     Value="0">
                            <Setter Property="local:EventFire.FzTriggers"
                                    Value="{StaticResource AvoidErroneousParserError}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Path=(local:CompareValue.Result), RelativeSource={RelativeSource Self}}"
                                     Value="1">
                            <DataTrigger.EnterActions>
                                <local:RaiseFzEvent EventName="StarsComplete" />
                            </DataTrigger.EnterActions>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </FrameworkElement.Style>

            <Grid HorizontalAlignment="Center" Margin="0,46,0,55">
                <local:TickerItemsControl ItemsSource="{Binding Stars}"
                                          Value="{Binding Path=(local:MinValue.Result), RelativeSource={RelativeSource Self}, Converter={StaticResource A_Converter_Identity}}"
                                          local:MinValue.A="{StaticResource A_Int_Zero}"
                                          local:MinValue.B="{Binding EarnedStars}"
                                          x:Name="TickerStars"
                                          ItemsPanel="{StaticResource A_PanelTemplate_BucketListStars}"
                                          ItemTemplate="{StaticResource A_ItemTemplate_BucketListStar}" />


            </Grid>
        </Decorator>
        <local:FZTextBlock Text="{Binding Path=Stars.Count}"
                           CapHeight="300"
                           Visibility="Hidden"/>
        <!-- Rewards -->
        <Decorator>
            <local:TickerItemsControl ItemsSource="{Binding Rewards}"
                                      Value="0"
                                      x:Name="TickerRewards"
                                      ItemsPanel="{StaticResource A_PanelTemplate_Rewards}">
                <FrameworkElement.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Rewards.Count}"
                                         Value="0">
                                <Setter Property="local:EventFire.FzTriggers">
                                    <Setter.Value>
                                        <local:EventFireTriggerCollection>
                                            <local:RaiseFzEvent local:EventFireTrigger.Event="NextReward"
                                                                EventName="FinalReward" />
                                        </local:EventFireTriggerCollection>
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </FrameworkElement.Style>
            </local:TickerItemsControl>
            <local:EventFire.FzTriggers>
                <local:Accumulate local:EventFireTrigger.Event="NextReward"
                                  local:EventFireTrigger.TargetName="TickerRewards"
                                  Amount="1"
                                  Property="(local:TickerItemsControl.Value)" />
            </local:EventFire.FzTriggers>
        </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:FZMaterial Preset="{StaticResource A_FZMaterialPresetAdditive}"
                          x:Name="FullscreenFlash"
                          Opacity="0" />

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

    </Grid>
    <Page.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <local:BeginUIStoryboard Storyboard="{StaticResource A_Storyboard_PostRace_SeriesComplete}"
                                     x:Name="PostRace_TeamScore" />
        </EventTrigger>
    </Page.Triggers>
    <local:EventFire.FzTriggers>
        <local:RaiseFzEvent local:EventFireTrigger.Event="FinalReward"
                            EventName="AutoContinue" />
        <local:RaiseFzEvent local:EventFireTrigger.Event="FinalReward"
                            EventName="Complete" />
        <local:RaiseEntityModelEvent local:EventFireTrigger.Event="FinalReward"
                            EventName="UISequenceComplete" />

        <local:BeginUIStoryboard local:EventFireTrigger.Event="FinalStar">
            <local:UIStoryboard>
                <local:UIStoryboard.TriggerAnimation>
                    <local:PlayVideoTrigger Storyboard.TargetName="Video"
                                            local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"/>
                </local:UIStoryboard.TriggerAnimation>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="GoldBackground"
                                               Storyboard.TargetProperty="Opacity">
                    <DiscreteDoubleKeyFrame KeyTime="0"
                                            Value="0" />
                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"
                                            Value="0" />
                    <LinearDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_End}"
                                          Value="1" />
                    <DiscreteDoubleKeyFrame KeyTime="0:0:3.0"
                                            Value="1" />
                    <LinearDoubleKeyFrame KeyTime="0:0:3.6"
                                          Value="0" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FullscreenFlash"
                                               Storyboard.TargetProperty="Opacity">
                    <DiscreteDoubleKeyFrame KeyTime="0"
                                            Value="0" />
                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_Begin}"
                                            Value="0" />
                    <LinearDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_FadeUp_End}"
                                          Value="0.8" />
                    <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_Flash_Off_Begin}"
                                            Value="0.8" />
                    <LinearDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_StarObjective_Flash_Off_End}"
                                          Value="0" />
                </DoubleAnimationUsingKeyFrames>
            </local:UIStoryboard>
        </local:BeginUIStoryboard>
    </local:EventFire.FzTriggers>
</Page>
