<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.HUDCurrencyAwardControl"
    x:Name="UserControl"
    Margin="490,0,0,0"
    VerticalAlignment="Center"
    HorizontalAlignment="Left" >

    <UserControl.Resources>
        <ResourceDictionary>
            <CircleEase x:Key="A_EasingFunction_Circle_EaseOut" EasingMode="EaseOut"/>
            <CircleEase x:Key="A_EasingFunction_Circle_EaseIn" EasingMode="EaseIn"/>

            <local:NumUnitConverter x:Key="A_NumUnitConverter_XPConverterSpecific" FractionDigits="0" ShowUnit="False" PositiveSign="False"/>

            <Style x:Key="A_Style_FZTextBlock_XPReason" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HudMedium_Tight}">
                <Setter Property="CapHeight" Value="19"/>
                <Setter Property="LineAdjust" Value="-0.55"/>
            </Style>

            <MappingConverter x:Key="H_ColorType_To_XAMLHUDColor" Default="{StaticResource H_Color_Primary_White}" CheckEnumKey="XAMLHUDColorType">
                <MappingConverterEntry Key="{x:Static XAMLHUDColorType.Default}" Value="{StaticResource H_Color_Primary_White}"/>
                <MappingConverterEntry Key="{x:Static XAMLHUDColorType.Red}" Value="#FFFF6060"/>
                <MappingConverterEntry Key="{x:Static XAMLHUDColorType.Green}" Value="#FF1DFF8F"/>
                <MappingConverterEntry Key="{x:Static XAMLHUDColorType.Blue}" Value="#FF6060FF"/>
                <MappingConverterEntry Key="{x:Static XAMLHUDColorType.Yellow}" Value="{StaticResource H_Color_Primary_Yellow}"/>
                <MappingConverterEntry Key="{x:Static XAMLHUDColorType.Pink}" Value="{StaticResource H_Color_Primary_Pink}"/>
                <MappingConverterEntry Key="{x:Static XAMLHUDColorType.Purple}" Value="{StaticResource H_Color_Primary_Purple}"/>
            </MappingConverter>
            
            <Style x:Key="A_Style_FZTextBlock_XPAmount" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_XPReason}">
                <Setter Property="CapHeight" Value="24"/>
                <Setter Property="FontFamily" Value="Horizon_A"/>
            </Style>

            <MappingConverter x:Key="H_CurrencyTypeToUnitString">
                <MappingConverterEntry Key="{x:Static XAMLHUDCurrencyRewardType.Credits}" Value=""/>
                <MappingConverterEntry Key="{x:Static XAMLHUDCurrencyRewardType.XP}" Value="{local:Loc UnitStrings.IDS_Units_XP_Label}"/>
                <MappingConverterEntry Key="{x:Static XAMLHUDCurrencyRewardType.Kudos}" Value="{local:Loc UnitStrings.IDS_Units_Kudos_Label}"/>
            </MappingConverter>

            <MappingConverter x:Key="H_Converter_CurrencyTypeToCreditsIconVisibility" Default="Collapsed">
                <MappingConverterEntry Key="{x:Static XAMLHUDCurrencyRewardType.Credits}" Value="Visible"/>
            </MappingConverter>

            <MappingConverter x:Key="H_CurrencyType_HiddenInEventLab" Default="Visible">
                <MappingConverterEntry Key="{x:Static XAMLHUDCurrencyRewardType.EventLab}" Value="Hidden"/>
            </MappingConverter>
         </ResourceDictionary>
    </UserControl.Resources>

    <Grid x:Name="PART_LayoutRoot" VerticalAlignment="Top" HorizontalAlignment="Center">
        <VisualStateManager.VisualStateGroups>
            <UIVisualStateGroup x:Name="VisualStateGroup">
                <VisualState x:Name="PART_Hidden">
                    <UIStoryboard>
                        <UIStoryboard.TriggerAnimation>
                            <RaiseFzEvent TriggerAnimation.KeyTime="0:0:0.5" EventName="PART_HiddenComplete"/>
                        </UIStoryboard.TriggerAnimation>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MainPanel">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0" EasingFunction="{StaticResource A_EasingFunction_Circle_EaseIn}"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="MainPanel">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="-50" EasingFunction="{StaticResource A_EasingFunction_Circle_EaseIn}"/>
                        </DoubleAnimationUsingKeyFrames>
                    </UIStoryboard>
                </VisualState>
                <VisualState Name="PART_Shown">
                    <UIStoryboard>
                        <UIStoryboard.TriggerAnimation>
                            <RaiseFzEvent TriggerAnimation.KeyTime="0:0:0.4" EventName="PART_ShownComplete"/>
                            <StartAudioTrigger TriggerAnimation.KeyTime="0:0:0.0" EventName="/Master/UI/DrivingSkills/HZ2_SFX_HUD_DrivingSkills_XPEarned_01"/>
                        </UIStoryboard.TriggerAnimation>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MainPanel">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1" EasingFunction="{StaticResource A_EasingFunction_Circle_EaseIn}"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TranslateTransform.Y)" Storyboard.TargetName="MainPanel">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.0" Value="25" EasingFunction="{StaticResource A_EasingFunction_Circle_EaseIn}"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="-5" EasingFunction="{StaticResource A_EasingFunction_Circle_EaseOut}"/>
                            <EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </UIStoryboard>
                </VisualState>
            </UIVisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <StackPanel x:Name="MainPanel" Orientation="Vertical" HorizontalAlignment="Right">
            <StackPanel.RenderTransform>
                <TranslateTransform />
            </StackPanel.RenderTransform>
            <local:FZTextBlock Text="{Binding ReasonString}" Style="{StaticResource A_Style_FZTextBlock_XPReason}" HorizontalAlignment="Right" RenderTransform="{StaticResource A_SkewTransform_HUD_Italics}" RenderTransformOrigin="0.5,0.5" TextAlignment="Right"/>
            <StackPanel Orientation="Horizontal" Margin="0,11,0,0" HorizontalAlignment="Right"  >
                <Control Style="{StaticResource H_Style_Control_CreditsIcon}" Margin="-2,-16,6,-16"
                         Visibility="{Binding Type, Converter={StaticResource H_Converter_CurrencyTypeToCreditsIconVisibility}}"
                         Height="32"
                         Width="32"/>
                <local:FZTextBlock Text="{Binding Earned, Converter={StaticResource A_NumUnitConverter_XPConverterSpecific}}"
                                   Color="{Binding XAMLHUDColorType, Converter={StaticResource H_ColorType_To_XAMLHUDColor}}"
                                   Style="{StaticResource A_Style_FZTextBlock_XPAmount}" Margin="0,0,0,0" VerticalAlignment="Center"
                                   HorizontalAlignment="Right"
                                   RenderTransform="{StaticResource A_SkewTransform_HUD_Italics}"
                                   RenderTransformOrigin="0.5,0.5"/>
                <local:FZTextBlock Text="{Binding Type, Converter={StaticResource H_CurrencyTypeToUnitString}}" Style="{StaticResource A_Style_FZTextBlock_HudMedium_Tight}"
                                   FontFamily="Horizon_A"
                                   CapHeight="24"
                                   Color="{StaticResource H_Color_Primary_White}"
                                   Visibility="{Binding Type, Converter={StaticResource H_CurrencyType_HiddenInEventLab}}"
                                   VerticalAlignment="Center"
                                   HorizontalAlignment="Center"
                                   RenderTransform="{StaticResource A_SkewTransform_HUD_Italics}"
                                   RenderTransformOrigin="0.5,0.5"
                                   Margin="8,0,0,0"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
