<Page DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Style="{StaticResource A_Style_Page_Generic}"
      mc:Ignorable="d"
      x:Class="ForzaUI.A_InGameAnnouncement"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      x:Name="Page">
    <Page.Resources>

        <local:OffsetKeyTime x:Key="A_KeyTime_Announcement_Begin"
                             KeyTime="0:0:0" />
        <local:OffsetKeyTime x:Key="A_KeyTime_Announcement_Land"
                             KeyTime="0:0:0.36" />
        <local:OffsetKeyTime x:Key="A_KeyTime_Announcement_Slide_End"
                             KeyTime="0:0:5" />
        <local:OffsetKeyTime x:Key="A_KeyTime_Announcement_Fade_End"
                             KeyTime="{StaticResource A_KeyTime_Announcement_Slide_End}"
                             Offset="-0:0:1.0" />
        <local:OffsetKeyTime x:Key="A_KeyTime_Announcement_Fade_Start"
                             KeyTime="{StaticResource A_KeyTime_Announcement_Fade_End}"
                             Offset="-0:0:0.3"/>

        <local:UIStoryboard x:Key="A_Storyboard_HighContrastBg">
            <!-- High Contrast BG fade in/out -->
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="HighContrastBg"
                                           Storyboard.TargetProperty="Opacity">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="0" />
                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Begin}"
                                        Value="0" />
                <LinearDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Land}"
                                      Value="1" />
                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Fade_Start}"
                                        Value="1" />
                <LinearDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Fade_End}"
                                      Value="0" />
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <local:UIStoryboard x:Key="A_Storyboard_Announcement">
            <!-- Whoosh -->
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TopLine"
                                           Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="-2000" />
                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Begin}"
                                        Value="-2000" />
                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Land}"
                                      Value="50"
                                      EasingFunction="{local:QuadraticEasing EasingMode=EaseInOut}" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BottomLine"
                                           Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="2000" />
                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Begin}"
                                        Value="2000" />
                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Land}"
                                      Value="50"
                                      EasingFunction="{local:QuadraticEasing EasingMode=EaseInOut}" />
            </DoubleAnimationUsingKeyFrames>
            <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:AudioEvent.SoundName)"
                                       Storyboard.TargetName="AnimationAudioEvent">
                <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="" />
                <DiscreteStringKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Begin}" Value="/Master/UI/PostRace/HZ2_SFX_HUD_PostRace_CashRewardsTotalOn_01" />
            </StringAnimationUsingKeyFrames>
            <!-- Slide -->
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TopLine"
                                           IsAdditive="True"
                                           Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Slide_End}"
                                      Value="150"
                                      EasingFunction="{local:LinearEasing}" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BottomLine"
                                           IsAdditive="True"
                                           Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Slide_End}"
                                      Value="-150"
                                      EasingFunction="{local:LinearEasing}" />
            </DoubleAnimationUsingKeyFrames>

            <!-- Fade on & off -->
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TopLine"
                                           Storyboard.TargetProperty="Opacity">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="0" />
                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Begin}"
                                        Value="0" />
                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Land}"
                                      Value="1"
                                      EasingFunction="{local:LinearEasing}" />
                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Fade_Start}"
                                        Value="1" />
                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Fade_End}"
                                      Value="0"
                                      EasingFunction="{local:LinearEasing}" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BottomLine"
                                           Storyboard.TargetProperty="Opacity">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="0" />
                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Begin}"
                                        Value="0" />
                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Land}"
                                      Value="1"
                                      EasingFunction="{local:LinearEasing}" />
                <DiscreteDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Fade_Start}"
                                        Value="1" />
                <EasingDoubleKeyFrame KeyTime="{StaticResource A_KeyTime_Announcement_Fade_End}"
                                      Value="0"
                                      EasingFunction="{local:LinearEasing}" />
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <Style x:Key="A_Style_FZRun_Announcement_TopLine_White"
               TargetType="local:FZRun">
            <Setter Property="Color"
                    Value="#ffffffff" />
        </Style>

        <Style x:Key="A_Style_FZRun_Announcement_BottomLine_CREDITS" TargetType="{x:Type Control}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Anthem/Icons/CRIcon/CR_110_FilledCircle.png" Width="149" Height="149" Margin="0,-210,0,0" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="A_Style_FZTextBlock_TopLine_Common"
               BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}"
               TargetType="{x:Type local:FZTextBlock}">
            <Setter Property="Color" Value="{Binding InfluenceThread.Color, FallbackValue=#fd1970}"/>
            <Setter Property="CapHeight" Value="54"/>
            <Setter Property="local:TextBlockInlineMarkup.ResourceBaseName" Value="A_Style_FZRun_Announcement_TopLine_"/>
            <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding TopLine}" />
        </Style>

        <Style x:Key="A_Style_FZTextBlock_BottomLine_Common"
               BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}"
               TargetType="{x:Type local:FZTextBlock}">
            <Setter Property="Color" Value="#fff"/>
            <Setter Property="CapHeight" Value="134"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>
            <Setter Property="LineAdjust" Value="-0.4"/>
            <Setter Property="local:TextBlockInlineMarkup.ResourceBaseName" Value="A_Style_FZRun_Announcement_BottomLine_"/>
            <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding BottomLine}" />
        </Style>

        <Style x:Key="A_Style_FZTextBlock_TopLine_Default"
               BasedOn="{StaticResource A_Style_FZTextBlock_TopLine_Common}"
               TargetType="{x:Type local:FZTextBlock}" />

        <Style x:Key="A_Style_FZTextBlock_BottomLine_Default"
               BasedOn="{StaticResource A_Style_FZTextBlock_BottomLine_Common}"
               TargetType="{x:Type local:FZTextBlock}" />

        <Style x:Key="A_Style_FZTextBlock_TopLine_TreasureHunt"
               BasedOn="{StaticResource A_Style_FZTextBlock_TopLine_Common}"
               TargetType="{x:Type local:FZTextBlock}">
            <Setter Property="Color" Value="#ffffd31a"/>
            <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding TopLine, Converter={StaticResource A_StringToUpper}}" />
        </Style>

        <Style x:Key="A_Style_FZTextBlock_BottomLine_TreasureHunt"
               BasedOn="{StaticResource A_Style_FZTextBlock_BottomLine_Common}"
               TargetType="{x:Type local:FZTextBlock}">
            <Setter Property="Color" Value="#ffffffff"/>
            <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding BottomLine, Converter={StaticResource A_StringToUpper}}" />
        </Style>

        <local:MappingConverter x:Key="A_Converter_TypeToTopLineStyle"
                                Default="{StaticResource A_Style_FZTextBlock_TopLine_Default}">
            <local:MappingConverterEntry Key="{x:Static local:InGameAnnouncementType.TreasureHunt}" Value="{StaticResource A_Style_FZTextBlock_TopLine_TreasureHunt}" />
        </local:MappingConverter>

        <local:MappingConverter x:Key="A_Converter_TypeToBottomLineStyle"
                                Default="{StaticResource A_Style_FZTextBlock_BottomLine_Default}">
            <local:MappingConverterEntry Key="{x:Static local:InGameAnnouncementType.TreasureHunt}" Value="{StaticResource A_Style_FZTextBlock_BottomLine_TreasureHunt}" />
        </local:MappingConverter>

    </Page.Resources>
    <Grid>
        <local:FZMaterial x:Name="HighContrastBg"
                          Color="#99000000"
                          Visibility="{StaticResource A_Visibility_ShowForHighContrastOnly}" />

        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">

            <Grid RenderTransformOrigin="0.5,0.5"
              HorizontalAlignment="Center"
              VerticalAlignment="Center">
                <UIElement.RenderTransform>
                    <RotateTransform Angle="-6" />
                </UIElement.RenderTransform>
                <StackPanel MaxWidth="1500"
                        Margin="0,60,0,0">
                    <Decorator x:Name="TopLine"
                           Margin="70,0,0,0"
                           Effect="{StaticResource A_MotionBlurEffect}"
                           local:MotionBlurEffect.MotionBlurPositionXControl="{Binding RenderTransform.X, RelativeSource={RelativeSource Self}}"
                           Opacity="0">
                        <UIElement.RenderTransform>
                            <TranslateTransform />
                        </UIElement.RenderTransform>
                        <Decorator RenderTransformOrigin="0.5,0.5"
                               RenderTransform="{StaticResource A_Transform_Italic}">
                            <local:FZTextBlock Style="{Binding AnnouncementType, Converter={StaticResource A_Converter_TypeToTopLineStyle}, FallbackValue={StaticResource A_Style_FZTextBlock_TopLine_Default}}" />
                        </Decorator>
                    </Decorator>

                    <Decorator Height="13" />

                    <Decorator x:Name="BottomLine"
                           Effect="{StaticResource A_MotionBlurEffect}"
                           local:MotionBlurEffect.MotionBlurPositionXControl="{Binding RenderTransform.X, RelativeSource={RelativeSource Self}}"
                           RenderTransformOrigin="0.5,0.5"
                           Opacity="0">
                        <UIElement.RenderTransform>
                            <TranslateTransform />
                        </UIElement.RenderTransform>
                        <Decorator RenderTransformOrigin="0.5,0.5"
                               RenderTransform="{StaticResource A_Transform_Italic}">
                            <local:FZTextBlock Style="{Binding AnnouncementType, Converter={StaticResource A_Converter_TypeToBottomLineStyle}, FallbackValue={StaticResource A_Style_FZTextBlock_BottomLine_Default}}" />
                        </Decorator>
                    </Decorator>
                </StackPanel>
            </Grid>

            <local:AudioEvent x:Name="AnimationAudioEvent" />
        </Grid>
    </Grid>
    <FrameworkElement.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <local:BeginUIStoryboard Storyboard="{StaticResource A_Storyboard_Announcement}" />
            <local:BeginUIStoryboard Storyboard="{StaticResource A_Storyboard_HighContrastBg}" />
        </EventTrigger>
    </FrameworkElement.Triggers>
</Page>
