<UserControl
    DataContext="{Binding (HUDData.Data), RelativeSource={RelativeSource Self}}" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:local="clr-namespace:ForzaUI"
    mc:Ignorable="d"
    x:Class="ForzaUI.HUDAnnouncementControl"
    x:Name="UserControl"
    Margin="0,155,0,0"
    VerticalAlignment="Top"
    HorizontalAlignment="Center">

    <UserControl.Resources>
        <ExponentialEase x:Key="A_EasingFunction_EaseIn" EasingMode="EaseIn"/>
        <CircleEase x:Key="A_EasingFunction_EaseOut" EasingMode="EaseOut"/>
        <CircleEase x:Key="A_EasingFunction_EaseInOut" EasingMode="EaseInOut"/>

        <Double x:Key="A_MainTitleText_TrackingAdjust_Start">0.25</Double>
        <Double x:Key="A_MainTitleText_TrackingAdjust_End">0.14</Double>

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

        <MappingConverter x:Key="A_MappingConverter_AnnouncementMarkupText">
            <MappingConverterEntry Key="{NoCase YELLOW}" Value="{StaticResource A_Style_FZRun_Markup_Announcement_BottomLine_YELLOW}" />
        </MappingConverter>

        <Style x:Key="H_Style_Announcement_GenericText"
               TargetType="FZTextBlock">
            <Setter Property="FontFamily" Value="Horizon_C" />
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}" />
            <Setter Property="Effect" Value="{StaticResource A_DropShadowEffect_DefaultHud}" />
            <Setter Property="TrackingAdjust" Value="0.15" />
        </Style>
        <Style x:Key="H_Style_Text_MainTitle"
               TargetType="FZTextBlock"
               BasedOn="{StaticResource H_Style_Announcement_GenericText}">
            <Setter Property="CapHeight" Value="41" />
        </Style>
        <Style x:Key="H_Style_Text_TopText"
               TargetType="FZTextBlock"
               BasedOn="{StaticResource H_Style_Announcement_GenericText}">
            <Setter Property="CapHeight" Value="25" />
        </Style>
        <Style x:Key="H_Style_Text_TopHighlightText"
               TargetType="FZTextBlock"
               BasedOn="{StaticResource H_Style_Announcement_GenericText}">
            <Setter Property="CapHeight" Value="20" />
            <Setter Property="Color" Value="{StaticResource H_Color_Primary_Yellow}" />
            <Setter Property="FontFamily" Value="Horizon_B" />
        </Style>
        <Style x:Key="H_Style_Text_BottomText"
               TargetType="FZTextBlock"
               BasedOn="{StaticResource H_Style_Announcement_GenericText}">
            <Setter Property="CapHeight" Value="20" />
            <Setter Property="FontFamily" Value="Horizon_B" />
            <Setter Property="MarkupConverter" Value="{StaticResource A_MappingConverter_AnnouncementMarkupText}" />
        </Style>
    </UserControl.Resources>

    <Grid x:Name="PART_LayoutRoot" Opacity="0">
        <VisualStateManager.VisualStateGroups>
            <UIVisualStateGroup x:Name="VisualStateGroup">
                <VisualState x:Name="PART_Shown">
                    <UIStoryboard>
                        <UIStoryboard.TriggerAnimation>
                            <!--FireAudioEvent to catch on control and play audio-->
                            <RaiseFzEvent TriggerAnimation.KeyTime="0:0:0.01" EventName="FireAudioEvent"/>
                            <RaiseFzEvent TriggerAnimation.KeyTime="0:0:3.92" EventName="ShownAnimationComplete"/>
                        </UIStoryboard.TriggerAnimation>

                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="TrackingAdjust" Storyboard.TargetName="MainTitle">
                            <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="{StaticResource A_MainTitleText_TrackingAdjust_Start}"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:2.0" Value="{StaticResource A_MainTitleText_TrackingAdjust_End}" EasingFunction="{StaticResource A_EasingFunction_EaseOut}"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_LayoutRoot">
                            <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:1.0" Value="1"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:3.92" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                        <UIStoryboard.TriggerAnimation>
                            <RaiseFzEvent EventName="ShowComplete" TriggerAnimation.KeyTime="0:0:3.92"/>
                        </UIStoryboard.TriggerAnimation>
                    </UIStoryboard>
                </VisualState>
                <VisualState x:Name="PART_Hidden">
                    <UIStoryboard>
                        <UIStoryboard.TriggerAnimation>
                            <RaiseFzEvent TriggerAnimation.KeyTime="0:0:1.06" EventName="HiddenAnimationComplete"/>
                        </UIStoryboard.TriggerAnimation>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_LayoutRoot">
                            <EasingDoubleKeyFrame KeyTime="0:0:1.06" Value="0" />
                        </DoubleAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="PART_LayoutRoot">
                            <DiscreteObjectKeyFrame KeyTime="0:0:1.06" Value="{x:Static Visibility.Collapsed}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="TrackingAdjust" Storyboard.TargetName="MainTitle">
                            <DiscreteDoubleKeyFrame KeyTime="0:0:0" Value="{StaticResource A_MainTitleText_TrackingAdjust_End}"/>
                        </DoubleAnimationUsingKeyFrames>
                    </UIStoryboard>
                </VisualState>
            </UIVisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <StackPanel x:Name="DisplayPanel" Orientation="Vertical" RenderTransformOrigin="0.5,0.5" Margin="15,0,15,0">
            <StackPanel.RenderTransform>
                <TransformGroup>
                    <ScaleTransform />
                    <TranslateTransform />
                </TransformGroup>
            </StackPanel.RenderTransform>
            <local:FZTextBlock Style="{StaticResource H_Style_Text_TopText}" 
                               Text="{Binding TopText}"
                               Visibility="{Binding TopText, Converter={StaticResource A_StringVisConverter}}"
                               HorizontalAlignment="Center"
                               Margin="0,0,0,20"
                               ZPanel.ZIndex="1"/>
            <local:FZTextBlock Style="{StaticResource H_Style_Text_TopHighlightText}" 
                               Text="{Binding TopHighlightText}"
                               Visibility="{Binding TopHighlightText, Converter={StaticResource A_StringVisConverter}}"
                               HorizontalAlignment="Center"
                               Margin="0,0,0,5"
                               ZPanel.ZIndex="1"/>
            <local:FZMaterial Width="680"
                              Height="50"
                              ImageSource="{Binding TopImagePath}"
                              Visibility="{Binding TopImagePath, Converter={StaticResource A_StringVisConverter}}"
                              HorizontalAlignment="Center"
                              ZPanel.ZIndex="1"/>
            <Grid Height="60"
                  HorizontalAlignment="Center"
                  Margin="0,-14,0,0">
                <FZMaterial Width="790" Height="100" HorizontalAlignment="Center" VerticalAlignment="Center"
                            ImageSource="Game:\Media\UI\Textures\Anthem\HUD\HUDAnnouncement\pattern.png"
                            Margin="0,-15,0,-15"/>
                <local:FZTextBlock x:Name="MainTitle"
                                   Style="{StaticResource H_Style_Text_MainTitle}" 
                                   Visibility="{Binding MainTitle, Converter={StaticResource A_StringVisConverter}}"
                                   Text="{Binding MainTitle}" 
                                   HorizontalAlignment="Center" 
                                   VerticalAlignment="Center"/>
            </Grid>

            <local:FZMaterial Width="680"
                              Height="50"
                              ImageSource="/ForzaUI;component/Textures/Anthem/HUD/HUDAnnouncement/bottom_line.png"
                              Margin="0,-25,0,0"/>
            <local:FZTextBlock x:Name="BottomText"
                               Style="{StaticResource H_Style_Text_BottomText}"
                               Visibility="{Binding BottomText, Converter={StaticResource A_StringVisConverter}}"
                               Text="{Binding BottomText}" 
                               HorizontalAlignment="Center" />
        </StackPanel>
    </Grid>
</UserControl>