<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_UpgradeBasket"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      >

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

    <Page.Resources>
        <ResourceDictionary>
            <local:LinearTransformConverter x:Key="A_LinearTransformConverter_ItemIndexOffset" Add="1" />

            <DataTemplate x:Key="A_DataTemplate_ListBoxItem_BasketItem">
                <Grid Height="{StaticResource A_Double_TextMenu_Height_Default}">
                    <StackPanel Orientation="Horizontal">
                        <Grid>
                            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_Pill_NonInteractive}"
                                              Width="{StaticResource A_Size_ColumnWidthSmall}"
                                              x:Name="Index"
                                              Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterLeftOnly}" />

                            <local:FZTextBlock Tag="{Binding Path=(ItemsControl.AlternationIndex), RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}, Converter={StaticResource A_LinearTransformConverter_ItemIndexOffset}}"
                                               Text="{Binding Tag, RelativeSource={RelativeSource Self}, Converter={StaticResource A_NumUnitConverter_Min2Digits_0dp}}"
                                               Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                                               Color="{StaticResource A_Color_TextMenu_Text_Highlighted}"
                                               FontFamily="Horizon_C"
                                               HorizontalAlignment="Center" />
                        </Grid>
                        <local:FZTextBlock Text="{Binding Text}"
                                           Margin="20,0"
                                           Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                                           HorizontalAlignment="Left" />
                    </StackPanel>

                    <local:FZTextBlock Text="{Binding CreditCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_ShowUnit_0dp}, FallbackValue=0}"
                                       Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                                       HorizontalAlignment="Right"
                                       Margin="20,0" />
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Path=(Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                             Value="True">
                        <Setter Property="Visibility"
                                Value="Hidden"
                                TargetName="Index" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_Row"
                             TargetType="ListBoxItem">
                <Grid>
                    <ContentControl Style="{StaticResource A_Style_ContentControl_SelectableRow}">
                        <ContentPresenter />
                    </ContentControl>
                </Grid>
            </ControlTemplate>

            <Style x:Key="A_Style_ListBoxItem_BasketItem"
                   BasedOn="{StaticResource A_Style_ListBoxItem_TextMenu}"
                   TargetType="ListBoxItem">
                <Setter Property="Template"
                        Value="{StaticResource A_ControlTemplate_Row}" />
                <Setter Property="Visibility"
                        Value="Visible" />
                <Setter Property="local:FocusOnMouseOverBehaviour.Self"
                        Value="True" />
                <Setter Property="local:SetSelectedOnMouseOverBehaviour.Self"
                        Value="True" />
            </Style>
        </ResourceDictionary>

        <Style x:Key="A_Style_FZTextBlock_BasketSummary"
               BasedOn="{StaticResource A_Style_FZTextBlock_OptionText}"
               TargetType="local:FZTextBlock">
            <Setter Property="Margin"
                    Value="0,0" />
            <Setter Property="FontFamily"
                    Value="Horizon_C" />
            <Setter Property="Color"
                    Value="{StaticResource A_Color_TextMenu_Text_Highlighted}" />
        </Style>
    </Page.Resources>

    <Grid>
        <Grid>
            <!-- Background Blur -->
            <local:FZMaterialGlassCapture />
            <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Popup_Background}"/>

            <!-- Help Button Bar -->
            <ContentControl x:Name="BottomBar"
                            Style="{StaticResource A_Style_ButtonBar}">
                <ContentControl x:Name="DefaultHelpPanel"
                                local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Goto}"
                                local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                                local:ControllerButtonPanel.StartDescription="{local:Loc HelpButtons.IDS_CheckOutNow}"
                                Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
            </ContentControl>
        </Grid>

        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}"
              Focusable="False">
            <StackPanel x:Name="MainContent"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">

                <ContentControl Content="{local:Loc ScreenTitles.IDS_BasketItems}"
                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Garage/Basket.png"
                                HorizontalAlignment="Left" />
                <StackPanel Width="1026" DataContext="{Binding Basket}">
                    <local:CommonListBox x:Name="PART_Menu"
                                         Style="{StaticResource A_Style_ListBox_TextMenu_Default}"
                                         ItemContainerStyle="{StaticResource A_Style_ListBoxItem_BasketItem}"
                                         ItemTemplate="{StaticResource A_DataTemplate_ListBoxItem_BasketItem}"
                                         ItemsSource="{Binding BasketItems}"
                                         AlternationCount="10000"
                                         DockPanel.Dock="Top"
                                         Height="612" />

                    <local:FZMaterial Height="{StaticResource A_Size_FooterRowHeight}"
                                      Style="{StaticResource A_Style_FZMaterial_FlatPanel_Tile}"
                                      Color="{StaticResource A_Color_TextMenu_Panel_Header}">
                        <Grid Margin="20,0">
                            <local:FZTextBlock Text="{local:Loc Upgrades_flow.IDS_BasketItemsTotal}"
                                               Style="{StaticResource A_Style_FZTextBlock_BasketSummary}"
                                               FontFamily="Horizon_C" />
                            <StackPanel Orientation="Horizontal"
                                        HorizontalAlignment="Right">
                                <local:FZTextBlock Text="{Binding TotalCreditCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_ShowUnit_0dp}, FallbackValue=0}"
                                                   Style="{StaticResource A_Style_FZTextBlock_BasketSummary}" />
                                <StackPanel Orientation="Horizontal"
                                            Visibility="{Binding AreTokensEnabled, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                                    <local:FZTextBlock Text="/"
                                                       Style="{StaticResource A_Style_FZTextBlock_BasketSummary}"
                                                       Margin="6,0,6,0" />
                                    <local:FZTextBlock Text="{Binding TotalTokenCost, ConverterParameter=tokenmoney, Converter={StaticResource A_NumUnitConverter_ShowUnit_0dp}, FallbackValue=0}"
                                                       Style="{StaticResource A_Style_FZTextBlock_BasketSummary}" />
                                </StackPanel>
                            </StackPanel>
                        </Grid>
                    </local:FZMaterial>
                </StackPanel>
            </StackPanel>
        </Grid>
    </Grid>
</Page>
