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

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

    <Page.Resources>
        <ResourceDictionary>

            <local:FZMaterialPresetGlassRoundtangle x:Key="A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterAll_HighBlur"  BasedOn="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterAll}"
                                                    BlurAmount="High"/>

            <Style x:Key="A_Style_FZMaterial_GlassPanel_Pill_VideoOptions" TargetType="{x:Type local:FZMaterial}" BasedOn="{StaticResource A_Style_FZMaterial_GlassPanel_Pill}">
                <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterAll_HighBlur}"/>
                <Setter Property="Color" Value="{StaticResource A_Color_PopupGlass}"/>
            </Style>

            <local:TileMenuDataItem x:Key="A_DataItem_ColorblindMode" Description="{local:Loc MyProfile.IDS_ColorblindModeDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_MinorNotifications" Heading="{local:Loc InGame.IDS_HudOption_MinorNotifications}" Description="{local:Loc InGame.IDS_HudOption_MinorNotifications_Desc}" />
            <local:TileMenuDataItem x:Key="A_DataItem_ActivityInviteNotifications" Heading="{local:Loc InGame.IDS_HudOption_ActivityInviteNotifications}" Description="{local:Loc InGame.IDS_HudOption_ActivityInviteNotifications_Desc}" />
            <local:TileMenuDataItem x:Key="A_DataItem_Subtitles" Description="{local:Loc MyProfile.IDS_SubtitlesDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_SubtitlesBackgroundOpacity" Heading="{local:Loc MyProfile.IDS_SubtitlesBackgroundOpacity}" Description="{local:Loc MyProfile.IDS_SubtitlesBackgroundOpacityDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_SubtitlesKeywordHighlight" Heading="{local:Loc MyProfile.IDS_SubtitlesKeywordHighlight}" Description="{local:Loc MyProfile.IDS_SubtitlesKeywordHighlightDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_SubtitlesFontSize" Heading="{local:Loc MyProfile.IDS_SubtitlesFontSize}" Description="{local:Loc MyProfile.IDS_SubtitlesFontSizeDescription}" />

            <local:TileMenuDataItem x:Key="A_DataItem_ScreenReaderPlatformOverride" Description="{local:Loc MyProfile.IDS_ScreenReaderPlatformOverrideDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_VoiceChatTTSPlatformOverride" Description="{local:Loc MyProfile.IDS_VoiceChatTTSPlatformOverrideDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_VoiceChatSTTPlatformOverride" Description="{local:Loc MyProfile.IDS_VoiceChatSTTPlatformOverrideDescription}" />

            <local:MultiConverter x:Key="A_Converter_OpacityBagValueToDisplayValue">
                <local:MultiConverterEntry>
                    <local:MultiConverterEntry.Converter>
                        <local:LinearTransformConverter Scale="100" />
                    </local:MultiConverterEntry.Converter>
                </local:MultiConverterEntry>
                <local:MultiConverterEntry Converter="{StaticResource A_NumUnitConverter_NoUnit_0dp}" />
            </local:MultiConverter>

            <Style x:Key="A_Style_SpinnerControl_Accessibility_InItemsList"
                BasedOn="{StaticResource A_Style_SpinnerControl_Default_InItemsList}"
                TargetType="local:SpinnerControl">
                <Setter Property="local:AccumulateSelfOnParent.ParentName" 
                        Value="OptionsList"/>
                <Setter Property="local:AccumulateSelfOnParent.SortOrder"
                        Value="{Binding (ItemsControl.AlternationIndex), RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/>
                <Setter Property="local:FindSelfIndexInCollection.Collection"
                        Value="{Binding (local:AccumulateSelfOnParent.Output), ElementName=OptionsList}"/>
                <Setter Property="local:ScreenReader.SelectedNumber"
                        Value="{Binding (local:FindSelfIndexInCollection.Index), RelativeSource={RelativeSource Self}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=0}"/>
                <Setter Property="local:ScreenReader.SelectedCount"
                        Value="{Binding (local:AccumulateSelfOnParent.Output).Count, ElementName=OptionsList, FallbackValue=0}"/>
            </Style>

            <Style x:Key="A_Style_Slider_Options_Default_AccessibilityOption"
                   BasedOn="{StaticResource A_Style_Slider_Options_InItemsList}"
                   TargetType="Slider">
                <Setter Property="local:AccumulateSelfOnParent.ParentName" 
                        Value="OptionsList"/>
                <Setter Property="local:AccumulateSelfOnParent.SortOrder"
                        Value="{Binding (ItemsControl.AlternationIndex), RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/>
                <Setter Property="local:FindSelfIndexInCollection.Collection"
                        Value="{Binding (local:AccumulateSelfOnParent.Output), ElementName=OptionsList}"/>
                <Setter Property="local:ScreenReader.SelectedNumber"
                        Value="{Binding (local:FindSelfIndexInCollection.Index), RelativeSource={RelativeSource Self}, Converter={StaticResource A_IndexToNumberConverter}, FallbackValue=0}"/>
                <Setter Property="local:ScreenReader.SelectedCount"
                        Value="{Binding (local:AccumulateSelfOnParent.Output).Count, ElementName=OptionsList, FallbackValue=0}"/>
            </Style>

            <Style x:Key="A_Style_SpinnerControl_HighlightKeywordsOption"
                   BasedOn="{StaticResource A_Style_SpinnerControl_Accessibility_InItemsList}"
                   TargetType="local:SpinnerControl">
                <Setter Property="Visibility"
                        Value="Visible" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding DataSource.CanHighlightKeywords, RelativeSource={RelativeSource AncestorType=Page}}"
                                 Value="False">
                        <Setter Property="Visibility"
                                Value="Collapsed" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style TargetType="{x:Type local:ControllerButtonControl}"
                   x:Key="A_Style_ControllerButtonControl_Accessibility_B"
                   BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
                <Setter Property="Visibility"
                Value="{Binding AllowBack, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" />
                <Setter Property="Button"
                Value="B" />
                <Setter Property="Description"
                Value="{local:Loc HelpButtons.IDS_Back}" />
            </Style>
        </ResourceDictionary>
    </Page.Resources>

    <Grid>
        <!-- Background Blur -->
        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Popup_Background}" 
                          Visibility="{Binding ForceBackgroundBlur, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}" />
        <Control Style="{StaticResource A_Style_Control_ScreenBackground}"/>
        <Grid>
            <local:PlayerBarControl x:Name="TopBar" Style="{StaticResource A_Style_PlayerBarControl}" />
            <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
                <local:ControllerButtonPanel x:Name="HelpPanel" Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                    <local:ControllerButtonControl Button="A" Description="{local:Loc HelpButtons.IDS_Accept}"/>
                    <local:ControllerButtonControl Style="{StaticResource A_Style_ControllerButtonControl_Accessibility_B}"/>
                    <local:ControllerButtonControl Button="Y" Description="{local:Loc HelpButtons.IDS_ResetDefault}" />
                    <local:ControllerButtonControl Style="{StaticResource A_Style_ControllerButtonControl_PreviewSubtitles}" />
                </local:ControllerButtonPanel>
            </ContentControl>

            <Border x:Name="LayoutRoot" SnapsToDevicePixels="True"
                    Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
                <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}" Focusable="False" >
                    <StackPanel Name="BasicOptions" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}" >
                        <ContentControl Tag="{local:Loc ScreenTitles.IDS_MyProfile}" 
                                        Content="{local:Loc ScreenTitles.IDS_AccessibilitySetup}" 
                                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                        local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Options.png"
                                        Focusable="False" 
                                        HorizontalAlignment="Left" />

                        <DockPanel>
                            <ContentControl DataContext="{Binding SelectedItem, ElementName=OptionsList}"
                                            Content="{Binding Tag.Description}"
                                            Width="412"
                                            DockPanel.Dock="Right"
                                            VerticalAlignment="Top"
                                            Style="{StaticResource A_Style_DescriptionPanel_Options}" />
                            <Grid DockPanel.Dock="Left">
                                <local:CommonListBox x:Name="OptionsList"
                                                     Width="824" AllowMouseWheelScrolling="False"
                                                     VerticalAlignment="Top"
                                                     SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=Page}}"
                                                     Style="{StaticResource A_Style_ListBox_List_Default}"
                                                     ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_NotFocusable}"
                                                     local:FocusOnPageFocusGained.VirtualizingSelectorSelectedItem="True">
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_ColorblindMode}" Style="{StaticResource A_Style_SpinnerControl_Accessibility_InItemsList}" 
                                                          Label="{local:Loc MyProfile.IDS_ColorblindMode}" ItemsSource="{Binding ColorblindModeOptions}" SelectedIndex="{Binding ColorblindMode}" />

                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_Subtitles}" Style="{StaticResource A_Style_SpinnerControl_Accessibility_InItemsList}" 
                                                          Label="{local:Loc MyProfile.IDS_Subtitles}" ItemsSource="{Binding OnOffOptions}" SelectedIndex="{Binding Subtitles}"
                                                          local:AccessibilityOptions.IsSubtitlesProperty="True" />
                                    <Slider Value="{Binding SubtitlesTextSize}"
                                            Tag="{StaticResource A_DataItem_SubtitlesFontSize}"
                                            Style="{StaticResource A_Style_Slider_Options_Default_AccessibilityOption}"
                                            Maximum="{Binding MaxSubtitlesTextSize}"
                                            Minimum="{Binding MinSubtitlesTextSize}"
                                            SmallChange="1"
                                            local:BindingProxy.B="{Binding SubtitlesTextSize, Converter={StaticResource A_Converter_SubtitlesFontSizeStringValue}}" 
                                            local:AccessibilityOptions.IsSubtitlesProperty="True" />
                                    <Slider Value="{Binding SubtitlesBackgroundOpacity}"
                                            Tag="{StaticResource A_DataItem_SubtitlesBackgroundOpacity}"
                                            Style="{StaticResource A_Style_Slider_Options_Default_AccessibilityOption}"
                                            SmallChange="0.05"
                                            local:BindingProxy.B="{Binding Value, RelativeSource={RelativeSource Self}, Converter={StaticResource A_Converter_OpacityBagValueToDisplayValue}}" 
                                            local:AccessibilityOptions.IsSubtitlesProperty="True" />
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_SubtitlesKeywordHighlight}"
                                                          Style="{StaticResource A_Style_SpinnerControl_HighlightKeywordsOption}"
                                                          Label="{local:Loc MyProfile.IDS_SubtitlesKeywordHighlight}"
                                                          ItemsSource="{Binding OnOffOptions}" SelectedItem="{Binding SubtitlesHighlightKeywordsItem}"
                                                          local:AccessibilityOptions.IsSubtitlesProperty="True" />

                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_MinorNotifications}" Style="{StaticResource A_Style_SpinnerControl_Accessibility_InItemsList}" 
                                                          Label="{local:Loc InGame.IDS_HudOption_MinorNotifications}" ItemsSource="{Binding OnOffOptions}"  SelectedIndex="{Binding MinorNotifications}" />

                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_ActivityInviteNotifications}" Style="{StaticResource A_Style_SpinnerControl_Accessibility_InItemsList}"
                                                          Label="{local:Loc InGame.IDS_HudOption_ActivityInviteNotifications}" ItemsSource="{Binding OnOffOptions}"  SelectedIndex="{Binding ActivityInviteNotifications}" />
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_ScreenReaderPlatformOverride}" Style="{StaticResource A_Style_SpinnerControl_Accessibility_InItemsList}"
                                                        Visibility="{Binding CanOverrideScreenReader, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                                        Label="{local:Loc MyProfile.IDS_ScreenReaderPlatformOverride}" ItemsSource="{Binding AccessibilityOverrideOptions}" SelectedIndex="{Binding ScreenReaderPlatformOverride}" />
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_VoiceChatTTSPlatformOverride}" Style="{StaticResource A_Style_SpinnerControl_Accessibility_InItemsList}"
                                                        Label="{local:Loc MyProfile.IDS_VoiceChatTTSPlatformOverride}" ItemsSource="{Binding AccessibilityOverrideOptions}" SelectedIndex="{Binding VoiceChatTTSPlatformOverride}" />
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_VoiceChatSTTPlatformOverride}" Style="{StaticResource A_Style_SpinnerControl_Accessibility_InItemsList}"
                                                        Label="{local:Loc MyProfile.IDS_VoiceChatSTTPlatformOverride}" ItemsSource="{Binding AccessibilityOverrideOptions}" SelectedIndex="{Binding VoiceChatSTTPlatformOverride}" />
                                </local:CommonListBox>
                            </Grid>
                        </DockPanel>
                    </StackPanel>
                </Grid>
            </Border>

            <local:PageInputHandler Style="{StaticResource A_Style_PageInputHandler_PreviewSubtitlesButton}" />
        </Grid>
    </Grid>
</Page>
