<UserControl
    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"
    mc:Ignorable="d"
    xmlns:local="clr-namespace:ForzaUI" 
    x:Class="ForzaUI.HUDTrackChallengeControl"
    x:Name="UserControl"
    RenderTransformOrigin="0.5,0.5">

    <UserControl.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_FZTextBlock_HudMedium_TrackChallenge" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HudMedium}">
                <Setter Property="VerticalAlignment" Value="Bottom"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_HudMedium_TrackChallenge_Highlight" TargetType="{x:Type local:FZTextBlock}" BasedOn="{StaticResource A_Style_FZTextBlock_HudMedium_TrackChallenge}">
                <Setter Property="Color" Value="{StaticResource A_Color_HUD_AlternateText}" />
            </Style>

            <Style x:Key="A_Style_FrameworkElement_Positioner" TargetType="FrameworkElement">
                <Setter Property="Margin" Value="0,99,0,0" />
                <Setter Property="HorizontalAlignment" Value="Right" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding DisplayMode}" Value="OnlineP2P">
                        <Setter Property="Margin" Value="0,160,0,0" />
                        <Setter Property="HorizontalAlignment" Value="Left" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding DisplayMode}" Value="OnlineCircuit">
                        <Setter Property="Margin" Value="0,235,0,0" />
                        <Setter Property="HorizontalAlignment" Value="Left" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Thickness x:Key="A_Thickness_TextMargin">0,-2,0,2</Thickness>
            <Thickness x:Key="A_Thickness_ItemMargin">0,0,0,3</Thickness>
        </ResourceDictionary>
    </UserControl.Resources>

    <Decorator x:Name="LayoutRoot" 
               Style="{StaticResource A_Style_FrameworkElement_Positioner}"
               VerticalAlignment="Top"
               MinWidth="320">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.5"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Hidden">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LayoutRoot">
                            <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Shown">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LayoutRoot">
                            <EasingDoubleKeyFrame KeyTime="0" Value="1"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <StackPanel Orientation="Vertical" VerticalAlignment="Top" >
            <local:FZMaterial x:Name="TargetBlock"  Style="{StaticResource A_Style_FZMaterial_GlassHudItem}"
                              Visibility="{Binding TargetLabel, Converter={StaticResource A_StringVisConverter}}"
                              Margin="{StaticResource A_Thickness_ItemMargin}">
                <DockPanel Margin="{StaticResource A_Thickness_TextMargin}">
                    <local:FZTextBlock DockPanel.Dock="Left" HorizontalAlignment="Left" Text="{Binding TargetLabel}" 
                                       Style="{StaticResource A_Style_FZTextBlock_HudMedium_TrackChallenge}" 
                                       Margin="10,0,10,0"/>
                    <local:FZTextBlock HorizontalAlignment="Right" Text="{Binding TargetValue}" 
                                       Style="{StaticResource A_Style_FZTextBlock_HudMedium_TrackChallenge}" 
                                       MaxWidth="160" Margin="10,0,10,0"/>
                </DockPanel>
            </local:FZMaterial>
            <local:FZMaterial x:Name="CurrentBlock" Style="{StaticResource A_Style_FZMaterial_GlassHudItem}" 
                              Margin="{StaticResource A_Thickness_ItemMargin}" >
                <DockPanel Margin="{StaticResource A_Thickness_TextMargin}">
                    <local:FZTextBlock DockPanel.Dock="Left" HorizontalAlignment="Left" 
                                       Text="{Binding CurrentLabel}" 
                                       Style="{StaticResource A_Style_FZTextBlock_HudMedium_TrackChallenge}" 
                                       Margin="10,0,10,0"/>
                    <local:FZTextBlock HorizontalAlignment="Right" Text="{Binding CurrentValue}" 
                                       Style="{StaticResource A_Style_FZTextBlock_HudMedium_TrackChallenge_Highlight}"
                                       MaxWidth="160" Margin="10,0,10,0"/>
                </DockPanel>
            </local:FZMaterial>
        </StackPanel>
    </Decorator>
</UserControl>
