<Page DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Style="{StaticResource A_Style_Page_Generic}"
      mc:Ignorable="d"
      x:Class="ForzaUI.Scenes.Anthem.A_MountainMap"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

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

    <Page.Resources>
        <Style x:Key="A_Style_FZRun_MapFestivalInstruction_STARS"
               TargetType="local:FZRun">
            <Setter Property="Color"
                Value="#FFFEFF49" />
        </Style>

        <Color x:Key="A_Color_Map_EventsSelectedValue">#FF00FFC6</Color>

        <local:UIStoryboard x:Key="A_Storyboard_HighlightFestivalObjective" RepeatBehavior="Forever" DurationOverride="0:0:2" BeginTime="0:0:4">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="{x:Null}">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="0"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:1.0" Value="1.0"/>
                <DiscreteDoubleKeyFrame KeyTime="0:0:3.0" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
            <SingleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(FadeInStart)" Storyboard.TargetName="{x:Null}">
                <EasingSingleKeyFrame KeyTime="0:0:1.0" Value="-0.46" EasingFunction="{StaticResource A_ExponentialEase_InOut}"/>
                <EasingSingleKeyFrame KeyTime="0:0:2.4" Value="1" EasingFunction="{StaticResource A_ExponentialEase_InOut}"/>
            </SingleAnimationUsingKeyFrames>
            <SingleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(FadeInEnd)" Storyboard.TargetName="{x:Null}">
                <EasingSingleKeyFrame KeyTime="0:0:1.0" Value="-0.35" EasingFunction="{StaticResource A_ExponentialEase_InOut}"/>
                <EasingSingleKeyFrame KeyTime="0:0:2.4" Value="1.11" EasingFunction="{StaticResource A_ExponentialEase_InOut}"/>
            </SingleAnimationUsingKeyFrames>
            <SingleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(FadeOutStart)" Storyboard.TargetName="{x:Null}">
                <EasingSingleKeyFrame KeyTime="0:0:1.0" Value="-0.21" EasingFunction="{StaticResource A_ExponentialEase_InOut}"/>
                <EasingSingleKeyFrame KeyTime="0:0:2.4" Value="1.25" EasingFunction="{StaticResource A_ExponentialEase_InOut}"/>
            </SingleAnimationUsingKeyFrames>
            <SingleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Effect).(FadeOutEnd)" Storyboard.TargetName="{x:Null}">
                <EasingSingleKeyFrame KeyTime="0:0:1.0" Value="-0.1" EasingFunction="{StaticResource A_ExponentialEase_InOut}"/>
                <EasingSingleKeyFrame KeyTime="0:0:2.4" Value="1.36" EasingFunction="{StaticResource A_ExponentialEase_InOut}"/>
            </SingleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <Style x:Key="A_Style_FZMaterial_PlayObjectiveHighlightAnimation">
            <Style.Triggers>
                <DataTrigger Binding="{Binding ShowObjectiveHighlight, FallbackValue=False}" Value="True">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource A_Storyboard_HighlightFestivalObjective}" />
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Page.Resources>

    <Grid>
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />
        <Grid Style="{StaticResource A_Style_FrameworkElement_SnapTransition_0}">
        <local:RoutedEventCommand x:Name="MouseUpRoutedEventCommand" RoutedEvent="Mouse.MouseUp"
                                  Command="{Binding OnMouseUp}" />
        <local:RoutedEventCommand x:Name="MouseLeftButtonDownRoutedEventCommand" RoutedEvent="UIElement.MouseLeftButtonDown"
                                  Command="{Binding OnLeftMouseDown}" />
        <local:FZMaterial x:Name="MouseClickHelperMaterial" GreedyMeasure="True"
                            local:RoutedEventCommand.Action="{Binding ElementName=MouseUpRoutedEventCommand}"
                            local:RoutedEventCommand.Action2="{Binding ElementName=MouseLeftButtonDownRoutedEventCommand}" />

        <Canvas DataContext="{Binding MapView, ElementName=mapCustomRenderElement}"                
                x:Name="LayoutRoot">
            <local:MapCustomRenderElement MapId="default"
                                          MapProfile="Mountain"
                                          Roll="{StaticResource A_Double_MountainMapRotation}"
                                          Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Page}}"
                                          Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Page}}"
                                          x:Name="mapCustomRenderElement">
                <local:MapCustomRenderElement.MapView>
                    <local:MapViewControllerInteractive
                                                        MinMapDistance="600"
                                                        MaxMapDistance="1100"
                                                        MinCursorSpeed="1000"
                                                        MaxCursorSpeed="2000"
                                                        MinCursorZoom="0"
                                                        MaxCursorZoom="1"
                                                        ZoomSpeed="3.0"
                                                        MouseZoomSpeed="15.0"
                                                        InputAccelerationStart="1"
                                                        InputAccelerationTime="1"
                                                        InputLinearity="2"
                                                        MapInteriaSpring="100"
                                                        MapInteriaDamping="20"
                                                        MapZoomInteriaSpring="300"
                                                        MapZoomInteriaDamping="40"
                                                        MapDeadArea=".4"
                                                        CursorDistance="200"
                                                        CursorScaleFactor="0.75" />
                </local:MapCustomRenderElement.MapView>
            </local:MapCustomRenderElement>
            <local:FZMaterialGlassCapture />
        </Canvas>
        <!-- Bars -->
        <local:PlayerBarControl Style="{StaticResource A_Style_PlayerBarControl_Map}"
                        x:Name="TopBar" />
        <!-- Festival Progress Info -->
        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}"
              VerticalAlignment="Top">
            <Decorator Margin="{StaticResource A_Thickness_Margin_PlayerBar}">
                <Grid>
                    <Grid Visibility="{Binding FestivalObjectiveCurrencyText, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}"
                            Margin="0,52,0,0"
                            Height="{StaticResource A_Double_Size_PlayerBar}"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Top">
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_AcrylicPanel_BodyPanel}">
                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_PlayerBarBold}"
                                            Margin="{StaticResource A_Margin_PlayerBarText}"
                                           local:TextBlockInlineMarkup.Markup="{Binding FestivalObjectiveCurrencyText}" 
                                            local:TextBlockInlineMarkup.ResourceBaseName="A_Style_FZRun_MapFestivalInstruction_"/>
                        </local:FZMaterial>
                        <local:FZMaterial x:Name="FestivalObjectiveHighlight"
                                          Style="{StaticResource A_Style_FZMaterial_PlayObjectiveHighlightAnimation}"
                                          Opacity="0"
                                          Preset="{StaticResource A_FZMaterialPresetAdditive}">
                            <local:FZMaterial.Effect>
                                <local:TextureMaskEffect Texture="{StaticResource A_Brush_PostRace_Silhouette}"
                                             Mask="{StaticResource A_Brush_PostRace_MaskGradient}"/>
                            </local:FZMaterial.Effect>
                        </local:FZMaterial>
                    </Grid>
                    <StackPanel VerticalAlignment="Top"
                                HorizontalAlignment="Left"
                                Orientation="Horizontal"
                                Height="40"
                                Visibility="{Binding InstructionText, Converter={StaticResource A_StringVisConverter}, FallbackValue={x:Static Visibility.Collapsed}}">
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_AcrylicPanel_Tile_BackgroundSmall}"
                                            ImageSource="/ForzaUI;component/Textures/Anthem/HUD/InfoIconSmall.png"
                                            Width="{StaticResource A_Double_Size_PlayerBar}"/>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_AcrylicPanel_BodyPanel}">
                            <local:FZTextBlock Text="{Binding InstructionText}"
                                                Style="{StaticResource A_Style_FZTextBlock_PlayerBarBold}"
                                                VerticalAlignment="Center"
                                                Margin="15,0"/>
                        </local:FZMaterial>
                    </StackPanel>

                </Grid>
            </Decorator>
            <Decorator Margin="{StaticResource A_Thickness_Margin_ButtonBar}">
                <StackPanel Orientation="Horizontal"
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Right"
                            Visibility="{Binding NumEventsSelected, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}">
                    <local:FZTextBlock Text="{local:Loc Map.IDS_CampaignRouteSelect_EventsSelected}"
                                       Style="{StaticResource A_Style_FZTextBlock_PlayerBarBold}"
                                       FontSize="52"
                                       VerticalAlignment="Bottom"/>
                    <Decorator Width="12"/>
                    <local:FZTextBlock Text="{Binding NumEventsSelected}"
                                       FontFamily="Horizon_A"
                                       FontSize="80"
                                       Color="{StaticResource A_Color_Map_EventsSelectedValue}" />
                </StackPanel>
            </Decorator>
        </Grid>

        <Canvas DataContext="{Binding MapView, ElementName=mapCustomRenderElement}">
            <Grid>
                <Grid.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform />
                        <SkewTransform />
                        <RotateTransform />
                        <TranslateTransform X="{Binding ActualWidth, ElementName=PinContainer, Converter={StaticResource A_Converter_PinXPosition}}"
                                            Y="{Binding ActualHeight, ElementName=PinContainer, Converter={StaticResource A_Converter_PinYPosition}}" />
                    </TransformGroup>
                </Grid.RenderTransform>

                <Decorator x:Name="PinContainer">
                    <Decorator.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform />
                            <SkewTransform />
                            <RotateTransform />
                            <TranslateTransform X="{Binding MapView.CursorX, ElementName=mapCustomRenderElement}"
                                                Y="{Binding MapView.CursorY, ElementName=mapCustomRenderElement}" />
                        </TransformGroup>
                    </Decorator.RenderTransform>

                    <Decorator Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}"
                               Height="Auto"
                               Width="Auto"
                               HorizontalAlignment="Stretch"
                               VerticalAlignment="Stretch">
                        <ContentControl Content="{Binding SnapContext, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}}"
                                        Style="{StaticResource A_Style_ContentControl_MapPin}"
                                        x:Name="Pin" />
                    </Decorator>
                </Decorator>
            </Grid>
        </Canvas>

        <local:RoutedEventCommand x:Name="MapZoomInRoutedEventCommand"
                                  RoutedEvent="UIElement.MouseLeftButtonDown"
                                  Command="{Binding MapZoomInCommand}" />
        <local:RoutedEventCommand x:Name="MapZoomOutRoutedEventCommand"
                                  RoutedEvent="UIElement.MouseLeftButtonDown"
                                  Command="{Binding MapZoomOutCommand}" />
        <local:RoutedEventCommand x:Name="UpMapZoomStopRoutedEventCommand"
                                  RoutedEvent="UIElement.MouseLeftButtonUp"
                                  Command="{Binding MapStopZoomCommand}" />
        <local:RoutedEventCommand x:Name="LeaveMapZoomStopRoutedEventCommand"
                                  RoutedEvent="UIElement.MouseLeave"
                                  Command="{Binding MapStopZoomCommand}" />

        <local:RoutedEventCommand x:Name="ButtonBarDisableMouseCursorMovement"
                                  RoutedEvent="UIElement.MouseEnter"
                                  Command="{Binding DisableMouseCursorMovement}" />
        <local:RoutedEventCommand x:Name="ButtonBarEnableMouseCursorMovement"
                                  RoutedEvent="UIElement.MouseLeave"
                                  Command="{Binding EnableMouseCursorMovement}" />

        <Grid x:Name="ExtraBottomBarBackground" Height="500" Margin="-250,0,-250,-250" VerticalAlignment="Bottom">
            <local:FZMaterial Color="Black"
                              Opacity="0.25"
                              Preset="{StaticResource A_FZMaterialPresetRoundtangle_Vignette}"
                              IsHitTestVisible="False" />
        </Grid>
        
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        x:Name="BottomBar">
            <local:FZMaterial x:Name="MouseButtonBarHitHelper"
                                  Height="30"
                                  Width="Auto"
                                  local:RoutedEventCommand.Action="{Binding ElementName=ButtonBarDisableMouseCursorMovement}"
                                  local:RoutedEventCommand.Action2="{Binding ElementName=ButtonBarEnableMouseCursorMovement}"
                                  Color="#00000000">
                <local:ControllerButtonPanel x:Name="HelpPanel"
                                             Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                    <local:ControllerButtonControl Button="A"
                                                       Description="{local:Loc HelpButtons.IDS_Select}"
                                                       AllowMouseClick="False" />
                    <local:ControllerButtonControl Button="B"
                                                       Description="{local:Loc HelpButtons.IDS_Resume}" />
                    <local:ControllerButtonControl Button="X"
                                                       Style="{StaticResource A_Style_ControllerButtonControl_MapXButton}" />
                    <local:ControllerButtonControl Button="Y" />
                    <local:ControllerButtonControl Button="LBumper" />
                    <local:ControllerButtonControl Button="RThumb" />
                    <local:ControllerButtonControl SupportsControllerInput="False"
                                                       InputOverride="{local:Input Command=INPUTCMD_UI_RIGHT_Y_AXIS, Context=INPUTCONTEXT_UI}"
                                                       Visibility="{Binding ShowMouseZoomButtons, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                                       UseHighKeyIfLinearCommand="True"
                                                       Description="{local:Loc HelpButtons.IDS_MapZoomIn}"
                                                       local:RoutedEventCommand.Action="{Binding ElementName=MapZoomInRoutedEventCommand}"
                                                       local:RoutedEventCommand.Action2="{Binding ElementName=UpMapZoomStopRoutedEventCommand}"
                                                       local:RoutedEventCommand.Action3="{Binding ElementName=LeaveMapZoomStopRoutedEventCommand}" />
                    <local:ControllerButtonControl SupportsControllerInput="False"
                                                       InputOverride="{local:Input Command=INPUTCMD_UI_RIGHT_Y_AXIS, Context=INPUTCONTEXT_UI}"
                                                       Visibility="{Binding ShowMouseZoomButtons, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                                       UseHighKeyIfLinearCommand="False"
                                                       Description="{local:Loc HelpButtons.IDS_MapZoomOut}"
                                                       local:RoutedEventCommand.Action="{Binding ElementName=MapZoomOutRoutedEventCommand}"
                                                       local:RoutedEventCommand.Action2="{Binding ElementName=UpMapZoomStopRoutedEventCommand}"
                                                       local:RoutedEventCommand.Action3="{Binding ElementName=LeaveMapZoomStopRoutedEventCommand}" />
                </local:ControllerButtonPanel>
            </local:FZMaterial>
        </ContentControl>
        </Grid>
    </Grid>
</Page>
