<Page xmlns:local="clr-namespace:ForzaUI;assembly="
      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_MusicSelect"
      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>
            <Double x:Key="A_Double_TrackTextStyle_FontSize">24</Double>
            <Double x:Key="A_Double_Content_Width">1060</Double>
            <Double x:Key="A_Double_Content_Height">50</Double>
            <System:Double x:Key="H_Double_Carousel_Total_Width">1464</System:Double>
            <local:MappingConverter x:Key="A_Converter_SelectedBoolToColor"
                                    Default="{StaticResource H_Color_Primary_Black}">
                <local:MappingConverterEntry Key="True" Value="{StaticResource H_Color_Primary_White}"/>
            </local:MappingConverter>
            <local:MappingConverter x:Key="A_Converter_IsSelectedToTextBlockStyle_TrackName"
                                    Default="{StaticResource A_Style_FZTextBlock_HorizonA}">
                <local:MappingConverterEntry Key="True" Value="{StaticResource A_Style_FZTextBlock_HorizonF}"/>
            </local:MappingConverter>
            <local:MappingConverter x:Key="A_Converter_IsSelectedToIconColor_IsPlaying"
                                    Default="{StaticResource H_Color_Primary_Black}">
                <local:MappingConverterEntry Key="True" Value="{StaticResource H_Color_Primary_White}"/>
            </local:MappingConverter>
            <local:MappingConverter x:Key="A_Converter_IsSelectedToTextBlockStyle_ArtistName"
                                    Default="{StaticResource A_Style_FZTextBlock_HorizonF}">
                <local:MappingConverterEntry Key="True" Value="{StaticResource A_Style_FZTextBlock_HorizonA}"/>
            </local:MappingConverter>
            <DataTemplate x:Key="A_DataTemplate_ListBoxItem_RadioTrack">
                <Grid Height="48">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="2*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <local:FZButton Grid.Column="0"
                                    Grid.ColumnSpan="3"
                                    Opacity="0"
                                    Command="{Binding RadioTrackSelectedCommand, RelativeSource={RelativeSource AncestorType=Page}}">
                    </local:FZButton>
                    <local:FZTextBlock Text="{Binding Title}"
                                       Style= "{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource A_Converter_IsSelectedToTextBlockStyle_TrackName}}"
                                       HorizontalAlignment="Left"
                                       VerticalAlignment="Center"
                                       Margin="20,0,10,0"
                                       IsHitTestVisible="False"
                                       Grid.Column="0"
                                       FontSize="{StaticResource A_Double_TrackTextStyle_FontSize}"
                                       Color="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource A_Converter_SelectedBoolToColor}}"/>
                    <local:FZTextBlock Text="{Binding Artist}"
                                       VerticalAlignment="Center"
                                       Style="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource A_Converter_IsSelectedToTextBlockStyle_ArtistName}}"
                                       IsHitTestVisible="False"
                                       Grid.Column="1"
                                       FontSize="{StaticResource A_Double_TrackTextStyle_FontSize}"
                                       Color="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource A_Converter_SelectedBoolToColor}}"/>
                    <Grid Grid.Column="2" Margin="10,0,20,0">
                        <local:FZMaterial Color="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource A_Converter_IsSelectedToIconColor_IsPlaying}}"
                                          Width="32"
                                          Height="32"
                                          VerticalAlignment="Center"
                                          ImageSource="/ForzaUI;component/Textures/Anthem/Icons/music_playing_icon.png"
                                          Visibility="{Binding IsPlaying, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}"
                                          IsHitTestVisible="False"/>
                    </Grid>
                </Grid>
            </DataTemplate>
            <Style x:Key="A_Style_FZMaterial_RadioStationIcon" TargetType="local:FZMaterial">
                <Setter Property="Margin" Value="30"/>
                <Setter Property="Visibility" Value="Collapsed"/>
                <Setter Property="Stretch" Value="None"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="StationOff">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/Icons/RadioStations/RadioIcon_Off.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Horizon Block Party">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Horizon_BlockParty.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Horizon Bass Arena">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Horizon_BassArena.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Horizon Pulse">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Horizon_Pulse.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Horizon XS">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Horizon_XS.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Gacha City Radio">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Gacha_City_Radio.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Hospital Records">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Hospital_Records.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Sub Pop Records">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Sub_Pop_black_and_white.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Horizon Opus">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Horizon_Opus.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Horizon Wave">
                      <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/Horizon_Wave.png" />
                      <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <!-- Adding Custom Style to enforce margin size matching between empty and filled entries -->
            <Style x:Key="A_Style_Control_MusicSelect_EmptyItem"
                TargetType="Control">
                <Setter
                    Property="Focusable"
                    Value="False"/>
                <Setter
                    Property="Template">
                    <Setter.Value>
                        <ControlTemplate
                            TargetType="Control">
                            <DockPanel VerticalAlignment="Stretch" Margin="0,2,0,2">
                                <FZMaterial
                                    Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Base}"
                                    Color="{StaticResource A_Color_GlassPanel_NonInteractive}"/>
                            </DockPanel>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <!-- Background Blur -->
        <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />
        <!-- Bars -->
        <local:PlayerBarControl x:Name="TopBar"
                                Style="{StaticResource A_Style_PlayerBarControl}" />
        <ContentControl x:Name="BottomBar" 
                        Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="PART_DefaultHelpPanel"
                            local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Apply}"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                            local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_PreviewMusic}"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>
        <Grid x:Name="PART_LayoutRoot">
            <local:PageInputHandler Button="X"
                                    x:Name="x_button_handler"
                                    Command="{Binding PreviewSelectedCommand, RelativeSource={RelativeSource AncestorType=Page}}"/>
            <Border x:Name="Frame"
                    Style="{StaticResource A_Style_Border_ScenePadding_Opus}"
                    Padding="228,0,228,0">
                <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}">
                    <StackPanel Orientation="Vertical"
                                VerticalAlignment="Center">
                        <!-- Title -->
                        <Decorator Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                            <ContentControl Content="{local:Loc ScreenTitles.IDS_MusicSelect}"
                                            local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Blueprint.png"
                                            Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                            HorizontalAlignment="Left"/>
                        </Decorator>
                        <StackPanel Orientation="Horizontal"
                                    Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}"
                                    HorizontalAlignment="Left">
                            <FZTabButtonsSelector x:Name="PART_RadioStationList"
                                               Style="{StaticResource H_Style_TabBar}"
                                               Width="{StaticResource H_Double_Carousel_Total_Width}"
                                               ItemsSource="{Binding RadioStations}"/>
                        </StackPanel>

                        <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}"
                                    Orientation="Horizontal">
                            <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}"
                                    Orientation="Vertical">

                                <!-- Song/Artist Title -->
                                <ContentControl Style="{StaticResource A_Style_ContentControl_Header_Custom}"
                                                Width="{StaticResource A_Double_Content_Width}"
                                                Height="48">
                                    <Grid Width="{StaticResource A_Double_Content_Width}">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="2*"/>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <FZTextBlock Style="{StaticResource H_Style_Text_DescriptionTitle}"
                                                     Grid.Column="0"
                                                     HorizontalAlignment="Left"
                                                     VerticalAlignment="Center"
                                                     Margin="20,0,10,0"
                                                     Text="{local:Loc BucketListBlueprint.IDS_Music_ListTitle_Song}"/>

                                        <FZTextBlock Style="{StaticResource H_Style_Text_DescriptionTitle}"
                                                     Grid.Column="1"
                                                     VerticalAlignment="Center"
                                                     Margin="0"
                                                     Text="{local:Loc BucketListBlueprint.IDS_Music_ListTitle_Artist}"/>
                                        <!-- Empty Space to match the the song, artist, play icon from -->
                                        <Grid Grid.Column="2" Margin="10,0,20,0" Width="32 Height=32"/>
                                    </Grid>
                                </ContentControl>
                                <Decorator Height="6"/>

                                <!-- Radio Track List -->
                                <local:WrapListBox
                                   x:Name="PART_RadioTrackList"
                                   Width="{StaticResource A_Double_Content_Width}"
                                   Height="594"
                                   Template="{StaticResource H_ControlTemplate_TextMenu_Default}"
                                   ScrollOrientation="Vertical"
                                   ItemWidth="{StaticResource A_Double_Content_Width}"
                                   ItemHeight="{StaticResource A_Double_Content_Height}"
                                   AlternationCount="10000"
                                   ItemsSource="{Binding SelectedItem.RadioTracks, ElementName=PART_RadioStationList}"
                                   ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_Gaps}"
                                   ItemTemplate="{StaticResource A_DataTemplate_ListBoxItem_RadioTrack}"
                                   EmptyItemStyle="{StaticResource A_Style_Control_MusicSelect_EmptyItem}"/>
                            </StackPanel>

                            <!-- Scrollbar -->
                            <Decorator Width="8"/>
                            <ScrollBar
                                x:Name="PART_ScrollBar_RadioTrackList"
                                HorizontalAlignment="Right"
                                Style="{StaticResource A_Style_ScrollBar_Default}"
                                Minimum="{Binding ScrollWindowMin, ElementName=PART_RadioTrackList}"
                                Maximum="{Binding ScrollWindowMax, ElementName=PART_RadioTrackList}"
                                Value="{Binding ScrollWindowValue, ElementName=PART_RadioTrackList, Mode=TwoWay}"
                                ViewportSize="{Binding ScrollWindowSize, ElementName=PART_RadioTrackList}" />

                            <!-- Description -->
                            <Decorator  Width="8"/>
                            <DockPanel Width="380">
                                <ContentControl Style="{StaticResource A_Style_ContentControl_Header}"
                                        Content="{local:Loc Main.IDS_Description}"
                                                MinWidth="0"
                                        DockPanel.Dock="Top"/>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <local:FZMaterial Grid.RowSpan="2" Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}"/>
                                    <Decorator Grid.Row="0" Margin="30,25">
                                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_Body}"
                                            Color="{StaticResource H_Color_Primary_White}"
                                            FontSize="22"
                                            Text="{Binding SelectedItem.Description, ElementName=PART_RadioTrackList}"
                                            TextWrapping="Wrap"/>
                                    </Decorator>
                                    <Decorator Grid.Row="1">
                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RadioStationIcon}"/>
                                    </Decorator>
                                </Grid>
                            </DockPanel>
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
    </Grid>
</Page>
