<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.A_AudioOptions"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding DataSource, RelativeSource={RelativeSource Self}}"
      FocusManager.FocusedElement="{Binding ElementName=OptionsList}"
      >

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

    <Page.Resources>
        <ResourceDictionary>
            <local:TileMenuDataItem x:Key="A_DataItem_Preset"                                                         Description="{local:Loc MyProfile.IDS_AudioPresetDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_XboxMusic"                                                      Description="{local:Loc MyProfile.IDS_XboxMusicDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_XboxMusicShuffle"                                               Description="{local:Loc MyProfile.IDS_XboxMusicShuffleDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_MasterVolume"    Heading="{local:Loc MyProfile.IDS_MasterGameVolume}" Description="{local:Loc MyProfile.IDS_MasterGameVolumeDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_RadioVolume"    Heading="{local:Loc MyProfile.IDS_RadioVolume}" Description="{local:Loc MyProfile.IDS_RadioVolumeDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_GrooveVolume"   Heading="{local:Loc MyProfile.IDS_GrooveVolume}" Description="{local:Loc MyProfile.IDS_GrooveVolumeDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_SFXVolume"      Heading="{local:Loc MyProfile.IDS_SFXVolume}"   Description="{local:Loc MyProfile.IDS_SFXVolumeDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_VOVolume"       Heading="{local:Loc MyProfile.IDS_VOVolume}"    Description="{local:Loc MyProfile.IDS_VOVolumeDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_CarVolume"      Heading="{local:Loc MyProfile.IDS_CarVolume}"   Description="{local:Loc MyProfile.IDS_CarVolumeDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_TireVolume"     Heading="{local:Loc MyProfile.IDS_TireVolume}"  Description="{local:Loc MyProfile.IDS_TireVolumeDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_GPSVoice"                                                       Description="{local:Loc MyProfile.IDS_GPSVoiceDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_RadioDJ"                                                        Description="{local:Loc MyProfile.IDS_RadioDJDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_Horns"          Heading="{local:Loc MyProfile.IDS_Horns}"       Description="{local:Loc MyProfile.IDS_HornsDescription}" />
            <local:TileMenuDataItem x:Key="A_DataItem_VoiceChatMode"  Heading="{local:Loc InGame.IDS_HudOption_VoiceChatMode}" Description="{local:Loc InGame.IDS_HudOption_VoiceChatMode_Desc}" />
            <local:TileMenuDataItem x:Key="A_DataItem_StreamerMode"   Heading="{local:Loc MyProfile.IDS_StreamerMode}" Description="{local:Loc MyProfile.IDS_StreamerModeDescription}" />

            <Style x:Key="A_Style_SpinnerControl_Audio_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_SpinnerControl_Audio_InItemsList_AltStyle"
                BasedOn="{StaticResource A_Style_SpinnerControl_Default_InItemsList_AltStyle}"
                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_Audio_Min1"
                   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}"/>
                <Setter Property="SmallChange"
                        Value="0.1" />
                <Setter Property="Minimum"
                        Value="0.1" />
                <Setter Property="IsSnapToTickEnabled"
                        Value="True" />
                <Setter Property="TickFrequency"
                        Value="0.1" />
                <Setter Property="local:BindingProxy.B"
                        Value="{Binding Value, RelativeSource={RelativeSource Self}, ConverterParameter=fracpercentage, Converter={StaticResource A_NumUnitConverter_PercentDecimated}}" />
            </Style>

            <Style x:Key="A_Style_Slider_Options_Audio_Min0"
                   BasedOn="{StaticResource A_Style_Slider_Options_Audio_Min1}" TargetType="Slider">
                <Setter Property="Minimum" Value="0.0" />
            </Style>
        </ResourceDictionary>
    </Page.Resources>

    <Grid>
        <!-- Background Blur -->
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <local:PlayerBarControl x:Name="TopBar" Style="{StaticResource A_Style_PlayerBarControl}" />
        <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="DefaultHelpPanel"
                    local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Accept}"
                    local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Cancel}"
                    local:ControllerButtonPanel.YDescription="{local:Loc HelpButtons.IDS_ResetDefault}"
                    Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>

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

                        <DockPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}" >
                            <ContentControl Content="{Binding Tag.Description}"
                                            DataContext="{Binding SelectedItem, ElementName=OptionsList}"
                                            Style="{StaticResource A_Style_DescriptionPanel_Options}"
                                            local:UIPageTransitionManager.TransitionIndex="1"
                                            DockPanel.Dock="Right"
                                            VerticalAlignment="Top" />

                            <Grid local:UIPageTransitionManager.TransitionIndex="0" DockPanel.Dock="Left" >
                                <local:CommonListBox x:Name="OptionsList"
                                                     Style="{StaticResource A_Style_ListBox_List_Default}"
                                                     ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_NotFocusable}"
                                                     Width="824">
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_Preset}" Style="{StaticResource A_Style_SpinnerControl_Audio_InItemsList_AltStyle}" Label="{local:Loc MyProfile.IDS_AudioPreset}" SelectedIndex="{Binding AudioPreset}" ItemsSource="{Binding AudioPresetOptions}" x:Name="FirstItem"/>
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_XboxMusic}" Style="{StaticResource A_Style_SpinnerControl_Audio_InItemsList}" Label="{local:Loc MyProfile.IDS_XboxMusic}" SelectedIndex="{Binding XboxMusic}" ItemsSource="{Binding XboxMusicOptions}" IsEnabled="{Binding PlaylistsSet}" Visibility="{Binding IsXboxMusicEnabled, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" local:BindingProxy.B="{x:Static TextTrimming.CharacterEllipsis}"/>
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_XboxMusicShuffle}" Style="{StaticResource A_Style_SpinnerControl_Audio_InItemsList}" Label="{local:Loc MyProfile.IDS_XboxMusicShuffle}" SelectedIndex="{Binding XboxMusicShuffle}" ItemsSource="{Binding OnOffOptions}" Visibility="{Binding IsXboxMusicEnabled, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                                    <Slider Value="{Binding MasterGameVolume}" Tag="{StaticResource A_DataItem_MasterVolume}" Style="{StaticResource A_Style_Slider_Options_Audio_Min0}" Visibility="{Binding IsPC, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                                    <Slider Value="{Binding RadioVolume}" Tag="{StaticResource A_DataItem_RadioVolume}" Style="{StaticResource A_Style_Slider_Options_Audio_Min1}" />
                                    <Slider Value="{Binding GrooveVolume}" Tag="{StaticResource A_DataItem_GrooveVolume}" Style="{StaticResource A_Style_Slider_Options_Audio_Min1}" Visibility="{Binding IsXboxMusicEnabled, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                                    <Slider Value="{Binding SFXVolume}" Tag="{StaticResource A_DataItem_SFXVolume}" Style="{StaticResource A_Style_Slider_Options_Audio_Min1}" />
                                    <Slider Value="{Binding VOVolume}" Tag="{StaticResource A_DataItem_VOVolume}" Style="{StaticResource A_Style_Slider_Options_Audio_Min1}" />
                                    <Slider Value="{Binding CarVolume}" Tag="{StaticResource A_DataItem_CarVolume}" Style="{StaticResource A_Style_Slider_Options_Audio_Min1}" />
                                    <Slider Value="{Binding TireVolume}" Tag="{StaticResource A_DataItem_TireVolume}" Style="{StaticResource A_Style_Slider_Options_Audio_Min1}" />
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_GPSVoice}" Style="{StaticResource A_Style_SpinnerControl_Audio_InItemsList}" Label="{local:Loc MyProfile.IDS_GPSVoice}" SelectedIndex="{Binding GPSVoice}" ItemsSource="{Binding OnOffOptions}"/>
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_RadioDJ}" Style="{StaticResource A_Style_SpinnerControl_Audio_InItemsList}" Label="{local:Loc MyProfile.IDS_RadioDJ}" SelectedIndex="{Binding RadioDJ}" ItemsSource="{Binding OnOffOptions}"/>
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_Horns}" Style="{StaticResource A_Style_SpinnerControl_Audio_InItemsList}" Label="{local:Loc MyProfile.IDS_Horns}" SelectedIndex="{Binding Horns}" ItemsSource="{Binding OnOffSoloOptions}"/>
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_VoiceChatMode}"  Style="{StaticResource A_Style_SpinnerControl_Audio_InItemsList}" Label="{local:Loc InGame.IDS_HudOption_VoiceChatMode}" SelectedIndex="{Binding VoiceChatMode}" ItemsSource="{Binding VoiceChatModeOptions}"/>
                                    <local:SpinnerControl Tag="{StaticResource A_DataItem_StreamerMode}" Style="{StaticResource A_Style_SpinnerControl_Audio_InItemsList}" Label="{local:Loc MyProfile.IDS_StreamerMode}" SelectedIndex="{Binding StreamerMode}" ItemsSource="{Binding OnOffOptions}"/>
                                </local:CommonListBox>
                            </Grid>
                        </DockPanel>
                    </StackPanel>
                </Grid>
            </Grid>
        </Border>
    </Grid>
</Page>
