<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>
            <Style x:Key="A_Style_Button_MusicSelectPreview"
                   TargetType="{x:Type local:FZButton}"
                   BasedOn="{StaticResource A_Style_Button_SpinnerArrowButton}">
                <Setter Property="Visibility" Value="Visible"/>
                <Setter Property="IsHitTestVisible" Value="True"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsPlaying}" Value="True">
                        <Setter Property="Visibility" Value="Hidden"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding CanBePreviewed}" Value="False">
                        <Setter Property="Visibility" Value="Hidden"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsControllerActiveInput, RelativeSource={RelativeSource AncestorType=Page}}" Value="True">
                        <Setter Property="Visibility" Value="Hidden"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZMaterial_MusicSelectPreview"
                   TargetType="{x:Type local:FZMaterial}">
                   <Setter Property="Color" Value="{StaticResource A_Color_Spinner_ArrowUnselected}"/>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=Button}}" Value="True">
                        <Setter Property="Color" Value="{StaticResource A_Color_Spinner_ArrowSelected}"/>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_ListBoxItem_RadioTrack">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <local:FZTextBlock Text="{Binding Title}"
                                           Style="{StaticResource A_Style_FZTextBlock_SpinnerTitle}"
                                           Margin="0,0,10,0"
                                           IsHitTestVisible="False"
                                           Grid.Column="0"/>
                        <local:FZTextBlock Text="{Binding Artist}"
                                           Style="{StaticResource A_Style_FZTextBlock_SpinnerItem}"
                                           IsHitTestVisible="False"
                                           Grid.Column="1"/>
                        <Grid Grid.Column="2">
                            <local:FZMaterial Width="32"
                                              Height="32"
                                              Color="{StaticResource A_Color_Opaque_Highlight}"
                                              VerticalAlignment="Center"
                                              ImageSource="/ForzaUI;component/Textures/Anthem/Icons/music_playing_icon.png"
                                              Visibility="{Binding IsPlaying, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}"
                                              IsHitTestVisible="False"/>
                            <local:FZButton Command="{Binding PreviewSelectedCommand, RelativeSource={RelativeSource AncestorType=Page}}"
                                    Style="{StaticResource A_Style_Button_MusicSelectPreview}">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_MusicSelectPreview}"
                                                  Width="32"
                                                  Height="32"
                                                  VerticalAlignment="Center"
                                                  ImageSource="/ForzaUI;component/Textures/Anthem/Icons/music_play_preview_icon.png"/>
                            </local:FZButton>
                        </Grid>
                    </Grid>
            </DataTemplate>

            <Style TargetType="ContentControl"
                   x:Key="A_Style_ContentControl_RadioStation_TabBarItem">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ContentControl">
                            <Grid>
                                <local:RoutedEventCommand x:Name="MouseSelectGroupRoutedEventCommand"
                                                          RoutedEvent="UIElement.MouseLeftButtonUp"
                                                          Command="{Binding MouseSelectGroupCommand, RelativeSource={RelativeSource AncestorType=Page}}" />
                                <local:FZButton Content="{Binding Title, Converter={StaticResource A_StringToUpper}}"
                                        Style="{StaticResource A_Style_ContentControl_TabTitle_Default}"
                                        local:RoutedEventCommand.Action="{Binding ElementName=MouseSelectGroupRoutedEventCommand}"
                                        OnClickSoundName="/Master/UI/PauseMenu/HZ2_SFX_UI_PauseMenu_ChangeTab_01" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="{x:Type local:ItemsSelector}"
                   x:Key="A_Style_Carousel3ItemList_TabBar">
                <Setter Property="FocusVisualStyle"
                        Value="{StaticResource A_Style_BlankVisualStyle}" />
                <Setter Property="IsTabStop"
                        Value="True" />
                <Setter Property="ClipToBounds"
                        Value="True" />
                <Setter Property="Width"
                        Value="864" />
                <Setter Property="Height"
                        Value="50" />
                <Setter Property="PageSize"
                        Value="1" />
                <Setter Property="ItemContainerStyle"
                        Value="{StaticResource A_Style_ContentControl_RadioStation_TabBarItem}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <local:VirtualizingScrollPanel Style="{StaticResource A_Style_VirtualizingScrollPanel_MotionBlurScrollPanel_TabTitle}"
                                                           ItemHeight="40"
                                                           ItemWidth="288"
                                                           Margin="0,0,0,0"
                                                           Padding="288,0,0,0" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <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/Icons/RadioStations/RadioIcon_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/Icons/RadioStations/RadioIcon_Bass.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/Icons/RadioStations/RadioIcon_Pulse.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Timeless FM">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/Icons/RadioStations/RadioIcon_Timeless.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/Icons/RadioStations/RadioIcon_Hospital.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Vagrant Records">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/Icons/RadioStations/RadioIcon_Vagrant.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Epitaph Records">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/Icons/RadioStations/RadioIcon_Epitaph.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Future Classic">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/Icons/RadioStations/RadioIcon_FutureClassic.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger> 
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="E3">
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Page.Resources>

    <Grid>
        <!-- Background Blur -->
        <Control Template="{StaticResource A_ControlTemplate_Blueprint_Background}"/>
        
        <!-- Bars -->
        <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_Select}"
                            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="LayoutRoot">
            <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}">
                <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}">
                    <StackPanel Orientation="Vertical"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Margin="-4,-34,0,0">
                        <!-- 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">
                            <local:FZButton VerticalAlignment="Top"
                                    Style="{StaticResource A_Style_Button_TabTitleLB_CarSelect}"
                                    Command="{Binding ScrollPagePrevCommand, ElementName=PART_RadioStationList}"
                                    IsEnabled="{Binding CanSelectPrev, ElementName=PART_RadioStationList}" />
                            <local:ItemsSelector x:Name="PART_RadioStationList"
                                                 Style="{StaticResource A_Style_Carousel3ItemList_TabBar}"
                                                 Focusable="False"
                                                 ItemsSource="{Binding RadioStations}"/>
                            <local:FZButton VerticalAlignment="Top"
                                    Style="{StaticResource A_Style_Button_TabTitleRB_CarSelect}"
                                    Command="{Binding ScrollPageNextCommand, ElementName=PART_RadioStationList}"
                                    IsEnabled="{Binding CanSelectNext, ElementName=PART_RadioStationList}" />
                        </StackPanel>

                        <DockPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}">
                            <Grid Width="426" DockPanel.Dock="Right">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="350" />
                                    <RowDefinition Height="5" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>

                                <DockPanel Grid.Row="0">
                                    <ContentControl Style="{StaticResource A_Style_ContentControl_Header}"
                                                    Content="{local:Loc Main.IDS_Description}"
                                                    DockPanel.Dock="Top"/>
                                    <Grid>
                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}"/>
                                        <Decorator Margin="30,25">
                                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_Body}"
                                                               Color="{StaticResource A_Color_Tile_Text_Alternate}"
                                                               FontSize="22"
                                                               Text="{Binding SelectedItem.Description, ElementName=PART_RadioTrackList}"
                                                               TextWrapping="Wrap"/>
                                        </Decorator>
                                    </Grid>
                                </DockPanel>

                                <Decorator Grid.Row="2">
                                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_AcrylicPanel_BodyPanel}">
                                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_RadioStationIcon}"/>
                                    </local:FZMaterial>
                                </Decorator>
                            </Grid>

                            <Grid Width="962" Margin="0,0,37,0">
                                <local:CommonListBox x:Name="PART_RadioTrackList"
                                                     KeyboardNavigation.DirectionalNavigation="Contained"
                                                     Style="{StaticResource A_Style_ListBox_List_Default_ScrollBar}"
                                                     ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_Default}"
                                                     ItemTemplate="{StaticResource A_DataTemplate_ListBoxItem_RadioTrack}"
                                                     ItemsSource="{Binding SelectedItem.RadioTracks, ElementName=PART_RadioStationList}"
                                                     Height="636"/>
                            </Grid>
                        </DockPanel>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
    </Grid>
</Page>
