<Page 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"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:local="clr-namespace:ForzaUI"
      x:Class="ForzaUI.A_CarLoadingWelcome"
      mc:Ignorable="d"
      VerticalAlignment="Center"
      HorizontalAlignment="Center"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <Page.Resources>

        <ControlTemplate x:Key="A_Template_CLC_WelcomeSubtitle" TargetType="Control">
            <ControlTemplate.Resources>
                <CircleEase x:Key="A_EasingFunction_EaseOut" EasingMode="EaseOut"/>
                <Storyboard x:Key="Show">
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" 
                                                    Storyboard.TargetName="TitleText">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="-700"/>
                        <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" EasingFunction="{StaticResource A_EasingFunction_EaseOut}"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
                <Storyboard x:Key="StartOff">
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" 
                                                    Storyboard.TargetName="TitleText">
                        <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="-700" />
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </ControlTemplate.Resources>
            <StackPanel Orientation="Vertical">
                <Grid ClipToBounds="True">
                    <Grid x:Name="TitleText" Margin="0,-14,0,-16" Style="{StaticResource A_Style_Grid_ARUIMotionBlur}">
                        <Grid.RenderTransform>
                            <TranslateTransform />
                        </Grid.RenderTransform>
                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_CLC_Subtitle}"
                                           Color="{StaticResource A_Color_CLC_ARUI_SubTitle}"
                                           Text="{Binding Subtitle}"/>
                    </Grid>
                </Grid>
                <local:EventFire.FzTriggers>
                    <local:EventFireTrigger Event="showevent"
                                            Storyboard="{StaticResource Show}" />
                    <local:EventFireTrigger Event="hideevent"
                                            Storyboard="{StaticResource StartOff}" />
                    <local:EventFireTrigger Event="startoffevent"
                                            Storyboard="{StaticResource StartOff}" />
                </local:EventFire.FzTriggers>
            </StackPanel>
        </ControlTemplate>

        <Storyboard x:Key="A_Storyboard_CLC_ShowStoryboard_Welcome">
            <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)"
                                           Storyboard.TargetName="TitleEventFire">
                <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="startoffevent" />
                <DiscreteStringKeyFrame KeyTime="0:0:0.2" Value="showevent" />
            </StringAnimationUsingKeyFrames>
            <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:AudioEvent.SoundName)"
                                       Storyboard.TargetName="TitleAudioEvent">
                <DiscreteStringKeyFrame KeyTime="0:0:0.2" Value="/Master/UI/PostRace/HZ2_SFX_HUD_PostRace_XPRewardsTitleOn_01" />
            </StringAnimationUsingKeyFrames>
            <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)"
                                           Storyboard.TargetName="UnderlineEventFire">
                <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="startoffevent" />
                <DiscreteStringKeyFrame KeyTime="0:0:0.2" Value="showevent" />
            </StringAnimationUsingKeyFrames>
            <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)"
                                           Storyboard.TargetName="SubtitleEventFire">
                <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="startoffevent" />
                <DiscreteStringKeyFrame KeyTime="0:0:0.2" Value="showevent" />
            </StringAnimationUsingKeyFrames>
        </Storyboard>

        <Storyboard x:Key="A_Storyboard_CLC_HideStoryboard_Welcome">
            <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)"
                                           Storyboard.TargetName="TitleEventFire">
                <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="startoffevent" />
            </StringAnimationUsingKeyFrames>
            <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)"
                                           Storyboard.TargetName="UnderlineEventFire">
                <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="startoffevent" />
            </StringAnimationUsingKeyFrames>
            <StringAnimationUsingKeyFrames Storyboard.TargetProperty="(local:EventFire.EventName)"
                                           Storyboard.TargetName="SubtitleEventFire">
                <DiscreteStringKeyFrame KeyTime="0:0:0.0" Value="startoffevent" />
            </StringAnimationUsingKeyFrames>
        </Storyboard>
    </Page.Resources>

    <Grid>
        <StackPanel VerticalAlignment="Center">
            <Viewbox HorizontalAlignment="Center" MaxHeight="656">
                <ContentControl x:Name="TitleControl"
                            Template="{StaticResource A_Template_CLC_SingleLineTitle}" />
            </Viewbox>
            <ContentControl x:Name="UnderlineControl"
                            Template="{StaticResource A_Template_CLC_TitleUnderline}" />
            <Viewbox HorizontalAlignment="Center" MaxHeight="185">
                <ContentControl x:Name="SubtitleControl"
                            Template="{StaticResource A_Template_CLC_WelcomeSubtitle}"/>
            </Viewbox>
        </StackPanel>

        <local:EventFire x:Name="TitleEventFire" TargetName="TitleControl" />
        <local:EventFire x:Name="UnderlineEventFire" TargetName="UnderlineControl" />
        <local:EventFire x:Name="SubtitleEventFire" TargetName="SubtitleControl" />

        <!-- Audio Events -->
        <local:AudioEvent x:Name="TitleAudioEvent" />
    </Grid>
</Page>
