<Page DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Style="{StaticResource A_Style_Page_Generic}"
      mc:Ignorable="d"
      x:Class="ForzaUI.A_LabyrinthAnnouncement"
      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>
        <Style x:Key="A_Style_FZTextBlock_TextLine_Base" TargetType="local:FZTextBlock">
            <Setter Property="Color" Value="{StaticResource A_Color_White}"/>
            <Setter Property="FontFamily" Value="Horizon_A"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Effect" Value="{StaticResource A_DropShadowEffect_DefaultHud}"/>
        </Style>
        <Style x:Key="A_Style_FZTextBlock_FirstLine" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_TextLine_Base}">
            <Setter Property="CapHeight" Value="50"/>
            <Setter Property="FontFamily" Value="Horizon_B"/>
        </Style>
        <Style x:Key="A_Style_FZTextBlock_SecondLine" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_TextLine_Base}">
            <Setter Property="CapHeight" Value="142"/>
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_Yellow}"/>
        </Style>
        <Style x:Key="A_Style_FZTextBlock_ExtremeBottomLine" TargetType="local:FZTextBlock"
               BasedOn="{StaticResource A_Style_FZTextBlock_TextLine_Base}">
            <Setter Property="CapHeight" Value="42"/>
            <Setter Property="TextWrapping" Value="Wrap"/>
            <Setter Property="TextAlignment" Value="Center"/>
            <Setter Property="FontFamily"  Value="Horizon_B" />
            <Setter Property="LineAdjust"  Value="-0.45" />
        </Style>

        <Style x:Key="A_Style_FZRun_TextColor_YELLOW" TargetType="local:FZRun">
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_Yellow}"/>
        </Style>

        <Style x:Key="A_Style_ItemContainerStyle"
               TargetType="{Type FrameworkElement}">
            <Setter Property="Margin" Value="8,3" />
            <Setter Property="Width" Value="400" />
            <Setter Property="Height" Value="34" />
        </Style>

        <Style x:Key="A_Style_ItemsPanelStyle"
               TargetType="{Type UniformGrid}">
            <Setter Property="Columns" Value="3"/>
            <Setter Property="Rows" Value="2"/>
        </Style>

        <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_FadeOut" FillBehavior="HoldEnd" >
            <!-- Fade off -->
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TopLine"
                                           Storyboard.TargetProperty="Opacity">
                <EasingDoubleKeyFrame Value="0"  KeyTime="0:0:0.15"
                                      EasingFunction="{local:LinearEasing}" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BottomLine"
                                           Storyboard.TargetProperty="Opacity">
                <EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.15"
                                      EasingFunction="{local:LinearEasing}" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ExtremeBottomLine"
                                           Storyboard.TargetProperty="Opacity">
                <EasingDoubleKeyFrame Value="0" KeyTime="0:0:0.15"
                                      EasingFunction="{local:LinearEasing}" />
            </DoubleAnimationUsingKeyFrames>
            <local:UIStoryboard.TriggerAnimation>
                <local:RaiseFzEvent EventName="FadeOutComplete" local:TriggerAnimation.KeyTime="0:0:0.15"/>
            </local:UIStoryboard.TriggerAnimation>
        </local:UIStoryboard>

        <local:OffsetKeyTime x:Key="A_KeyTime_Announcement_BackgroundFade_Start"
                             Offset="0:0:0.14"
                             KeyTime="{StaticResource A_KeyTime_Announcement_Land}"/>

        <local:UIStoryboard x:Key="A_Storyboard_FadeIn" FillBehavior="HoldEnd">
            <!-- Fade on-->
            <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" />
            </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" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ExtremeBottomLine"
                                           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" />
            </DoubleAnimationUsingKeyFrames>
            <local:UIStoryboard.TriggerAnimation>
                <local:RaiseFzEvent local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Announcement_Fade_Start}"
                                    EventName="AnnouncementReadyToExit" />
            </local:UIStoryboard.TriggerAnimation>
        </local:UIStoryboard>

        <local:UIStoryboard x:Key="A_Storyboard_AnimationUsingKeyFrames_Whoosh">
            <!-- 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="70"
                                      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>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ExtremeBottomLine"
                                           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="30"
                                      EasingFunction="{local:QuadraticEasing EasingMode=EaseInOut}" />
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <local:UIStoryboard x:Key="A_Storyboard_Animate_GameText_Common">
            <StaticResourceExtension ResourceKey="A_Storyboard_AnimationUsingKeyFrames_Whoosh"/>

            <!-- Slide -->
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TopLine"
                                           IsAdditive="True"
                                           Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
                <EasingDoubleKeyFrame Value="-60" KeyTime="{StaticResource A_KeyTime_Announcement_Slide_End}"
                                      EasingFunction="{local:CubicEasing}" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="BottomLine"
                                           IsAdditive="True"
                                           Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
                <EasingDoubleKeyFrame Value="-2" KeyTime="{StaticResource A_KeyTime_Announcement_Slide_End}"
                                      EasingFunction="{local:CubicEasing}" />
            </DoubleAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ExtremeBottomLine"
                                           IsAdditive="True"
                                           Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.X)">
                <EasingDoubleKeyFrame Value="60" KeyTime="{StaticResource A_KeyTime_Announcement_Slide_End}"
                                      EasingFunction="{local:CubicEasing}" />
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <Style x:Key="A_Style_Audio_Context_Triggers" TargetType="FrameworkElement">
            <Style.Triggers>
                <DataTrigger Binding="{Binding AnnouncementAudio, RelativeSource={RelativeSource AncestorType=Page}}" Value="{x:Static local:InGameAnnouncementSound.Standard}">
                    <DataTrigger.EnterActions>
                        <local:StartAudioTrigger local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Announcement_Begin}"
                                                 EventName="UI_OnlineEvents_Go"/>
                    </DataTrigger.EnterActions>
                </DataTrigger>

                <DataTrigger Binding="{Binding AnnouncementAudio, RelativeSource={RelativeSource AncestorType=Page}}" Value="{x:Static local:InGameAnnouncementSound.Victory}">
                    <DataTrigger.EnterActions>
                        <local:StartAudioTrigger local:TriggerAnimation.KeyTime="{StaticResource A_KeyTime_Announcement_Begin}"
                                                 EventName="AudioUITrigger_ELM_Versus_H2H_Win"/>
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Page.Resources>
    <Grid>
         <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        x:Name="BottomBar">
            <local:ControllerButtonPanel x:Name="PART_HelpPanel"
                                         Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <local:ControllerButtonControl Button="A"
                                               Description="{Binding PrimaryDescription}" />
                <local:ControllerButtonControl Button="X"
                                               Description="{Binding SecondaryDescription}" />
                <local:ControllerButtonControl Button="Y"
                                               Description="{Binding TertiaryDescription}" />
            </local:ControllerButtonPanel>
        </ContentControl>

        <local:PageInputHandler Button="{x:Static local:ControllerButtonType.A}"
                                Command="{Binding PrimaryCommand}" />
        <local:PageInputHandler Button="{x:Static local:ControllerButtonType.X}"
                                Command="{Binding SecondaryCommand}" />
        <local:PageInputHandler Button="{x:Static local:ControllerButtonType.Y}"
                                Command="{Binding TertiaryCommand}" />

        <Grid x:Name="LayoutRoot" Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <local:FZMaterial Width="1920" Height="460"
                              ImageSource="/ForzaUI;component/Textures/Data_Bound/Labyrinth/AnnouncementScreen/labyrinth_backing.png"/>
            <Grid VerticalAlignment="Center" HorizontalAlignment="Center">
                <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                    <Decorator x:Name="TopLine"
                               Margin="70,0,0,0"
                               Effect="{StaticResource A_MotionBlurEffect}"
                               local:MotionBlurEffect.MotionBlurPositionXControl="{Binding RenderTransform.X, RelativeSource={RelativeSource Self}}"
                               Opacity="1">
                        <UIElement.RenderTransform>
                            <TranslateTransform />
                        </UIElement.RenderTransform>
                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_FirstLine}" 
                                           Text="{Binding TopLine}"/>
                    </Decorator>
                    <Decorator Height="19" />
                    <Decorator x:Name="BottomLine"
                               Effect="{StaticResource A_MotionBlurEffect}"
                               local:MotionBlurEffect.MotionBlurPositionXControl="{Binding RenderTransform.X, RelativeSource={RelativeSource Self}}"
                               RenderTransformOrigin="0.5,0.5"
                               Opacity="1">
                        <UIElement.RenderTransform>
                            <TranslateTransform />
                        </UIElement.RenderTransform>

                        <Decorator RenderTransformOrigin="0.5,0.5" RenderTransform="{StaticResource A_Transform_Italic}">
                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_SecondLine}" 
                                               Text="{Binding BottomLine}" />
                        </Decorator>
                    </Decorator>
                    <Decorator Height="29"/>
                    <Grid>
                        <Decorator x:Name="ExtremeBottomLine"
                                   Effect="{StaticResource A_MotionBlurEffect}"
                                   local:MotionBlurEffect.MotionBlurPositionXControl="{Binding RenderTransform.X, RelativeSource={RelativeSource Self}}"
                                   RenderTransformOrigin="0.5,0.5"
                                   Margin="-60,0,0,0"
                                   Opacity="1">
                            <UIElement.RenderTransform>
                                <TranslateTransform />
                            </UIElement.RenderTransform>
                            <Decorator RenderTransformOrigin="0.5,0.5" RenderTransform="{StaticResource A_Transform_Italic}">
                                <local:FZTextBlock MaxWidth="750" 
                                                   Style="{StaticResource A_Style_FZTextBlock_ExtremeBottomLine}"
                                                   local:TextBlockInlineMarkup.Markup="{Binding ExtremeBottomLine}"
                                                   local:TextBlockInlineMarkup.ResourceBaseName="A_Style_FZRun_TextColor_"/>
                            </Decorator>
                        </Decorator>
                    </Grid>
                </StackPanel>
            </Grid>
        </Grid>
        <FrameworkElement Style="{StaticResource A_Style_Audio_Context_Triggers}"/>
    </Grid>
    <local:EventFire.FzTriggers>
        <local:BeginUIStoryboard local:EventFireTrigger.Event="Hide_FadeOut" Storyboard="{StaticResource A_Storyboard_FadeOut}"/>
        <local:BeginUIStoryboard local:EventFireTrigger.Event="Show_Announcement" Storyboard="{StaticResource A_Storyboard_FadeIn}"/>
        <local:BeginUIStoryboard local:EventFireTrigger.Event="Show_Announcement" Storyboard="{StaticResource A_Storyboard_Animate_GameText_Common}"/>
    </local:EventFire.FzTriggers>
</Page>
