<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="Hidden"/>
                <Setter Property="IsHitTestVisible" Value="True"/>
                <Style.Triggers>
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType=ListBoxItem}}" Value="True"/>
                            <Condition Binding="{Binding IsPlaying}" Value="False"/>
                        </MultiDataTrigger.Conditions>
                        <Setter Property="Visibility" Value="Visible"/>
                    </MultiDataTrigger>

                    <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>

            <local:MappingConverter x:Key="A_Converter_SelectedBoolToColor"
                            Default="">
                <local:MappingConverterEntry Key="True" Value="#FFFFFF"/>
                <local:MappingConverterEntry Key="False" Value="#959595"/>
            </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="{StaticResource A_Style_FZTextBlock_SpinnerTitle}"
                                           Margin="20,0,10,0"
                                           IsHitTestVisible="False"
                                           Grid.Column="0"
                                           Color="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource A_Converter_SelectedBoolToColor}}"
                                           FontFamily="Horizon_A"/>
                    <local:FZTextBlock Text="{Binding Artist}"
                                           Style="{StaticResource A_Style_FZTextBlock_SpinnerItem}"
                                           IsHitTestVisible="False"
                                           Grid.Column="1"
                                           Color="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}, Converter={StaticResource A_Converter_SelectedBoolToColor}}"
                                           TextAlignment="Left"
                                           FontFamily="Horizon_B"/>
                    <Grid Grid.Column="2" Margin="10,0,20,0">
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_MusicSelectPreview}"
                                              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"/>
                        <local:FZButton x:Name="PreviewButton"
                                        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="39"
                                                           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="10"/>
                <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="Timeless FM">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Anthem/HUD/RadioLogos/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/HUD/RadioLogos/Hospital_Records.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding SelectedItem.StationName, ElementName=PART_RadioStationList}" Value="Radio Awesome">
                        <Setter Property="ImageSource" Value="/ForzaUI;component/Textures/Data_Bound/PDLC2/RadioStations/Radio_Awesome.png" />
                        <Setter Property="Visibility" Value="Visible"/>
                    </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}">
                            <DockPanel Grid.Row="0" Width="426" DockPanel.Dock="Right">
                                <ContentControl Style="{StaticResource A_Style_ContentControl_Header}"
                                                    Content="{local:Loc Main.IDS_Description}"
                                                    DockPanel.Dock="Top"/>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="350" />
                                        <RowDefinition Height="*" />
                                    </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="#FFFFFF"
                                                               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>

                            <Grid Width="1040" Margin="0,0,6,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="663"/>
                            </Grid>
                        </DockPanel>
                    </StackPanel>
                </Grid>
            </Border>
        </Grid>
    </Grid>
</Page>
