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

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

    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_ControllerButtonControl_MovementControl_Right" TargetType="local:ControllerButtonControl" BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
                <Setter Property="Visibility" Value="Collapsed"/>
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding IsControllerActiveInput, RelativeSource={RelativeSource AncestorType=Page}}" Value="False"/>
                            <Condition Binding="{Binding IsCurrentCheckpointEditable, RelativeSource={RelativeSource AncestorType=Page}}" Value="True"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Visibility" Value="Visible"/>
                    </MultiDataTrigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="A_Style_ControllerButtonControl_MovementControl" TargetType="local:ControllerButtonControl" BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
                <Setter Property="Description" Value="{local:Loc HelpButtons.IDS_RouteBlueprint_Checkpoint_MoveCheckPoint_Left}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsControllerActiveInput, RelativeSource={RelativeSource AncestorType=Page}}" Value="True">
                        <Setter Property="Description" Value="{local:Loc HelpButtons.IDS_RouteBlueprint_Checkpoint_MoveCheckPoint}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Page.Resources>

    <Grid x:Name="PART_LayoutRoot">
        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <Grid x:Name="AdjustableSafeFrame" Margin="{Binding SafeFrameMargin}">

                <StackPanel VerticalAlignment="Center"
                            HorizontalAlignment="Center"
                            Margin="0,0,0,400"
                            Visibility="{Binding IsEditingCheckpoints, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                            Style="{StaticResource A_Style_FrameworkElement_FadeOnlyTransition_0}">
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HUDBase}"
                                       Effect="{StaticResource A_DropShadowEffect_DefaultHud}"
                                       FontFamily="Horizon_A"
                                       CapHeight="40"
                                       TextWrapping="Wrap"
                                       TextAlignment="Center" 
                                       LineStackingStrategy="BlockLineHeight"
                                       Visibility="{Binding IsCurrentCheckpointStartline, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"
                                       Text="{Binding (local:MultiStringFormatter.Output), RelativeSource={RelativeSource Self}}"
                                       local:MultiStringFormatter.Format="{Binding Source={local:Loc EventBlueprint.IDS_RouteBlueprint_CurrentCheckpoint}, Converter={StaticResource A_StringToUpper}}"
                                       local:MultiStringFormatter.Param0="{Binding CurrentCheckpointIndex, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_IndexToNumberConverter}}"
                                       local:MultiStringFormatter.Param1="{Binding CheckpointCount, RelativeSource={RelativeSource AncestorType=Page}}" />
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HUDBase}"
                                       Effect="{StaticResource A_DropShadowEffect_DefaultHud}"
                                       FontFamily="Horizon_A"
                                       CapHeight="40"
                                       TextWrapping="Wrap"
                                       TextAlignment="Center"
                                       Visibility="{Binding IsCurrentCheckpointStartline, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                       LineStackingStrategy="BlockLineHeight"
                                       Text="{Binding Source={local:Loc EventBlueprint.IDS_RouteBlueprint_CurrentCheckpointStartline}, Converter={StaticResource A_StringToUpper}}"/>
                    <Decorator Height="20" />
                    <StackPanel Orientation="Horizontal"
                                HorizontalAlignment="Center"
                                Margin="0,2,0,0"
                                Visibility="{Binding AllowNextPrevCheckpoint, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                        <local:ControllerButtonControl MinHeight="30"
                                                       Margin="0,-10,6,-10"
                                                       Style="{StaticResource A_Style_ControllerButtonControl_ActivationButton}"
                                                       InputOverride="{local:Input Command=INPUTCMD_QUICKCHAT_ACTIVATE, Context=INPUTCONTEXT_RACING_UI}"
                                                       Visibility="Visible"
                                                       UseLargeIcon="True" />
                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HudMedium_Tight}"
                                           FontFamily="Horizon_C"
                                           CapHeight="15"
                                           TextWrapping="Wrap"
                                           TextAlignment="Center"
                                           Text="{local:Loc EventBlueprint.IDS_RouteBlueprint_PreviousCheckpoint}" />
                        <Decorator Width="35" />
                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HudMedium_Tight}"
                                           FontFamily="Horizon_C"
                                           CapHeight="15"
                                           TextWrapping="Wrap"
                                           TextAlignment="Center"
                                           Text="{local:Loc EventBlueprint.IDS_RouteBlueprint_NextCheckpoint}" />
                        <local:ControllerButtonControl MinHeight="30"
                                                       Margin="6,-10,0,-10"
                                                       Style="{StaticResource A_Style_ControllerButtonControl_ActivationButton}"
                                                       InputOverride="{local:Input Command=INPUTCMD_RADIO_RIGHT, Context=INPUTCONTEXT_RACING_UI}"
                                                       Visibility="Visible"
                                                       UseLargeIcon="True" />
                    </StackPanel>
                </StackPanel>

                <!--Do not change visibility! 
                    This control exists so a hud status (not intended to be recreated) does not get removed for not being in the scene, 
                    which is something that RouteBlueprintCheckpointEditor and RouteBlueprintHud does to get rid of inactive status's -->
                <local:HUDAnnaControl HUDData.Type="HUDStatusAnna" Visibility="Collapsed"/>

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

                <StackPanel Margin="0,0,0,24" VerticalAlignment="Bottom">
                    <local:HUDPressButtonControl HUDData.Type="HUDStatusPressButton" Margin="0"/>
                    <Decorator Style="{StaticResource A_Style_FrameworkElement_SubtitlesSpaceMaker}" />
                </StackPanel>
            </Grid>
        </Grid>

        <ContentControl Style="{StaticResource A_Style_ButtonBar}">
            <local:ControllerButtonPanel x:Name="PART_HelpPanel"
                           Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <local:ControllerButtonControl Button="A"
                                               Description="{local:Loc HelpButtons.IDS_Confirm}"
                                               Visibility="{Binding IsEditingCheckpoints, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"/>
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_HANDBRAKE, Context=INPUTCONTEXT_RACING}"
                                               Description="{local:Loc HelpButtons.IDS_RouteBlueprint_Checkpoint_Edit_Finish}"
                                               Visibility="{Binding IsEditingCheckpoints, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" />
                <local:ControllerButtonControl Button="B"
                                               Description="{local:Loc HelpButtons.IDS_Cancel}"
                                               Visibility="{Binding IsEditingCheckpoints, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"/>
                
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_STEERING, Context=INPUTCONTEXT_RACING}"
                                               Style="{StaticResource A_Style_ControllerButtonControl_MovementControl}"
                                               Visibility="{Binding IsCurrentCheckpointEditable, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>

                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_STEERING, Context=INPUTCONTEXT_RACING}"
                                               Style="{StaticResource A_Style_ControllerButtonControl_MovementControl_Right}"
                                               UseHighKeyIfLinearCommand="True"
                                               Description="{local:Loc HelpButtons.IDS_RouteBlueprint_Checkpoint_MoveCheckPoint_Right}"
                                               />

                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_BRAKE, Context=INPUTCONTEXT_RACING}"
                                               Description="{local:Loc HelpButtons.IDS_RouteBlueprint_Checkpoint_Narrow}"
                                               Visibility="{Binding IsCurrentCheckpointEditable, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_GAS, Context=INPUTCONTEXT_RACING}"
                                               Description="{local:Loc HelpButtons.IDS_RouteBlueprint_Checkpoint_Widen}"
                                               Visibility="{Binding IsCurrentCheckpointEditable, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_ACTIVATE, Context=INPUTCONTEXT_RACING}"
                                               Description="{local:Loc HelpButtons.IDS_RouteBlueprint_Resume_Recording}"
                                               Visibility="{Binding IsEditingCheckpoints, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" />
                <local:ControllerButtonControl InputOverride="{local:Input Command=INPUTCMD_OPEN_MAP, Context=INPUTCONTEXT_RACING}"
                                               Description="{local:Loc HelpButtons.IDS_PropPlacement_Mode}"
                                               Visibility="{Binding IsEditingCheckpoints, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" />
            </local:ControllerButtonPanel>
        </ContentControl>
    </Grid>
</Page>
