<Page DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Style="{StaticResource A_Style_Page_Generic}"
      mc:Ignorable="d"
      x:Class="ForzaUI.Scenes.Anthem.A_Map"
      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>
        <local:UIStoryboard x:Key="A_Storyboard_MapPinOpacity_BlendValueInputChanged">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="{x:Null}"
                                           FillBehavior="HoldEnd"
                                           Storyboard.TargetProperty="(local:BlendValue.Blend)">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                      Value="1">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <QuarticEase EasingMode="EaseOut" />
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <local:UIStoryboard x:Key="A_Storyboard_FadeInObjective">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="{x:Null}"
                                           FillBehavior="HoldEnd"
                                           Storyboard.TargetProperty="(Opacity)">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:1.0"
                                      Value="1">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <QuarticEase EasingMode="EaseOut" />
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <local:UIStoryboard x:Key="A_Storyboard_FadeInInstruction">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="{x:Null}"
                                           FillBehavior="HoldEnd"
                                           Storyboard.TargetProperty="(Opacity)">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="0" />
                <EasingDoubleKeyFrame KeyTime="0:0:1.0"
                                      Value="1">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <QuarticEase EasingMode="EaseOut" />
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <local:UIStoryboard x:Key="A_Storyboard_FadeOutObjective">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="{x:Null}"
                                           FillBehavior="HoldEnd"
                                           Storyboard.TargetProperty="(Opacity)">
                <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                        Value="1" />
                <EasingDoubleKeyFrame KeyTime="0:0:1.0"
                                      Value="0">
                    <EasingDoubleKeyFrame.EasingFunction>
                        <QuarticEase EasingMode="EaseOut" />
                    </EasingDoubleKeyFrame.EasingFunction>
                </EasingDoubleKeyFrame>
            </DoubleAnimationUsingKeyFrames>
        </local:UIStoryboard>

        <Style x:Key="A_Style_PinContainer"
               TargetType="FrameworkElement">
            <Setter Property="RenderTransform">
                <Setter.Value>
                    <TranslateTransform X="{Binding PinPosX, RelativeSource={RelativeSource AncestorType=Page}}"
                                        Y="{Binding PinPosY, RelativeSource={RelativeSource AncestorType=Page}}" />
                </Setter.Value>
            </Setter>
            <Setter Property="local:BlendValue.InputChangedStoryboard" Value="{StaticResource A_Storyboard_MapPinOpacity_BlendValueInputChanged}" />
            <Setter Property="local:BlendValue.Input" Value="{Binding CanShowPin, RelativeSource={RelativeSource AncestorType=Page}}" />
            <Setter Property="local:BlendValue.BlendFromPreviousOutput" Value="True" />
            <Setter Property="local:BlendValue.ShouldSkipInitialInputChange" Value="False" />
            <Setter Property="Opacity" Value="{Binding (local:BlendValue.Output), RelativeSource={RelativeSource Self}}" />
            <Setter Property="Visibility" Value="{Binding CanShowPin, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}" />
        </Style>
        <Style x:Key="A_Style_FZRun_MapFestivalInstruction_HIGHLIGHT"
               TargetType="local:FZRun">
            <Setter Property="Color"
                Value="#FFFFF539" />
        </Style>

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

        <local:MappingConverter x:Key="A_Converter_ActivityPanelStatusToMapDimmer"
                                Default="0">
            <local:MappingConverterEntry Key="True" Value="0.5"/>
        </local:MappingConverter>

        <Style x:Key="A_Style_ControllerButtonControl_MapLBButton"            
               BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}"
               TargetType="local:ControllerButtonControl">
            <Setter Property="Description" Value="{local:Loc HelpButtons.IDS_ActivityPanelToggle}" />
            <Setter Property="Visibility" Value="{Binding ActivityPanel.IsEnabled, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding LockToActivationPanel}" Value="True">
                    <Setter Property="Visibility" Value="Collapsed" />
                </DataTrigger>
                <DataTrigger Binding="{Binding ActivityPanel}" Value="{x:Null}">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding IsUIFlowMapContext}"
                         Value="True">
                    <Setter Property="Visibility"
                        Value="{x:Static Visibility.Collapsed}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding CanHandleInput}"
                         Value="False">
                    <Setter Property="Visibility"
                        Value="{x:Static Visibility.Collapsed}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_ControllerButtonControl_MapBackButton" BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}" TargetType="local:ControllerButtonControl">
            <Setter Property="Description" Value="{local:Loc HelpButtons.IDS_Resume}" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding SceneEnum}" Value="{x:Static local:SceneEntryEnum.CampaignRouteSelect}">
                    <Setter Property="Visibility" Value="Collapsed" />
                </DataTrigger>
                <DataTrigger Binding="{Binding EliminatorPhase, FallbackValue=0}" Value="{x:Static local:EliminatorPhase.PreGame}">
                    <Setter Property="Visibility" Value="Collapsed" />
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style TargetType="local:FZMaterial" x:Key="A_Style_FZMaterial_EliminatorTimer">
            <Style.Resources>
                <local:MappingConverter x:Key="A_MappingConverter_Phase_To_Timer_Visiblity" Default="Collapsed">
                    <local:MappingConverterEntry Key="{x:Static local:EliminatorPhase.PreGame}" Value="Visible"/>
                </local:MappingConverter>
            </Style.Resources>
            <Setter Property="Width" Value="290"/>
            <Setter Property="Height" Value="144"/>
            <Setter Property="Visibility" Value="{Binding EliminatorPhase, Converter={StaticResource A_MappingConverter_Phase_To_Timer_Visiblity}, FallbackValue=Collapsed}"/>
            <Setter Property="ImageSourceNoPreload" Value="/ForzaUI;component/Textures/Data_Bound/Eliminator/Map/ELIM_TimerHousing.png"/>
        </Style>
        <local:LinearTransformConverter x:Key="A_LinearTransformConverter_EliminatorTimer_MaxBarWidth" Scale="220"/>

        <local:MappingConverter x:Key="A_MappingConverter_FlyerFlip_ButtonText" Default="{x:Null}">
            <local:MappingConverterEntry Key="true" Value="{local:Loc HelpButtons.IDS_ViewEventFlyer}"/>
            <local:MappingConverterEntry Key="false" Value="{local:Loc HelpButtons.IDS_ViewEventInformation}"/>
        </local:MappingConverter>

        <local:MappingConverter x:Key="A_MappingConverter_MapStartButtonDescription"
                                Default="{local:Loc HelpButtons.IDS_MyHorizonLife}">
            <local:MappingConverterEntry Key="{x:Static XAMLTrack.ExpansionTwo}" Value="{local:Loc HelpButtons.IDS_BrickChallenges}"/>
        </local:MappingConverter>
        
        <Style x:Key="A_Style_ControllerButtonControl_MapStartButton" BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}" TargetType="local:ControllerButtonControl">
            <Setter Property="Description" Value="{Binding ActiveTrack, Converter={StaticResource A_MappingConverter_MapStartButtonDescription}}" />
            <Setter Property="Visibility" Value="{Binding ActivityPanel.IsActive, FallbackValue=Collapsed, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsCampaignScreenLocked}" Value="True">
                    <Setter Property="Visibility" Value="{x:Static Visibility.Collapsed}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding SceneEnum}" Value="{x:Static local:SceneEntryEnum.CampaignRouteSelect}">
                    <Setter Property="Description" Value="{local:Loc HelpButtons.IDS_Resume}" />
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding CanHandleMapInput}"
                         Value="False">
                    <Setter Property="Visibility"
                        Value="{x:Static Visibility.Collapsed}" />
                </DataTrigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding ActivityPanel.IsActive}" Value="True" />
                        <Condition Binding="{Binding ActivityPanel.CanFlyerFlip}" Value="True"/>
                    </MultiDataTrigger.Conditions>
                    <MultiDataTrigger.Setters>
                        <Setter Property="Description" Value="{Binding ActivityPanel.SelectedItem.CampaignSetupItem.IsFlyerFlipped, Converter={StaticResource A_MappingConverter_FlyerFlip_ButtonText}}"/>
                        <Setter Property="Visibility" Value="Visible"/>
                    </MultiDataTrigger.Setters>
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_LayoutRoot_Map" TargetType="FrameworkElement" BasedOn="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <Setter Property="Visibility" Value="{Binding ActivityPanel.IsEnabled, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding ActivityPanel}" Value="{x:Null}">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="A_Style_ActivityPanel_Visibility_Toggle" TargetType="FrameworkElement">
            <Setter Property="Visibility" Value="{Binding ActivityPanel.IsEnabled, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding ActivityPanel}" Value="{x:Null}">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_FZMaterial_ObjectiveBacking"
           TargetType="{x:Type local:FZMaterial}">
            <Setter Property="Color" Value="{StaticResource A_Color_CurrencyValueContainer_Dark}"/>
            <Setter Property="Height" Value="{StaticResource A_Double_Size_PlayerBar}" />
            <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll}" />
            <Setter Property="Opacity" Value="0"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding EnableFadeEffects}" Value="False">
                    <Setter Property="Opacity" Value="1"/>
                </DataTrigger>
                
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding EnableFadeEffects}" Value="True"/>
                        <Condition Binding="{Binding FadeObjectiveIn}" Value="True"/>
                    </MultiDataTrigger.Conditions>
                    <MultiDataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource A_Storyboard_FadeInObjective}"/>
                    </MultiDataTrigger.EnterActions>
                    <MultiDataTrigger.ExitActions>
                        <BeginStoryboard Storyboard="{StaticResource A_Storyboard_FadeOutObjective}"/>
                    </MultiDataTrigger.ExitActions>
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_FZMaterial_InstructionBacking" TargetType="{x:Type local:FZMaterial}">
            <Setter Property="Margin" Value="50,40,0,0"/>
            <Setter Property="Color" Value="{StaticResource A_Color_ButtonBar_Background}"/>
            <Setter Property="Height" Value="{StaticResource A_Double_Size_PlayerBar}" />
            <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll}" />
            <Style.Triggers>
                <!--Moves towards edge if activity panel is not there -->
                <DataTrigger Binding="{Binding ActivityPanel}" Value="{x:Null}">
                    <Setter Property="Margin" Value="-2,0,0,0"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding ActivityPanel.IsEnabled}" Value="False">
                    <Setter Property="Margin" Value="-2,0,0,0"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding Visibility, RelativeSource={RelativeSource Self}}" Value="{x:Static Visibility.Visible}">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource A_Storyboard_FadeInInstruction}"/>
                    </DataTrigger.EnterActions>
                </DataTrigger>

                <DataTrigger Binding="{Binding SceneEnum}" Value="{x:Static local:SceneEntryEnum.MapEliminator}">
                    <Setter Property="Color" Value="{StaticResource A_Color_HUD_Glass_Eliminator}"/>
                    <Setter Property="Height" Value="35"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_FZMaterial_EventCounter" TargetType="local:FZMaterial" BasedOn="{StaticResource A_Style_FZMaterial_GlassPanel_Pill}">
            <Setter Property="Visibility" Value="Hidden"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding NumEventsSelected, Converter={StaticResource A_CompareConverter}, ConverterParameter=-1}" Value="1">
                    <Setter Property="Visibility" Value="Visible"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_FZMaterial_InfoPromptIcon" TargetType="local:FZMaterial">
            <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/InfoIconSmall.png"/>
            <Setter Property="Margin" Value="5,0,10,0"/>
            <Setter Property="Width" Value="32"/>
            <Setter Property="Height" Value="32"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding SceneEnum}" Value="{x:Static local:SceneEntryEnum.MapEliminator}">
                    <Setter Property="Margin" Value="-14,-8,6,-8"/>
                    <Setter Property="Width" Value="48"/>
                    <Setter Property="Height" Value="48"/>
                    <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/Eliminator/Map/ELIM_InfoPromptIcon.png"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>


        <!-- Copied from shared_bars.xaml to add a viewbox for languages with really long strings on the button bar -->
        <ControlTemplate x:Key="A_ControlTemplate_ButtonBar_Map" TargetType="ContentControl">
            <Grid RenderTransformOrigin="0.5,1.0"
                  VerticalAlignment="Bottom"
                  Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
                <Viewbox StretchDirection="DownOnly"
                         VerticalAlignment="Bottom"
                         HorizontalAlignment="Left"
                         Margin="{StaticResource A_Thickness_Margin_ButtonBar}">
                    <Grid VerticalAlignment="Bottom"
                          HorizontalAlignment="Left">
                        <local:FZMaterial x:Name="ControllerStyleBackground"
                                          Style="{StaticResource A_Style_ControllerButton_Background}"
                                          Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_ConsoleButtonBarBackground_All}">
                            <ContentPresenter x:Name="ControllerButtonPanel"
                                              Margin="4,0,0,0"
                                              VerticalAlignment="Center" />
                        </local:FZMaterial>
                    </Grid>
                </Viewbox>
            </Grid>
            <ControlTemplate.Triggers>
                <DataTrigger Binding="{Binding IsControllerActiveInput, RelativeSource={RelativeSource AncestorType=Page}}"
                             Value="False">
                    <Setter TargetName="ControllerStyleBackground"
                            Property="Color"
                            Value="#00000000" />
                    <Setter TargetName="ControllerButtonPanel"
                            Property="Margin"
                            Value="0" />
                </DataTrigger>
                <DataTrigger Binding="{Binding ActualWidth, ElementName=ControllerButtonPanel}"
                             Value="0">
                    <Setter TargetName="ControllerButtonPanel"
                            Property="Margin"
                            Value="0" />
                </DataTrigger>
                <EventTrigger RoutedEvent="ControllerButtonPanel.ShowControllerButtonPanel">
                    <local:BeginUIStoryboard Storyboard="{StaticResource ShowControllerButtonPanel}"/>
                </EventTrigger>
                <EventTrigger RoutedEvent="ControllerButtonPanel.ShowControllerButtonPanelInstant">
                    <local:BeginUIStoryboard Storyboard="{StaticResource ShowControllerButtonPanelInstant}"/>
                </EventTrigger>
                <EventTrigger RoutedEvent="ControllerButtonPanel.HideControllerButtonPanel">
                    <local:BeginUIStoryboard Storyboard="{StaticResource HideControllerButtonPanel}"/>
                </EventTrigger>
                <EventTrigger RoutedEvent="ControllerButtonPanel.HideControllerButtonPanelInstant">
                    <local:BeginUIStoryboard Storyboard="{StaticResource HideControllerButtonPanelInstant}"/>
                </EventTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <Style x:Key="A_Style_MapViewControllerInteractive_DefaultController"
               TargetType="{x:Type local:MapViewControllerInteractive}">
            <Setter Property="MinMapDistance" Value="{local:TrackProperty MapMinDistance}" />
            <Setter Property="MaxMapDistance" Value="{local:TrackProperty MapMaxDistance}" />
            <Setter Property="MinCursorSpeed" Value="1000" />
            <Setter Property="MaxCursorSpeed" Value="4000" />
            <Setter Property="MinCursorZoom" Value="0" />
            <Setter Property="MaxCursorZoom" Value="1" />
            <Setter Property="ZoomSpeed" Value="3.0" />
            <Setter Property="MouseZoomSpeed" Value="15.0" />
            <Setter Property="InputAccelerationStart" Value="1" />
            <Setter Property="InputAccelerationTime" Value="1" />
            <Setter Property="InputLinearity" Value="2" />
            <Setter Property="MapInteriaSpring" Value="100" />
            <Setter Property="MapInteriaDamping" Value="20" />
            <Setter Property="MapZoomInteriaSpring" Value="300" />
            <Setter Property="MapZoomInteriaDamping" Value="40" />
            <Setter Property="MapDeadArea" Value=".4" />
            <Setter Property="CursorDistance" Value="200" />
            <Setter Property="CursorScaleFactor" Value="0.75" />
            <Setter Property="MapId" Value="{Binding MapId, ElementName=PART_MapCustomRenderElement}" />
        </Style>

        <Style x:Key="A_Style_MapViewControllerInteractive_ExpansionOne"
               BasedOn="{StaticResource A_Style_MapViewControllerInteractive_DefaultController}"
               TargetType="{x:Type local:MapViewControllerInteractive}">
            <Setter Property="MaxCursorSpeed" Value="2000" />
        </Style>

        <Style x:Key="A_Style_MapViewControllerInteractive_ExpansionTwo"
               BasedOn="{StaticResource A_Style_MapViewControllerInteractive_DefaultController}"
               TargetType="{x:Type local:MapViewControllerInteractive}">
            <Setter Property="MaxCursorSpeed" Value="1300" />
        </Style>

        <local:MappingConverter x:Key="A_Converter_TrackToMapViewStyle"
                                Default="{StaticResource A_Style_MapViewControllerInteractive_DefaultController}">
            <local:MappingConverterEntry Key="{x:Static local:XAMLTrack.ExpansionOne}" Value="{StaticResource A_Style_MapViewControllerInteractive_ExpansionOne}" />
            <local:MappingConverterEntry Key="{x:Static local:XAMLTrack.ExpansionTwo}" Value="{StaticResource A_Style_MapViewControllerInteractive_ExpansionTwo}" />
        </local:MappingConverter>

        <local:MappingConverter x:Key="A_Converter_VisibleOnDLC2Only"
                                Default="{x:Static Visibility.Collapsed}">
            <local:MappingConverterEntry Key="{x:Static local:XAMLTrack.ExpansionTwo}" Value="{x:Static Visibility.Visible}" />
        </local:MappingConverter>

        <local:MappingConverter x:Key="A_Converter_CollapsedOnDLC2Only"
                                Default="{x:Static Visibility.Visible}">
            <local:MappingConverterEntry Key="{x:Static local:XAMLTrack.ExpansionTwo}" Value="{x:Static Visibility.Collapsed}" />
        </local:MappingConverter>

        <local:FZMaterialPresetRoundtangleStroke x:Key="A_FZMaterialPresetRoundtangleStroke_DLC2Border_Outer"
                                                 BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                                                 CornerRadius="16,16,16,16"
                                                 Thickness="8" />
        <local:FZMaterialPresetRoundtangleStroke x:Key="A_FZMaterialPresetRoundtangleStroke_DLC2Border_Inner"
                                                 BasedOn="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll}"
                                                 CornerRadius="10,10,10,10"
                                                 Thickness="4" />

    </Page.Resources>

    <Grid>
        <local:FZMaterial Color="#FF000000" />
        <local:RoutedEventCommand x:Name="MouseUpRoutedEventCommand" RoutedEvent="Mouse.MouseUp"
                                  Command="{Binding OnMouseUp}" />
        <local:RoutedEventCommand x:Name="MouseLeftButtonDownRoutedEventCommand" RoutedEvent="UIElement.MouseLeftButtonDown"
                                  Command="{Binding OnLeftMouseDown}" />

        <local:MapViewControllerInteractive x:Name="PART_ViewController"
                                            Style="{Binding ActiveTrack, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_Converter_TrackToMapViewStyle}}" />

        <Canvas x:Name="LayoutRoot">
            <local:MapCustomRenderElement MapId="default"
                                          MapProfile="{Binding MapProfile, RelativeSource={RelativeSource AncestorType=Page}}"
                                          Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Page}}"
                                          Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Page}}"
                                          MapView="{Binding ElementName=PART_ViewController}"
                                          x:Name="PART_MapCustomRenderElement" />
            <local:FZMaterialGlassCapture />
        </Canvas>
        <local:RoutedEventCommand x:Name="ButtonBarDisableMouseCursorMovement"
                                  RoutedEvent="UIElement.MouseEnter"
                                  Command="{Binding DisableMouseCursorMovement}" />
        <local:RoutedEventCommand x:Name="ButtonBarEnableMouseCursorMovement"
                                  RoutedEvent="UIElement.MouseLeave"
                                  Command="{Binding EnableMouseCursorMovement}" />
        <!-- 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>
                    <Decorator Visibility="{Binding ActiveTrack, Converter={StaticResource A_Converter_CollapsedOnDLC2Only}}"
                               Margin="0,52,6,0"
                               HorizontalAlignment="Right"
                               VerticalAlignment="Top">
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_ObjectiveBacking}"
                                          Visibility="{Binding ObjectiveText, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}">
                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_PlayerBarBold}"
                                               Margin="{StaticResource A_Margin_PlayerBarText}"
                                               local:TextBlockInlineMarkup.Markup="{Binding ObjectiveText}" 
                                               local:TextBlockInlineMarkup.ResourceBaseName="A_Style_FZRun_MapFestivalInstruction_"
                                               Effect="{StaticResource A_DropShadowEffect_HelpBar}"/>
                        </local:FZMaterial>
                    </Decorator>
                    <Control Style="{StaticResource A_Style_Control_BrickChallengeObjective}"
                             Margin="0,52,6,0"
                             HorizontalAlignment="Right"
                             VerticalAlignment="Top"
                             Visibility="{Binding ActiveTrack, Converter={StaticResource A_Converter_VisibleOnDLC2Only}}" />
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_InstructionBacking}"
                                      Visibility="{Binding InstructionText, Converter={StaticResource A_StringVisConverter}, FallbackValue={x:Static Visibility.Collapsed}}"
                                      HorizontalAlignment="Left"
                                      VerticalAlignment="Top">
                        <StackPanel Orientation="Horizontal">
                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_InfoPromptIcon}"/>
                            <local:FZTextBlock Text="{Binding InstructionText}"
                                               Style="{StaticResource A_Style_FZTextBlock_PlayerBarBold}"
                                               VerticalAlignment="Center"
                                               Margin="0,0,10,0"/>
                        </StackPanel>
                    </local:FZMaterial>
                </Grid>
            </Decorator>
            <Viewbox Margin="{StaticResource A_Thickness_Margin_ButtonBar}"
                StretchDirection="DownOnly"
                MaxWidth="375"
                VerticalAlignment="Bottom"
                HorizontalAlignment="Right">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_EventCounter}">
                    <StackPanel Orientation="Horizontal">
                        <local:FZTextBlock Text="{local:Loc Map.IDS_CampaignRouteSelect_EventsSelected}"
                                       Color="{StaticResource A_Color_White}" Margin="12"
                                       CapHeight="24" FontFamily="Horizon_B"
                                       VerticalAlignment="Center"/>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FlatPanel_TileRight}" Color="{StaticResource A_Color_Map_EventsSelectedBackground}">
                            <local:FZTextBlock Text="{Binding NumEventsSelected}" Margin="12"
                                       FontFamily="Horizon_A" VerticalAlignment="Center"
                                       CapHeight="24"
                                       Color="{StaticResource A_Color_Map_EventsSelectedValue}" />
                        </local:FZMaterial>
                    </StackPanel>
                </local:FZMaterial>
            </Viewbox>
            <Grid x:Name="EliminatorTimer" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="78,40,78,64">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_EliminatorTimer}">
                    <Decorator Margin="0,0,0,14" VerticalAlignment="Bottom" HorizontalAlignment="Center">
                        <DockPanel>
                            <local:FZMaterial DockPanel.Dock="Left" Style="{StaticResource A_Style_FZMaterial_FlatPanel_LeftHeaderPanel}" Color="{StaticResource A_Color_InfluenceThread_eliminator}">
                                <local:FZMaterial Width="40" Height="40" ImageSource="/ForzaUI;component/Textures/Data_Bound/Eliminator/Map/ELIM_TimerIcon.png"/>
                            </local:FZMaterial>
                            <Grid>
                                <local:FZMaterial CaptureSubgraph="True" Style="{StaticResource A_Style_FZMaterial_FlatPanel_TileRight}">
                                    <Grid>
                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FlatPanel_Base}" Color="{StaticResource A_Color_HUD_Glass_Eliminator}" Width="220">
                                        </local:FZMaterial>
                                        <local:FZMaterial Width="{Binding TimeRemainingRatio, Converter={StaticResource A_LinearTransformConverter_EliminatorTimer_MaxBarWidth}, FallbackValue=0}"
                                                  Style="{StaticResource A_Style_FZMaterial_FlatPanel_Base}" Color="#AD2476" HorizontalAlignment="Left"/>
                                    </Grid>
                                </local:FZMaterial>
                                <Decorator Margin="12" HorizontalAlignment="Right">
                                    <local:FZTextBlock Text="{Binding TimeRemaining}"
                                                       Style="{StaticResource A_Style_FZTextBlock_Heading_Large}"
                                                       CapHeight="16"
                                                       MinWidth="34"
                                                       VerticalAlignment="Center" HorizontalAlignment="Right"
                                                       Color="{StaticResource A_Color_White}" />
                                </Decorator>
                            </Grid>
                        </DockPanel>
                    </Decorator>
                </local:FZMaterial>
            </Grid>
            <!-- Debug Only -->
            <local:FZMaterial Color="#80000000"
                              Visibility="{Binding SelectionFilters, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}"
                              VerticalAlignment="Center"
                              HorizontalAlignment="Right">
                <local:FZTextBlock Text="{Binding SelectionFilters}"
                                   FontSize="24"
                                   Color="#FFFFFFFF"
                                   FontFamily="Horizon_B"
                                   Margin="20" />
            </local:FZMaterial>
        </Grid>

        <Canvas DataContext="{Binding MapView, ElementName=PART_MapCustomRenderElement}">
            <Grid x:Name="PinContainer"
                  Style="{StaticResource A_Style_PinContainer}">
                <ContentControl Content="{Binding SnapContext, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}}"
                                Style="{StaticResource A_Style_ContentControl_MapPin}"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                IsHitTestVisible="False"
                                local:AttachedRoutedEventCommand.Command="{Binding OnPinSizeChangedCommand, RelativeSource={RelativeSource AncestorType=Page}}"
                                local:AttachedRoutedEventCommand.RoutedEvent="FrameworkElement.SizeChanged"
                                x:Name="Pin">
                    <ContentControl.Template>
                        <ControlTemplate TargetType="ContentControl">
                            <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}"
                                       Height="Auto"
                                       Width="Auto"
                                       HorizontalAlignment="Stretch"
                                       VerticalAlignment="Stretch">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_MapFloatingPanelShadow}"
                                                  Opacity="0.5"
                                                  Margin="-35" />
                                <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangleStroke_DLC2Border_Outer}"
                                                  Color="#FFFFFF"
                                                  Visibility="{Binding ActiveTrack, Converter={StaticResource A_Converter_VisibleOnDLC2Only}, RelativeSource={RelativeSource AncestorType=Page}}"
                                                  Margin="-9" />
                                <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangleStroke_DLC2Border_Inner}"
                                                  Color="#000000"
                                                  Visibility="{Binding ActiveTrack, Converter={StaticResource A_Converter_VisibleOnDLC2Only}, RelativeSource={RelativeSource AncestorType=Page}}"
                                                  Margin="-3" />
                                <ContentPresenter />
                            </Grid>
                        </ControlTemplate>
                    </ContentControl.Template>
                </ContentControl>
            </Grid>
        </Canvas>

        <local:FZMaterial x:Name="MouseClickHelperMaterial"
                          GreedyMeasure="True"
                          Color="#00FFFFFF"
                          local:RoutedEventCommand.Action="{Binding ElementName=MouseUpRoutedEventCommand}"
                          local:RoutedEventCommand.Action2="{Binding ElementName=MouseLeftButtonDownRoutedEventCommand}" />

        <local:FZMaterial Color="#000000"
                          IsHitTestVisible="False"
                          Style="{StaticResource A_Style_ActivityPanel_Visibility_Toggle}"
                          Opacity="{Binding ActivityPanel.IsActive, Converter={StaticResource A_Converter_ActivityPanelStatusToMapDimmer}}" />

        <Grid Style="{StaticResource A_Style_LayoutRoot_Map}"
              VerticalAlignment="Top">
            <Control Style="{StaticResource A_Style_Control_ActivityPanel}"
                     DataContext="{Binding ActivityPanel}"
                     Margin="52,78,0,0"
                     local:RoutedEventCommand.Action="{Binding ElementName=ButtonBarDisableMouseCursorMovement}"
                     local:RoutedEventCommand.Action2="{Binding ElementName=ButtonBarEnableMouseCursorMovement}" />
        </Grid>
        
        <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}" />
        
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        Template="{StaticResource A_ControlTemplate_ButtonBar_Map}"
                        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"
                                                   Style="{StaticResource A_Style_ControllerButtonControl_MapAButton}" />
                    <local:ControllerButtonControl Button="B"
                                                   Style="{StaticResource A_Style_ControllerButtonControl_MapBackButton}" />
                    <local:ControllerButtonControl Button="X"
                                                   Style="{StaticResource A_Style_ControllerButtonControl_MapXButton}" />
                    <local:ControllerButtonControl Button="Y" />
                    <local:ControllerButtonControl Button="LBumper"
                                                   Style="{StaticResource A_Style_ControllerButtonControl_MapLBButton}" />
                    <local:ControllerButtonControl Button="Start"
                                                   Style="{StaticResource A_Style_ControllerButtonControl_MapStartButton}" />
                    <local:ControllerButtonControl Button="RBumper" />
                    <local:ControllerButtonControl Button="RThumb" />
                </local:ControllerButtonPanel>
            </local:FZMaterial>
        </ContentControl>
    </Grid>
</Page>
