<Page 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_RouteBlueprintHud"
      x:Name="Page"
      WindowTitle="Page"
      FlowDirection="LeftToRight"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={x:Static RelativeSource.Self}}">

    <Page.Resources>
        <ResourceDictionary>

            <local:LinearTransformConverter x:Key="A_TransformConverter_LengthRatio" Scale="356"/>

            <Style x:Key="A_Style_FZRun_HIGHLIGHT" TargetType="{x:Type local:FZRun}">
                <Setter Property="Color" Value="{StaticResource A_Color_HUD_HighlightText}"/>
            </Style>

            <MappingConverter x:Key="A_MappingConverter_TextHighlight">
                <MappingConverterEntry Key="{NoCase HIGHLIGHT}" Value="{StaticResource A_Style_FZRun_HIGHLIGHT}" />
            </MappingConverter>

            <Style x:Key="A_Style_FrameworkElement_MapPin_CollapsedIfArena"
                   TargetType="{x:Type FrameworkElement}">
                <Setter Property="Visibility" Value="Visible" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsArena}" Value="True">
                        <Setter Property="Visibility" Value="Collapsed" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

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

    <Grid x:Name="PART_LayoutRoot">

        <local:FZMaterial x:Name="PropSelectionHighlight"
                              Style="{StaticResource A_Style_FZMaterialPresetStencilHighlight_ARUI}" />

        <ContentControl Style="{StaticResource A_Style_ButtonBar}">
            <local:ControllerButtonPanel x:Name="PART_HelpPanel"
                           Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_ACTIVATE, Context=INPUTCONTEXT_RACING}"
                                   Description="{local:Loc HelpButtons.IDS_RouteBlueprint_Checkpoint_Place}"
                                   Visibility="{Binding CanPlaceCheckpoint, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                   AllowMouseClick="False"/>
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_MULLIGAN, Context=INPUTCONTEXT_RACING}"
                                   Description="{local:Loc HelpButtons.IDS_Mulligan}" 
                                   Visibility="{Binding CanRewind, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                   AllowMouseClick="False"/>
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_OPEN_MAP, Context=INPUTCONTEXT_RACING}"
                                   Description="{local:Loc HelpButtons.IDS_PropPlacement_Mode}"
                                   Visibility="{Binding CanOpenBuilder, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                   AllowMouseClick="False"/>
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_OPEN_MAP, Context=INPUTCONTEXT_RACING}"
                                    Description="{local:Loc HelpButtons.IDS_Exit_FreeDrive}"
                                    Visibility="{Binding CanExitFreeDrive, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                    AllowMouseClick="False"/>
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_PAUSE_GAME, Context=INPUTCONTEXT_RACING}"
                                   Description="{local:Loc HelpButtons.IDS_RouteBlueprint_RouteOptions}"
                                   Visibility="{Binding CanOpenRouteOptions, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                   AllowMouseClick="False"/>
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_PAUSE_GAME, Context=INPUTCONTEXT_RACING}"
                                    Description="{local:Loc HelpButtons.IDS_FreeDrive_PauseOptions}"
                                    Visibility="{Binding CanOpenFreeDriveOptions, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                    AllowMouseClick="False"/>
            </local:ControllerButtonPanel>
        </ContentControl>
      
        <Grid Style="{StaticResource A_Style_FrameworkElement_FadeOnlyTransition_0}">
            <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch"
                  Height="Auto"
                  Width="Auto">
                <Grid x:Name="AdjustableSafeFrame"
                      Margin="{Binding SafeFrameMargin}">

                    <Decorator HorizontalAlignment="Left"
                               VerticalAlignment="Bottom"
                               Margin="0,0,0,60">
                        <local:HUDAnnaControl HUDData.Type="HUDStatusAnna" />
                    </Decorator>

                    <local:HUDSpeedometerControl x:Name="HUDStatusSpeedometer" HUDData.Type="HUDStatusSpeedometer" />

                    <Decorator HorizontalAlignment="Left"
                               VerticalAlignment="Bottom" 
                               Margin="0,0,0,49">
                        <local:HUDRadioControl HUDData.Type="HUDStatusRadio" />
                    </Decorator>
                    <Decorator DataContext="{Binding DataContext, ElementName=HUDStatusSpeedometer}"
                           Style="{StaticResource A_Style_FrameworkElement_WaitSpinnerPositioner}">
                        <local:HUDWaitSpinnerControl HUDData.Type="HUDStatusWaitSpinner" />
                    </Decorator>

                    <Decorator HorizontalAlignment="Center"
                               VerticalAlignment="Top">
                        <StackPanel>
                            <Decorator Style="{StaticResource A_Style_FrameworkElement_NotificationPopupSpaceMaker}" />
                            <local:HUDWarningToastControl HUDData.Type="HUDStatusWarningToast" />
                        </StackPanel>
                    </Decorator>
                    <Decorator HorizontalAlignment="Right"
                               VerticalAlignment="Top">
                        <local:HUDMiniLeaderboardControl HUDData.Type="HUDStatusMiniLeaderboard" />
                    </Decorator>

                    <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
                        <Decorator Visibility="{Binding IsRecordingRoute, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" LayoutTransform="{StaticResource A_SkewTransform_HUD_Italics}">
                            <local:FZTextBlock Style="{StaticResource H_Style_Text_Creation_MainTitle}" 
                                               Text="{local:Loc EventBlueprint.IDS_RouteCreator}" />
                        </Decorator>
			            <Decorator Visibility="{Binding IsFreeDriving, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" LayoutTransform="{StaticResource A_SkewTransform_HUD_Italics}">
                            <local:FZTextBlock Style="{StaticResource H_Style_Text_Creation_MainTitle}" 
                                               Text="{local:Loc EventBlueprint.IDS_RouteBlueprint_FreeDrive_Title}" />
                        </Decorator>
                        <StackPanel Visibility="{Binding IsFreeDriving, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                            <Decorator Height="17"/>
                            <Grid>
                                <local:FZMaterial Style="{StaticResource A_Style_Material_Creation_Pill_Background_4px}" />
                                <DockPanel>
                                    <local:FZTextBlock Text="{local:Loc EventBlueprint.IDS_Length}" 
                                                       Style="{StaticResource H_Style_Text_Creation_PillHeader}"/>
                                    <local:FZTextBlock Text="{Binding RouteLength}" 
                                                       Style="{StaticResource H_Style_Text_Creation_PillContent}" />
                                </DockPanel>
                            </Grid>
                            <Decorator Height="2"/>
                            <Grid>
                                <local:FZMaterial Style="{StaticResource A_Style_Material_Creation_Pill_Background_4px}" />

                                <DockPanel>
                                    <local:FZTextBlock Text="{local:Loc EventBlueprint.IDS_RouteBlueprint_CheckPoints}" 
                                                       Style="{StaticResource H_Style_Text_Creation_PillHeader}"/>
                                    <local:FZTextBlock local:MultiStringFormatter.Format="{local:Loc EventBlueprint.IDS_RouteBlueprint_CheckpointProgress}"
                                                       local:MultiStringFormatter.Param0="{Binding AmountOfPlacedCheckpoints}"
                                                       local:MultiStringFormatter.Param1="{Binding MaxCheckpoints}"
                                                       Text="{Binding (local:MultiStringFormatter.Output), RelativeSource={RelativeSource Self}}"
                                                       Style="{StaticResource H_Style_Text_Creation_PillContent}" />
                                </DockPanel>
                            </Grid>
                        </StackPanel>
                    </StackPanel>

                    <!-- Network Controls -->
                    <local:HUDNetworkStatusControl HUDData.Type="HUDStatusNetworkStatus" />
                        
                    <Decorator Margin="0,0,0,24" VerticalAlignment="Bottom"
                               Style="{StaticResource A_Style_FrameworkElement_MapPin_CollapsedIfArena}">
                        <StackPanel>
                            <local:HUDPressButtonControl HUDData.Type="HUDStatusPressButton" Margin="0,0,0,0"/>
                            <Decorator Style="{StaticResource A_Style_FrameworkElement_SubtitlesSpaceMaker}" />
                        </StackPanel>
                    </Decorator>
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</Page>
