<Hud xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      x:Class="ForzaUI.A_Hud"
      x:Name="Page"
      WindowTitle="Page"
      FlowDirection="LeftToRight"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={x:Static RelativeSource.Self}}">
    <Page.Resources>
        <Style x:Key="A_Style_FrameworkElement_LayoutRoot_HUD"
            TargetType="FrameworkElement"
            BasedOn="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <Setter Property="Opacity" Value="1"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding AreRaceBordersActive, Source={StaticResource PART_UISceneContext}, FallbackValue={StaticResource A_Boolean_False}}" Value="{StaticResource A_Boolean_True}">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard>
                            <BeginStoryboard.Storyboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetProperty="Opacity"
                                        Storyboard.TargetName="{Null}"
                                        To="0"
                                        BeginTime="0:0:0.4"
                                        Duration="0:0:0.75"/>
                                </Storyboard>
                            </BeginStoryboard.Storyboard>
                        </BeginStoryboard>
                    </DataTrigger.EnterActions>
                    <DataTrigger.ExitActions>
                        <BeginStoryboard>
                            <BeginStoryboard.Storyboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetProperty="Opacity"
                                        Storyboard.TargetName="{Null}"
                                        FillBehavior="Stop"
                                        To="1"
                                        BeginTime="0:0:0.1"
                                        Duration="0:0:0.1"/>
                                </Storyboard>
                            </BeginStoryboard.Storyboard>
                        </BeginStoryboard>
                    </DataTrigger.ExitActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <local:MappingConverter x:Key="A_Converter_RadarPositionEnum_to_HorizontalAlignment" Default="{x:Static HorizontalAlignment.Center}">
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.RightBottom}" Value="{x:Static HorizontalAlignment.Right}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.CenterLeft}" Value="{x:Static HorizontalAlignment.Center}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.CenterRight}" Value="{x:Static HorizontalAlignment.Center}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.CenterTop}" Value="{x:Static HorizontalAlignment.Center}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.CenterBottom}" Value="{x:Static HorizontalAlignment.Center}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.RightTop}" Value="{x:Static HorizontalAlignment.Right}"/>
        </local:MappingConverter>

        <local:MappingConverter x:Key="A_Converter_RadarPositionEnum_to_VerticalAlignment" Default="{x:Static VerticalAlignment.Center}">
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.RightBottom}" Value="{x:Static VerticalAlignment.Bottom}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.CenterLeft}" Value="{x:Static VerticalAlignment.Center}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.CenterRight}" Value="{x:Static VerticalAlignment.Center}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.CenterTop}" Value="{x:Static VerticalAlignment.Center}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.CenterBottom}" Value="{x:Static VerticalAlignment.Center}"/>
            <local:MappingConverterEntry Key="{x:Static local:ProximityRadarPositionOptionsEnum.RightTop}" Value="{x:Static VerticalAlignment.Bottom}"/>
        </local:MappingConverter>

    </Page.Resources>

    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Hud}" />
    </local:UIPageTransitionManager.TransitionManager>

    <Grid Style="{StaticResource A_Style_FrameworkElement_FadeOnlyTransition_0}">
        <Grid x:Name="PART_LayoutRoot"
              Style="{StaticResource A_Style_FrameworkElement_LayoutRoot_HUD}"
              HorizontalAlignment="Stretch"
              VerticalAlignment="Stretch"
              Height="Auto"
              Width="Auto">
            <Grid x:Name="AdjustableSafeFrame"
                  Margin="{Binding SafeFrameMargin}">

                <!-- HUD Controls -->
                <local:HUDActivationControl x:Name="HUDStatusActivation" HUDData.Type="HUDStatusActivation" HorizontalAlignment="Left" VerticalAlignment=" Bottom" Margin="25,0,0,452"/>

                <!--Always On-->
                <local:HUDRadioControl HUDData.Type="HUDStatusRadio" />

                <local:HUDInfoFeedControl HUDData.Type="HUDStatusInfoFeed" />

                <Grid x:Name="HUDSkill">
                    <local:HUDSkillControl HUDData.Type="HUDStatusSkill" />
                    <local:HUDSkillTokenControl HUDData.Type="HUDStatusSkillToken"/>
                    <local:HUDSkillSongControl HUDData.Type="HUDStatusSkillSong"/>
                </Grid>

                <Grid x:Name="HUDProximity"
                      HorizontalAlignment="{Binding ProximityRadarPosition, Converter={StaticResource A_Converter_RadarPositionEnum_to_HorizontalAlignment}}"
                      VerticalAlignment="{Binding ProximityRadarPosition, Converter={StaticResource A_Converter_RadarPositionEnum_to_VerticalAlignment}}">
                    <local:HUDProximityBlindspotControl HUDData.Type="HUDStatusProximityBlindspot"/>
                    <local:HUDProximityRadarControl HUDData.Type="HUDStatusProximityRadar"/>
                </Grid>

                <Grid x:Name="HUDAnnaAndSpeedometerAndConvertibleAndLoadingSpinner">
                    <local:HUDAnnaControl HUDData.Type="HUDStatusAnna"/>
                    <StackPanel x:Name="HUDSpeedometerAndHUDStatusConvertible" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right">
                        <!-- pivot should be right aligned so that we can specify the correct right margin without having to think about the width-->
                        <StackPanel x:Name="ConvertibleAndLoadingSpinner" Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Right">
                            <local:HUDWaitSpinnerControl HUDData.Type="HUDStatusWaitSpinner" HorizontalAlignment="Right"/>
                            <local:HUDConvertibleControl HUDData.Type="HUDStatusConvertible" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
                        </StackPanel>
                        <local:HUDSpeedometerControl HUDData.Type="HUDStatusSpeedometer" VerticalAlignment="Bottom" HorizontalAlignment="Right" 
                                                     Visibility="{Binding IsSpeedoVisible, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                    </StackPanel>
                </Grid>

                <!--SimpleStatusControls-->
                <local:HUDWrongWayControl HUDData.Type="HUDStatusWrongWay"
                                          VerticalAlignment="Top"
                                          Margin="0,260,0,0" />

                <local:HUDEliminatorProgressControl HUDData.Type="HUDStatusEliminatorProgress"
                                                VerticalAlignment="Top"/>

                <local:HUDHideSeekProgressControl HUDData.Type="HUDStatusHideSeekProgress"
                                                VerticalAlignment="Top"/>

                <!--Race Controls-->
                <StackPanel HorizontalAlignment="Left"
                            VerticalAlignment="Top"
                            Orientation="Vertical">
                    <local:HUDRaceProgressControl HUDData.Type="HUDStatusRaceProgress"
                                                    VerticalAlignment="Top"/>

                    <HUDCreationInfoControl HUDData.Type="HUDStatusCreationInfo" />

                    <local:HUDTestDriveTimeLeftControl VerticalAlignment="Top" HorizontalAlignment="Left" HUDData.Type="HUDStatusTestDriveTimeLeft"/>

                    <local:HUDInstructionControl HUDData.Type="HUDStatusInstruction"
                                                 VerticalAlignment="Top"
                                                 Visibility="{Binding IsVisibilityOptionEnabled, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                </StackPanel>

                <StackPanel>
                    <local:HUDEliminatorCarGradeControl HUDData.Type="HUDStatusEliminatorCarGrade" />
                    <local:HUDMiniLeaderboardControl HUDData.Type="HUDStatusMiniLeaderboard" />
                </StackPanel>

                <!-- Notifications and Transient Controls -->
                <local:HUDMajorNotificationControl HUDData.Type="HUDStatusMajorNotification" />
                
                <local:HUDAnnouncementControl HUDData.Type="HUDStatusAnnouncement" />

                <local:HUDRaceVersusControl HUDData.Type="HUDStatusRaceVersus" />

                <local:HUDCurrencyAwardControl HUDData.Type="HUDStatusCurrencyAward"/>

                <!-- Network Controls -->
                <local:HUDNetworkStatusControl HUDData.Type="HUDStatusNetworkStatus"/>

                <local:HUDDriveToEventControl HUDData.Type="HUDStatusNetworkRoadTripDestinationDrive"/>
                <StackPanel VerticalAlignment="Bottom">
                    <local:HUDRaceFinishCountdownControl HUDData.Type="HUDStatusRaceCountdown" />
                    <Decorator Style="{StaticResource A_Style_FrameworkElement_SubtitlesSpaceMaker}" />
                </StackPanel>

                <StackPanel HorizontalAlignment="Left"
                            VerticalAlignment="Top">
                    <local:HUDChallengeControl HUDData.Type="HUDStatusChallenge"/>
                </StackPanel>

                <StackPanel VerticalAlignment="Bottom">
                    <local:HUDEliminatorUpgradeChoiceControl HUDData.Type="HUDStatusEliminatorUpgradeChoiceBase"/>
                    <Grid>
                        <local:HUDMinorNotificationControl HUDData.Type="HUDStatusMinorNotification" />
                        <local:HUDStuntPartyProgressControl HUDData.Type="HUDStatusStuntPartyProgress" />
                        <local:HUDRivalsEverywhereControl HUDData.Type="HUDStatusRivalsEverywhere"/>
                        <local:HUDStagedAmbientEventControl HUDData.Type="HUDStatusStagedAmbientEvent"/>
                    </Grid>
                    <StackPanel Margin="0,0,0,-12">
                        <local:HUDPressButtonControl HUDData.Type="HUDStatusPressButton" Margin="0"/>
                        <Decorator Style="{StaticResource A_Style_FrameworkElement_SubtitlesSpaceMaker}" />
                    </StackPanel>
                </StackPanel>
                
                <local:HUDRewardRevealsControl HUDData.Type="HUDStatusRewardReveals"/>

                <StackPanel VerticalAlignment="Bottom">
                    <local:HUDHideSeekCompassControl HUDData.Type="HUDStatusHideSeekCompass"
                                 HorizontalAlignment="Center"
                                 Margin="0,0,0,-58"
                                 local:BindingProxy.A="{Binding (local:BlendValue.Blend), ElementName=SubtitleSpaceMakerCompass}" />
                    <Decorator Style="{StaticResource A_Style_FrameworkElement_SubtitlesSpaceMaker}" x:Name="SubtitleSpaceMakerCompass"  />
                </StackPanel>

                <!--Not actually in HUD status'-->
                <Decorator HUDData.Type="HUDStatusDummyNotInHUD"/>
                <Decorator HUDData.Type="HUDStatusDummyEliminatorAnnouncement"/>
            </Grid>
        </Grid>
    </Grid>
</Hud>
