<Page xmlns:local="clr-namespace:ForzaUI"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      x:Class="ForzaUI.A_CampaignSlotMenu"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      local:AttachedTileMenu.TileMenuNavigationManager="{local:TileMenuNavigationManager Width=3, Height=3}"
      Margin="0">
    <Page.Resources>
        <ResourceDictionary>
            <!--Item Template for slotmenu-->
            <ControlTemplate x:Key="A_DataTemplate_ListItem_CampaignSlotMenuItem"
                             TargetType="{x:Type local:FZButton}">
                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}">
                    <local:FZMaterial Style="{StaticResource H_Style_Container_GlassHighBlur_Description}" Height="156" Margin="0,0,0,8"/>
                    <local:FZMaterial x:Name="IconBackground" Color="{StaticResource A_Color_WhitePanel}"
                                      Preset="{StaticResource H_Roundtangle_Outer_3px}" />
                    <local:FZMaterial x:Name="Icon" ImageSource="{Binding Icon}" 
                                      Width="56"
                                      Height="44"
                                      Color="{StaticResource H_Color_Primary_Purple}"
                                      Margin="12,8,12,50"/>
                    <Grid Margin="16,92,16,16" Height="60">
                        <local:FZTextBlock x:Name="SlotText"
                                           Text="{Binding Heading, Converter={StaticResource A_StringToUpper}}"
                                           Color="{StaticResource H_Color_Primary_Purple}"
                                           HorizontalAlignment="Center" VerticalAlignment="Top"
                                           TextWrapping="Wrap"
                                           TextAlignment="Center"
                                           CapHeight="17"/>
                    </Grid>
                    <local:FZMaterial x:Name="PadLock" Width="56" Height="44" Visibility="Collapsed"
                                      ImageSource="/ForzaUI;component/Textures/Anthem/Icons/TiledMenus/SlotMenu/Locked.png"
                                      Color="{StaticResource H_Color_Primary_White}"
                                      Margin="0,-50,0,0"
                                      Opacity="0.6"/>
                    <StrokeHighlightControl Style="{StaticResource A_Style_ContentControl_TileSelectionStroke}" Focusable="False"/>
                </Grid>
                
                <!--Lock state trigger.-->
                <ControlTemplate.Triggers>
                    <DataTrigger Binding="{Binding Command.DeniedCommand, Converter={StaticResource A_Converter_DeniedCommandToLockState}}" Value="{x:Static local:LockState.Locked}">
                        <Setter TargetName="IconBackground" Property="Visibility" Value="Collapsed"/>
                        <Setter TargetName="PadLock" Property="Visibility" Value="Visible"/>
                        <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
                        <Setter TargetName="SlotText" Property="Color" Value="{StaticResource A_Color_White}"/>
                        <Setter TargetName="SlotText" Property="Opacity" Value="0.6"/>
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <!--Item Template for slotmenu-->
            <ControlTemplate x:Key="A_DataTemplate_ListItem_CampaignSlotMenuItem_Eventlab"
                             TargetType="{x:Type local:FZButton}">
                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}">
                    <local:FZMaterial Style="{StaticResource H_Style_Container_GlassHighBlur_Description}" Height="156" Margin="0,0,0,8"/>
                    <local:FZMaterial x:Name="BackgroundTexture" ImageSource="/ForzaUI;component/Textures/Anthem/Icons/TiledMenus/SlotMenu/EventLab_Tile_Large.png"
                                      Preset="{StaticResource H_Roundtangle_Outer_3px}" />
                    <Grid Margin="16,92,16,16" Height="60">
                        <local:FZTextBlock x:Name="SlotText"
                                           Visibility="Collapsed"
                                           Text="{Binding Heading, Converter={StaticResource A_StringToUpper}}"
                                           Color="{StaticResource A_Color_White}"
                                           Opacity="0.6"
                                           HorizontalAlignment="Center" VerticalAlignment="Top"
                                           TextWrapping="Wrap"
                                           TextAlignment="Center"
                                           CapHeight="17"/>
                    </Grid>
                    <local:FZMaterial x:Name="PadLock" Width="56" Height="44" Visibility="Collapsed"
                                      ImageSource="/ForzaUI;component/Textures/Anthem/Icons/TiledMenus/SlotMenu/Locked.png"
                                      Color="{StaticResource H_Color_Primary_White}"
                                      Margin="0,-50,0,0"
                                      Opacity="0.6"/>
                    <StrokeHighlightControl Style="{StaticResource A_Style_ContentControl_TileSelectionStroke}" Focusable="False" Margin="5"/>
                </Grid>

                <!--Lock state trigger.-->
                <ControlTemplate.Triggers>
                    <DataTrigger Binding="{Binding Command.DeniedCommand, Converter={StaticResource A_Converter_DeniedCommandToLockState}}" Value="{x:Static local:LockState.Locked}">
                        <Setter TargetName="BackgroundTexture" Property="Visibility" Value="Collapsed"/>
                        <Setter TargetName="PadLock" Property="Visibility" Value="Visible"/>
                        <Setter TargetName="SlotText" Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <local:LinearTransformConverter x:Key="A_LinearTransformConverter_CreativeHubTile_YPositionTransform" Scale="160"/>
            <local:LinearTransformConverter x:Key="A_LinearTransformConverter_CreativeHubTile_XPositionTransform" Scale="244"/>

            <Style x:Key="A_Style_Button_PlaygroundGamesCampaignSlotTile"
                BasedOn="{StaticResource A_Style_Button_RootTile}"
                TargetType="{x:Type local:FZButton}">
                <Setter Property="Width" Value="240"/>
                <Setter Property="Height" Value="156"/>
                <Setter Property="local:TileMenuNavigationManager.GridWidth" Value="1"/>
                <Setter Property="local:TileMenuNavigationManager.GridHeight" Value="1"/>
                <Setter Property="Canvas.Left" Value="{Binding Path=(local:TileMenuNavigationManager.GridX) ,RelativeSource={RelativeSource Self}, Converter={StaticResource A_LinearTransformConverter_CreativeHubTile_XPositionTransform}}"/>
                <Setter Property="Canvas.Top" Value="{Binding Path=(local:TileMenuNavigationManager.GridY) ,RelativeSource={RelativeSource Self}, Converter={StaticResource A_LinearTransformConverter_CreativeHubTile_YPositionTransform}}"/>
                <Setter Property="Template" Value="{StaticResource A_DataTemplate_ListItem_CampaignSlotMenuItem}"/>
                <Setter Property="Command" Value="{Binding Command}"/>
            </Style>

            <Style x:Key="A_Style_Button_PlaygroundGamesCampaignSlotTile_Eventlab"
                BasedOn="{StaticResource A_Style_Button_PlaygroundGamesCampaignSlotTile}"
                TargetType="{x:Type local:FZButton}">
                <Setter Property="Width" Value="728"/>
                <Setter Property="local:TileMenuNavigationManager.GridWidth" Value="3"/>
                <Setter Property="Template" Value="{StaticResource A_DataTemplate_ListItem_CampaignSlotMenuItem_Eventlab}"/>
            </Style>

            <!--This is used to return a local string based on the binding value-->
            <local:MappingConverter x:Key="A_Converter_CampaignSwitchEventToSwitchEventString">
                <local:MappingConverterEntry Key="{x:Static local:CampaignSwitchEventAVUI.NotAvailable}" Value="{x:Null}"/>
                <local:MappingConverterEntry Key="{x:Static local:CampaignSwitchEventAVUI.Season}" Value="{local:Loc HelpButtons.IDS_SwitchToSeasonEvent}"/>
            </local:MappingConverter>
        </ResourceDictionary>
    </Page.Resources>

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

    <Grid x:Name="PART_LayoutRoot">
        <local:PlayerBarControl x:Name="TopBar" Style="{StaticResource A_Style_PlayerBarControl}" />
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        x:Name="BottomBar">
            <ControllerButtonPanel x:Name="PART_HelpPanel"
                                 Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <ControllerButtonControl Button="A"
                                         Description="{Loc HelpButtons.IDS_Select}" />
                <ControllerButtonControl Button="B"
                                         Description="{Loc HelpButtons.IDS_Back}" />
                <ControllerButtonControl Button="Y"
                                         Description="{Binding SwitchEventMenu, Converter={StaticResource A_Converter_CampaignSwitchEventToSwitchEventString}}"/>
            </ControllerButtonPanel>
        </ContentControl>
        <Border Style="{StaticResource A_Style_Border_ScenePadding}"
                ClipToBounds="false">
            <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                  Margin="0,60,0,0"
                  ClipToBounds="false">
                <StackPanel Margin="0,0,0,111" VerticalAlignment="Bottom" HorizontalAlignment="Left" ClipToBounds="false">
                    <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}" Visibility="{Binding HideTitleUI, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"
                                Margin="0,0,4,-4"
                                HorizontalAlignment="Left">
                        <ContentControl x:Name="ContentControl_SceneTitle"
                                        Content="{Binding ScreenTitle, Converter={StaticResource A_StringToUpper}}"
                                        local:BindingProxy.A="{Binding ScreenTitleIcon}"
                                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"/>
                    </StackPanel>

                    <StackPanel x:Name="PART_MenuContent"
                                Panel.ZIndex="1"
                                RenderTransformOrigin="0.5,0.5">
                        <local:AutoSizeCanvas x:Name="PART_SCOPE_Main">
                            <local:FZButton DataContext="{Binding KingItem}"
                                            Style="{StaticResource A_Style_Button_PlaygroundGamesCampaignSlotTile}"
                                            local:TileMenuNavigationManager.GridX="0"
                                            local:TileMenuNavigationManager.GridY="0"/>
                            <local:FZButton DataContext="{Binding InfectedItem}"
                                            Style="{StaticResource A_Style_Button_PlaygroundGamesCampaignSlotTile}"
                                            local:TileMenuNavigationManager.GridX="1"
                                            local:TileMenuNavigationManager.GridY="0"/>
                            <local:FZButton DataContext="{Binding FlagrushItem}"
                                            Style="{StaticResource A_Style_Button_PlaygroundGamesCampaignSlotTile}"
                                            local:TileMenuNavigationManager.GridX="2"
                                            local:TileMenuNavigationManager.GridY="0"/>
                            <local:FZButton DataContext="{Binding TeamkingItem}"
                                            Style="{StaticResource A_Style_Button_PlaygroundGamesCampaignSlotTile}"
                                            local:TileMenuNavigationManager.GridX="0"
                                            local:TileMenuNavigationManager.GridY="1"/>
                            <local:FZButton DataContext="{Binding SurvivalItem}"
                                            Style="{StaticResource A_Style_Button_PlaygroundGamesCampaignSlotTile}"
                                            local:TileMenuNavigationManager.GridX="1"
                                            local:TileMenuNavigationManager.GridY="1"/>
                            <local:FZButton DataContext="{Binding TeamFlagRushItem}"
                                            Style="{StaticResource A_Style_Button_PlaygroundGamesCampaignSlotTile}"
                                            local:TileMenuNavigationManager.GridX="2"
                                            local:TileMenuNavigationManager.GridY="1"/>
                            <local:FZButton DataContext="{Binding CustomEventLabItem}"
                                            Style="{StaticResource A_Style_Button_PlaygroundGamesCampaignSlotTile_Eventlab}"
                                            local:TileMenuNavigationManager.GridX="0"
                                            local:TileMenuNavigationManager.GridY="2"
                                            local:BindingProxy.B="1" />
                        </local:AutoSizeCanvas>
                    </StackPanel>

                    <local:FZMaterial x:Name="DescriptionPanel"
                                      Style="{StaticResource H_Style_Container_GlassHighBlur_Description}"
                                      Height="88" Margin="0,4,0,4" Panel.ZIndex="0"
                                      Width="716">
                        <local:FZTextBlock Text="{Binding (local:AttachedTileMenu.TileMenuNavigationManager).SelectedTile.DataContext.Description}"
                                           Style="{StaticResource A_Style_FZTextBlock_Description}"
                                           HorizontalAlignment="Left"
                                           VerticalAlignment="Top"
                                           Margin="24,18"
                                           TextWrapping="Wrap"
                                           Color="{StaticResource A_Color_White}"/>
                    </local:FZMaterial>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Page>
