<Page x:Class="ForzaUI.Scenes.Anthem.A_QuickChatContextSelect"
      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:local="clr-namespace:ForzaUI"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      mc:Ignorable="d" 
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

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

    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_ListBoxItem_QuickChatSlotItem"
                BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu_Default}"
                TargetType="ListBoxItem">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Input}" Value="{x:Null}">
                        <Setter Property="Focusable"
                                Value="False" />
                        <Setter Property="Tag"
                                Value="GroupHeader" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_QuickChatSlotText"
                BasedOn="{StaticResource A_Style_FZTextBlock_OptionText}"
                TargetType="{x:Type local:FZTextBlock}">
                <Setter Property="TextAlignment" Value="Right"/>
            </Style>

            <Style x:Key="A_Style_ControllerButtonControl_QuickChatSlotInput"
                TargetType="{x:Type local:ControllerButtonControl}"
                BasedOn="{StaticResource A_Style_ControllerButtonControl_Default_ShowAlways}">
                <Setter Property="Margin" Value="16,0"/>
                <Setter Property="Height" Value="35"/>
                <Setter Property="UseLargeIcon" Value="True"/>
                <Setter Property="HideBackground" Value="True"/>
                <Setter Property="HideShadow" Value="True"/>
                <Setter Property="Desaturate" Value="True"/>
                <Setter Property="AllowMouseClick" Value="False"/>
                <Setter Property="Color" Value="#FF000000"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Value="True">
                        <Setter Property="Color" Value="{StaticResource A_Color_ButtonBar_Foreground}"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Input}" Value="{x:Null}">
                        <Setter Property="Visibility" Value="{x:Static Visibility.Collapsed}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_ListBoxItem_QuickChatSlotItem">
                <Grid IsHitTestVisible="False"
                      Height="{StaticResource A_Double_TextMenu_Height_Default}">
                    <local:ControllerButtonControl x:Name="ControllerButton"
                        Style="{StaticResource A_Style_ControllerButtonControl_QuickChatSlotInput}"
                        InputOverride="{Binding Input}"
                        SupportsControllerInput="True"
                        HorizontalAlignment="Left"
                        local:ScreenReader.Event="OnChange"
                        local:ScreenReader.LineType="SelectedItem"
                        local:ScreenReader.ControlType="Button"
                        local:ScreenReader.SelectedNumber="{Binding ButtonIndex, Converter={StaticResource A_IndexToNumberConverter}}"
                        local:ScreenReader.SelectedCount="{Binding ButtonCount}" />
                    <local:FZTextBlock x:Name="Text" Text="{Binding Text}" Style="{StaticResource A_Style_FZTextBlock_QuickChatSlotText}"
                                       local:ScreenReader.Event="OnChange"
                                       local:ScreenReader.LineType="SelectedValue" />
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Input}" Value="{x:Null}">
                        <Setter TargetName="Text"
                                Property="TextAlignment"
                                Value="Center" />
                        <Setter TargetName="Text"
                                Property="FontFamily"
                                Value="Horizon_C" />
                        <Setter TargetName="Text"
                                Property="Color"
                                Value="{StaticResource A_Color_TextMenu_Text_Highlighted}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True">
                        <Setter TargetName="Text" Property="local:ScreenReader.Line" Value="{Binding Text}" />
                        <Setter TargetName="ControllerButton" Property="local:ScreenReader.Line" Value="{Binding ScreenReaderName, RelativeSource={RelativeSource Self}}" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </ResourceDictionary>
    </Page.Resources>

    <Grid>
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />
        <local:PlayerBarControl x:Name="TopBar"
                                Style="{StaticResource A_Style_PlayerBarControl}"
                                Visibility="{Binding IsInPauseFlow, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
        <ContentControl x:Name="BottomBar"
                            Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="DefaultHelpPanel"
                            local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                            local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_Save}"
                            local:ControllerButtonPanel.YDescription="{local:Loc HelpButtons.IDS_ResetDefault}"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}"/>
        </ContentControl>
        <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}"
                SnapsToDevicePixels="True"
                UseLayoutRounding="True">
            <DockPanel HorizontalAlignment="Center">
                <Decorator DockPanel.Dock="Top" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                    <ContentControl Content="{local:Loc ScreenTitles.IDS_QuickChatSelect}"
                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                HorizontalAlignment="Left"
                                local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/QuickChatSelect.png" />
                </Decorator>

                <local:CommonListBox x:Name="OptionsList"
                                     Style="{StaticResource A_Style_ListBox_TextMenu_Default}"
                                     ItemContainerStyle="{StaticResource A_Style_ListBoxItem_QuickChatSlotItem}"
                                     ItemTemplate="{StaticResource A_DataTemplate_ListBoxItem_QuickChatSlotItem}"
                                     ItemsSource="{Binding Collection}"
                                     SelectedIndex="1"
                                     SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=Page}, Mode=OneWayToSource}"
                                     Height="765"
                                     Width="742"
                                     local:FocusOnPageFocusGained.SelectorSelectedItem="True"
                                     local:ManualPassthroughProperty.Input="{Binding SelectedItem, RelativeSource={RelativeSource Self}}"
                                     local:ManualPassthroughProperty.Allowed="{Binding SelectedItem, RelativeSource={RelativeSource Self}, Converter={StaticResource A_Converter_TrueIfNotNull}, FallbackValue={StaticResource A_Boolean_False}}"
                                     local:ScreenReader.LineType="SelectedGroup"
                                     local:ScreenReader.Event="OnChange"
                                     local:ScreenReader.Line="{Binding (local:ManualPassthroughProperty.LastValidAllowedOutput).ContextName, RelativeSource={RelativeSource Self}}"
                                     local:ScreenReader.SelectedNumber="{Binding (local:ManualPassthroughProperty.LastValidAllowedOutput).ContextIndex, RelativeSource={RelativeSource Self}, Converter={StaticResource A_IndexToNumberConverter}}"
                                     local:ScreenReader.SelectedCount="{Binding (local:ManualPassthroughProperty.LastValidAllowedOutput).ContextCount, RelativeSource={RelativeSource Self}}" />
            </DockPanel>
        </Border>
    </Grid>
</Page>
