<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_LiveryPaintSelect"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <Page.Resources>
        <Color x:Key="H_Color_Toggle_Background">#FF8C8C8C</Color>

        <System:String x:Key="A_String_AdvancedSupport">+</System:String>
        <DataTemplate x:Key="A_DataTemplate_LiveryPaintItemData">
            <Grid>
                <local:FZMaterial ImageSource="{Binding IconPath}"
                                  Margin="10" />
                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_HorizonA}"
                                CapHeight="24"
                                Text="{Binding Source={StaticResource A_String_AdvancedSupport}}"
                                Color="{StaticResource H_Color_Primary_Black}"
                                Margin="5,7"
                                AlignToCapAndBaseLines="True"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Bottom"
                                Visibility="{Binding SupportsSubgroups, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" />
            </Grid> 
        </DataTemplate>
      
      <System:Double x:Key="PaintIconSize">156</System:Double> <!-- 152 + margin--> 

        <MappingConverter x:Key="A_Map_ToggleEnabledToAlignment" Default="Right">
            <MappingConverterEntry Key="{StaticResource A_Boolean_False}" Value="Left"/>
        </MappingConverter>

        <MappingConverter x:Key="A_Map_ToggleEnabledToColor" Default="{StaticResource H_Color_Primary_Pink}">
            <MappingConverterEntry Key="{StaticResource A_Boolean_False}" Value="{StaticResource H_Color_Primary_White}"/>
        </MappingConverter>

    </Page.Resources>

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

    <Grid>
        <!-- Bars -->
        <ContentControl x:Name="BottomBar"
                        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_Select}" />
                <local:ControllerButtonControl Button="B"
                                               Description="{local:Loc HelpButtons.IDS_Back}" />
                <local:ControllerButtonControl Button="Back"
                                               Description="{local:Loc HelpButtons.IDS_Save}" />
            </local:ControllerButtonPanel>
        </ContentControl>

        <Border x:Name="PART_LayoutRoot"
                Style="{StaticResource A_Style_Border_ScenePadding_TiledScene}">
            <Grid Margin ="24,26,0,0">            
                <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">  
                    <local:RoutedEventCommand x:Name="ButtonBarDisableMouseCursorMovement"
                                              RoutedEvent="UIElement.MouseEnter"
                                              Command="{Binding DisableCameraFocus,RelativeSource={RelativeSource AncestorType=Page}}" />
                    <local:RoutedEventCommand x:Name="ButtonBarEnableMouseCursorMovement"
                                              RoutedEvent="UIElement.MouseLeave"
                                              Command="{Binding EnableCameraFocus,RelativeSource={RelativeSource AncestorType=Page}}" />

                    <local:FZMaterial Style="{StaticResource H_Style_Container_ScreenTitle}" 
                                      x:Name="MenuHeader"
                                      Color="{StaticResource H_Color_Primary_Green}"
                                      HorizontalAlignment="Left"
                                      Width="464"
                                      VerticalAlignment="Bottom"
                                      Margin="0,0,0,12"
                                      Visibility="{Binding Text, ElementName=Textblock_Title, Converter={StaticResource A_StringVisConverter}}">
                        <local:FZTextBlock Style="{StaticResource H_Style_Text_ScreenTitle}"
                                           Text="{Binding SelectedItem.ItemName, ElementName=PART_ItemsSelector_PaintMenu}"
                                           Color="{StaticResource H_Color_Primary_Black}"
                                           CapHeight="18"
                                           Margin="24,0,24,0"
                                           HorizontalAlignment="Left"
                                           Focusable="False"/>
                    </local:FZMaterial>
                    <local:WrapListBox x:Name="PART_ItemsSelector_PaintMenu"
                                       Style="{StaticResource H_Style_UpgradeGrid_Square_3x3}"
                                       ItemTemplate="{StaticResource A_DataTemplate_LiveryPaintItemData}"
                                       ItemsSource="{Binding PaintMenuCollection}"
                                       ItemWidth="{StaticResource PaintIconSize}"
                                       ItemHeight="{StaticResource PaintIconSize}"
                                       ScrollOrientation="Vertical"
                                       HorizontalAlignment="Left"
                                       SelectedIndex="0"
                                       local:RoutedEventCommand.Action="{Binding ElementName=ButtonBarDisableMouseCursorMovement}"
                                       local:RoutedEventCommand.Action2="{Binding ElementName=ButtonBarEnableMouseCursorMovement}"/>
                
                </StackPanel>
                <StackPanel Margin="0,-71,-6,0" Visibility="{Binding IsControllerActiveInput, Converter={StaticResource A_FZBooleanToVisibilityConverter}, RelativeSource={RelativeSource AncestorType=Page}}">
                    <StackPanel Orientation="Horizontal"  HorizontalAlignment="Right"  Visibility="{Binding HasCamera, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                        <FZMaterial Color="{StaticResource H_Color_Primary_White}" Height="48" Width="48">
                            <FZMaterial Color="{StaticResource H_Color_Primary_Black}"  Height="48" Width="48" ImageSource="/ForzaUI;component/Textures/Anthem/Paintshop/advanced_camera.png"/>
                        </FZMaterial>
                        <Grid 
                            Name="Advanced_Camera_Button_Prompt"
                            MinWidth="300" 
                            Height="48">
                            <FZMaterial 
                                Color="{StaticResource H_Color_Glass_Purple_40pc}"
                                Preset="{StaticResource H_GlassRoundtangle_1px}"/>
                            <DockPanel Margin="10,0,10,0">
                                <ControllerButtonControl
                                Button="LTrigger"
                                Description="{local:Loc HelpButtons.IDS_AdvancedCamera}"
                                HideBackground="True"/>
                                <Grid>
                                    <FZMaterial
                                    Height="30"
                                    Width="43"
                                    Color="{Binding AdvancedCameraEnabled, Converter={StaticResource A_Map_ToggleEnabledToColor}}">
                                        <FZMaterial.Preset>
                                            <FZMaterialPresetRoundtangleStroke CornerRadius="14" Thickness="3.5" />
                                        </FZMaterial.Preset>
                                    </FZMaterial>
                                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                                        <FZMaterial
                                            Height="17"
                                            Width="30"
                                            Color="{StaticResource H_Color_Toggle_Background}">
                                            <FZMaterial.Preset>
                                                <FZMaterialPresetRoundtangle CornerRadius="8" />
                                            </FZMaterial.Preset>
                                        </FZMaterial>
                                        <FZMaterial
                                           Height="18"
                                           Width="18"
                                           Color="{Binding AdvancedCameraEnabled, Converter={StaticResource A_Map_ToggleEnabledToColor}}"
                                           HorizontalAlignment="{Binding AdvancedCameraEnabled, Converter={StaticResource A_Map_ToggleEnabledToAlignment},RelativeSource={RelativeSource FindAncestor, AncestorType=Page}}">
                                            <FZMaterial.Preset>
                                                <FZMaterialPresetRoundtangle CornerRadius="8" />
                                            </FZMaterial.Preset>
                                        </FZMaterial>
                                    </Grid>
                                </Grid>
                            </DockPanel>
                            <FZMaterial Color="#0fff" IsHitTestVisible="True" />
                        </Grid>
                    </StackPanel>
                    <FZMaterial Color="{StaticResource H_Color_Glass_Purple_20pc}" 
                                Preset="{StaticResource H_GlassRoundtangle_1px}" 
                                Height="48" 
                                Width="219" 
                                HorizontalAlignment="Right"
                                Margin="0,3,0,0"
                                Visibility="{Binding AdvancedCameraEnabled, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                        <StackPanel Orientation="Horizontal">
                            <ControllerButtonControl
                               Margin="10,0,0,0"
                               Button="LThumb_UpDown"
                               Description="{local:Loc HelpButtons.IDS_AdvancedCameraZoom}"
                               HorizontalAlignment="Left"
                               HideBackground="True"/>
                            <ControllerButtonControl
                               Button="RThumb" 
                               HorizontalAlignment="Right"
                               Description="{local:Loc HelpButtons.IDS_AdvancedCameraPan}"
                               HideBackground="True"/>
                        </StackPanel>
                    </FZMaterial>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Page>