<Page x:Class="ForzaUI.Scenes.Anthem.A_MyHorizonLife"
      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" 
      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>
        <System:Double x:Key="A_Double_FullScreenCarousel_2ItemsHigh_ListItemWidthScale">-1</System:Double>
        <System:Double x:Key="A_Double_FullScreenCarousel_2ItemsHigh_ListItemWidthOffset">573</System:Double>
        <System:Double x:Key="A_Double_FullScreenCarousel_2ItemsHigh_ListItemWidth">240</System:Double>
        <System:Double x:Key="A_Double_FullScreenCarousel_2ItemsHigh_ListItemHeight">325</System:Double>
        <System:Double x:Key="A_Double_FullScreenCarousel_2ItemsHigh_ListHeight">660</System:Double>

        <ControlTemplate x:Key="A_ControlTemplate_FullScreenCarousel_2ItemsHigh" TargetType="{x:Type local:CommonListBox}">
            <local:VirtualizingWrapPanel IsItemsHost="True"
                                         ScrollOrientation="Horizontal"
                                         ItemWidth="{StaticResource A_Double_FullScreenCarousel_2ItemsHigh_ListItemWidth}"
                                         ItemHeight="{StaticResource A_Double_FullScreenCarousel_2ItemsHigh_ListItemHeight}"
                                         EmptyItemStyle="{StaticResource A_Style_Control_Carousel_EmptyItemStyle}"
                                         SeparatorItemStyle="{StaticResource A_Style_ListBoxItem_FullScreenCarousel_SeparatorItemStyle}"
                                         SeparatorPlacement="{Binding SeparatorPlacementFunc, RelativeSource={RelativeSource AncestorType=Page}}"
                                         SelectionLimitTop="{StaticResource A_Double_FullScreenCarousel_2ItemsHigh_ListItemWidthOffset}"
                                         Style="{StaticResource A_VirtualizingWrapPanel_Default}">
                <local:VirtualizingWrapPanel.RenderTransform>
                    <TranslateTransform X="{Binding Path=(local:BlendValue.Output), RelativeSource={RelativeSource AncestorType=VirtualizingWrapPanel}}" />
                </local:VirtualizingWrapPanel.RenderTransform>
            </local:VirtualizingWrapPanel>
        </ControlTemplate>

        <Style x:Key="A_Style_CommonListBox_FullScreenCarousel_2ItemsHigh"
               TargetType="{x:Type local:CommonListBox}">
            <Setter Property="Template"
                    Value="{StaticResource A_ControlTemplate_FullScreenCarousel_2ItemsHigh}" />
            <Setter Property="VerticalAlignment" 
                    Value="Center" />
            <Setter Property="HorizontalAlignment" 
                    Value="Center" />
            <Setter Property="ItemContainerStyle"
                    Value="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle}" />
            <Setter Property="ScrollViewer.CanContentScroll" 
                    Value="False" />
            <Setter Property="Height" 
                    Value="{StaticResource A_Double_FullScreenCarousel_ListHeight}" />
            <Setter Property="Margin" 
                    Value="-93,0,0,-7" />
            <Setter Property="Width"
                    Value="{Binding Width, RelativeSource={RelativeSource AncestorType=Page}}" />
        </Style>

        <Style x:Key="A_Style_FZRun_ToNextTierMessage_INFLUENCE"
               TargetType="{x:Type local:FZRun}">
            <Setter Property="FontFamily" Value="Horizon_A" />
            <Setter Property="CapHeight" Value="36" />
        </Style>

        <Style x:Key="A_Style_FZRun_ToNextTierMessage_TIER"
               TargetType="{x:Type local:FZRun}">
            <Setter Property="FontFamily" Value="Horizon_C" />
            <Setter Property="CapHeight" Value="15" />
        </Style>

        <TextWrapping x:Key="A_TextWrapping_ToNextTierMessage">NoWrap</TextWrapping>
        <TextWrapping x:Key="A_TextWrapping_ToNextTierMessage_DE">Wrap</TextWrapping>

        <Style x:Key="A_Style_FZTextBlock_ToNextTierMessage"
               TargetType="{x:Type local:FZTextBlock}">
            <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding ToNextTierMessage}" />
            <Setter Property="local:TextBlockInlineMarkup.ResourceBaseName" Value="A_Style_FZRun_ToNextTierMessage_" />
            <Setter Property="FontFamily" Value="Horizon_C" />
            <Setter Property="CapHeight" Value="14" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="Color" Value="#FFFFFF" />
            <Setter Property="TextWrapping" Value="{local:LocalizedResource A_TextWrapping_ToNextTierMessage}" />
        </Style>

        <Style x:Key="A_Style_FZRun_ProgressDescription_SMALL"
               TargetType="{x:Type local:FZRun}">
            <Setter Property="FontFamily" Value="Horizon_C" />
            <Setter Property="CapHeight" Value="14" />
        </Style>

        <TextWrapping x:Key="A_TextWrapping_ProgressDescription">Wrap</TextWrapping>
        <TextWrapping x:Key="A_TextWrapping_ProgressDescription_DE">WrapWithOverflow</TextWrapping>

        <Style x:Key="A_Style_FZTextBlock_ProgressDescription"
               TargetType="{x:Type local:FZTextBlock}"
               BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
            <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding ProgressDescription, Converter={StaticResource A_StringToUpper}}" />
            <Setter Property="local:TextBlockInlineMarkup.ResourceBaseName" Value="A_Style_FZRun_ProgressDescription_" />
            <Setter Property="CapHeight" Value="35" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="Color" Value="#FFFFFF" />
            <Setter Property="TextWrapping" Value="{local:LocalizedResource A_TextWrapping_ProgressDescription}" />
            <Setter Property="LineAdjust" Value="-0.25"/>
        </Style>

        <Style x:Key="A_Style_FZTextBlock_ProgressDescription_Locked"
               TargetType="{x:Type local:FZTextBlock}"
               BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
            <Setter Property="local:TextBlockInlineMarkup.Markup" Value="{Binding LockedReason, Converter={StaticResource A_StringToUpper}}" />
            <Setter Property="local:TextBlockInlineMarkup.ResourceBaseName" Value="A_Style_FZRun_ProgressDescription_" />
            <Setter Property="CapHeight" Value="35" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="Color" Value="#FFFFFF" />
            <Setter Property="TextWrapping" Value="{local:LocalizedResource A_TextWrapping_ProgressDescription}" />
            <Setter Property="LineAdjust" Value="-0.25"/>
        </Style>

        <DataTemplate x:Key="A_DataTemplate_HorizonLifeItem">
            <Control Template="{StaticResource A_ControlTemplate_HorizonLifeItem}" />
        </DataTemplate>

        <Style x:Key="A_Style_ControllerButtonControl_HorizonLife_A_Button" TargetType="local:ControllerButtonControl" BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
            <Setter Property="Description" Value="{local:Loc HelpButtons.IDS_ViewObjectives}"/>
            <Setter Property="Visibility" Value="Collapsed"/>
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsObjectiveViewEnabled}" Value="True" />
                        <Condition Binding="{Binding SelectedItem.IsLocked}" Value="False"/>
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Visibility" Value="Visible" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>

        <local:MultiConverter x:Key="A_Converter_ThreadTitleToKingOfActivation">
            <local:MultiConverterEntry Converter="{StaticResource A_Converter_StringFormatConverter}"
                                       Parameter="{local:Loc TiledMenus.IDS_MyHorizonLife_EnableKingOfSeriesMessage}" />
            <local:MultiConverterEntry Converter="{StaticResource A_StringToUpper}" />
        </local:MultiConverter>

        <Style x:Key="A_Style_ControllerButtonControl_HorizonLife_X_Button" TargetType="local:ControllerButtonControl" BasedOn="{StaticResource A_Style_ControllerButtonControl_Default}">
            <Setter Property="Description" Value="{local:Loc HelpButtons.IDS_ViewOnMap}" />
            <Setter Property="Visibility" Value="Collapsed"/>
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsVisitMapEnabled}" Value="True" />
                        <Condition Binding="{Binding SelectedItem.CanViewOnMap}" Value="True" />
                        <Condition Binding="{Binding SelectedItem.IsLocked}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Visibility" Value="Visible" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>


        <Style x:Key="A_Style_FrameworkElement_VisibleIfCanUnlockKingOfSeries"
               TargetType="FrameworkElement">
            <Setter Property="Visibility" Value="Collapsed"/>
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Progress.KingOfSeriesReadyForUnlock}" Value="True" />
                        <Condition Binding="{Binding IsVisitMapEnabled, RelativeSource={RelativeSource AncestorType=Page}}" Value="True" />
                        <Condition Binding="{Binding IsLocked}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Visibility" Value="Visible" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_FrameworkElement_CollapsedIfCanUnlockKingOfSeries"
               TargetType="FrameworkElement">
            <Setter Property="Visibility" Value="Visible" />
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding Progress.KingOfSeriesReadyForUnlock}" Value="True" />
                        <Condition Binding="{Binding IsVisitMapEnabled, RelativeSource={RelativeSource AncestorType=Page}}" Value="True" />
                        <Condition Binding="{Binding IsLocked}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Visibility" Value="Collapsed"/>
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>

        <!--Used to toggle the progress states in theleft panel via the thread progress values -->
        <local:MappingConverter x:Key="A_Converter_Progress_NextTier_Influence_To_Visibility" Default="Collapsed">
            <local:MappingConverterEntry Key="0" Value="Visible"/>
        </local:MappingConverter>
        <local:MappingConverter x:Key="A_Converter_Progress_NextTier_Influence_To_Visibility_Inverse" Default="Visible">
            <local:MappingConverterEntry Key="0" Value="Collapsed"/>
        </local:MappingConverter>

        <!--Life specific glass side panel -->
        <Style x:Key="A_ControlTemplate_SidePanel_HorizonLife" TargetType="ContentControl">
            <Style.Resources>
                <local:FZMaterialPresetGlassRoundtangle x:Key="A_FZMaterialPresetGlassRoundtangle_GlassPanel_HorizonLife"
                        BasedOn="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Base}"
                        BlurAmount="High"
                        CornerRadius="{StaticResource A_CornerRadius_Outer_Bottom}"/>
                
                <ControlTemplate x:Key="A_ControlTemplate_SidePanelContent" TargetType="ContentControl">
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}" Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_HorizonLife}">
                        <ContentPresenter/>
                    </local:FZMaterial>
                </ControlTemplate>
            </Style.Resources>
            <Setter Property="Template" Value="{StaticResource A_ControlTemplate_SidePanel}"/>
        </Style>

        <Style x:Key="A_Style_FZMaterial_Thread_Footer" TargetType="local:FZMaterial">
            <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterBottomOnly}"/>
            <Setter Property="Color" Value="{Binding Progress.ThreadName, Converter={StaticResource A_Converter_InfluenceThreadIdToColor}}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsLocked}" Value="True">
                    <Setter Property="Color" Value="{StaticResource A_Color_Tile_Background_Locked}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="A_Style_Textblock_Thread_Footer" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_HorizonA}">
            <Setter Property="Text" Value="{Binding Progress.Tier, Converter={StaticResource A_Converter_TierToString}}"/>
            <Setter Property="Color" Value="#FFFFFF"/>
            <Setter Property="CapHeight" Value="32"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding IsLocked}" Value="True">
                    <Setter Property="Text" Value="{local:Loc TiledMenus.IDS_MyHorizonLife_ThreadLocked}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Page.Resources>

    <Grid>
        <local:MappingConverterResourcePreloader Converter="{StaticResource A_Converter_RewardTypeToIcon}" ValueType="BitmapImage" />
        <local:MappingConverterResourcePreloader Converter="{StaticResource A_Converter_ThreadNameToMyHorizonLifeIcon}" ValueType="BitmapImage" />
        <local:MappingConverterResourcePreloader Converter="{StaticResource A_Converter_ThreadNameToThreadIcon}" ValueType="BitmapImage" />

       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <!-- Bars -->
        <local:PlayerBarControl Style="{StaticResource A_Style_PlayerBarControl_WithTokens}"
                                x:Name="TopBar" />

        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        x:Name="BottomBar">
            <local:ControllerButtonPanel x:Name="HelpPanel"
                                         Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <local:ControllerButtonControl Button="A"
                                               Style="{StaticResource A_Style_ControllerButtonControl_HorizonLife_A_Button}"/>
                <local:ControllerButtonControl Button="B"
                                               Description="{local:Loc HelpButtons.IDS_Back}" />
                <local:ControllerButtonControl Button="X"
                                               Style="{StaticResource A_Style_ControllerButtonControl_HorizonLife_X_Button}"/>
            </local:ControllerButtonPanel>
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding_Opus}">
            <StackPanel VerticalAlignment="Bottom"
                Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                <Decorator HorizontalAlignment="Left"
                           VerticalAlignment="Top">
                    <ContentControl Content="{local:Loc ScreenTitles.IDS_MyHorizonLife}"
                                    local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/MyHorizonLife.png"
                                    Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                    x:Name="TitleBlock" />
                </Decorator>
                <Grid>
                    <local:CommonListBox ItemTemplate="{StaticResource A_DataTemplate_HorizonLifeItem}"
                                         Style="{StaticResource A_Style_CommonListBox_FullScreenCarousel_2ItemsHigh}"
                                         SelectedItem="{Binding SelectedItem}"
                                         ItemsSource="{Binding Collection}"
                                         x:Name="Items"
                                         local:FocusOnPageFocusGained.SelectorSelectedItem="True" />
                    <Grid DataContext="{Binding SelectedItem, ElementName=Items}"
                          HorizontalAlignment="Left"
                          VerticalAlignment="Center">
                        <local:FZMaterialGlassCapture />
                        <ContentControl DockPanel.Dock="Left"
                                        Tag="{Binding Title}"
                                        Style="{StaticResource A_ControlTemplate_SidePanel_HorizonLife}"
                                        Width="409"
                                        Height="700">
                            <DockPanel>
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Thread_Footer}"
                                                  DockPanel.Dock="Bottom"
                                                  MinHeight="78">
                                    <Grid HorizontalAlignment="Center"
                                          VerticalAlignment="Center">
                                        <StackPanel Orientation="Horizontal" Style="{StaticResource A_Style_FrameworkElement_CollapsedIfCanUnlockKingOfSeries}">
                                            <local:FZTextBlock Style="{StaticResource A_Style_Textblock_Thread_Footer}" Margin="23,23,23,23"
                                                                Effect="{StaticResource A_Effect_HighContrastModeDropShadow}" />
                                            <local:FZMaterial Visibility="{Binding IsLocked, Converter={StaticResource A_FZBooleanToVisibilityConverter}}" Margin="-20,0,0,0"
                                                              ImageSource="/ForzaUI;component/Textures/Anthem/Icons/Pad_Lock.png" Color="#FFFFFF" Width="36" Height="36" Stretch="Uniform"/>
                                        </StackPanel>
                                    </Grid>
                                </local:FZMaterial>
                                <DockPanel>
                                    <Decorator x:Name="ProgressText" DockPanel.Dock="Top" 
                                               Height="215"
                                               Visibility="{Binding Progress.InfluenceToNextTier, Converter={StaticResource A_Converter_Progress_NextTier_Influence_To_Visibility_Inverse}}"
                                               VerticalAlignment="Bottom">
                                        <Grid>
                                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_ProgressDescription}"
                                                           Margin="25,0,25,25" Visibility="{Binding IsLocked, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"
                                                           VerticalAlignment="Center" />
                                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_ProgressDescription_Locked}"
                                                           Margin="25,0,25,0" Visibility="{Binding IsLocked, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                                                           VerticalAlignment="Center" />
                                        </Grid>
                                    </Decorator>
                                    
                                    <Grid x:Name="CompletionText" DockPanel.Dock="Top"
                                          Visibility="{Binding Progress.InfluenceToNextTier, Converter={StaticResource A_Converter_Progress_NextTier_Influence_To_Visibility}}"
                                          Height="250"
                                          Margin="25,25,25,25">
                                        <StackPanel  Orientation="Vertical" VerticalAlignment="Center">
                                            <local:FZTextBlock Text="{local:Loc TiledMenus.IDS_MyHorizonLife_CompletedThreadProgress}"
                                                               CapHeight="18"
                                                               FontFamily="Horizon_C"
                                                               TextAlignment="Center"
                                                               Color="#FFFFFF"
                                                               TextWrapping="Wrap"
                                                               VerticalAlignment="Top" />
                                            <Decorator Height="32"/>
                                            <local:FZTextBlock Text="{Binding Title, Converter={StaticResource A_StringToUpper}}"
                                                               CapHeight="35"
                                                               TextAlignment="Center"
                                                               Color="#FFFFFF"
                                                               TextWrapping="Wrap"
                                                               VerticalAlignment="Bottom" />
                                        </StackPanel>
                                    </Grid>
                                    <local:FZMaterial Color="#80FFFFFF"
                                                      DockPanel.Dock="Top"
                                                      Height="2" />
                                    <Decorator Visibility="{Binding IsLocked, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                                        <DockPanel Margin="25,25,25,0" Visibility="{Binding Progress.InfluenceToNextTier, Converter={StaticResource A_Converter_Progress_NextTier_Influence_To_Visibility_Inverse}}">
                                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_ToNextTierMessage}"
                                                           DockPanel.Dock="Top" />
                                            <Decorator Height="15" DockPanel.Dock="Top" />
                                            <ItemsControl ItemsSource="{Binding Rewards}"
                                                      ItemTemplate="{StaticResource A_DataTemplate_SmallReward}"
                                                      Focusable="False"
                                                      VerticalAlignment="Center" />
                                        </DockPanel>
                                    </Decorator>
                                    <Grid x:Name="ThreadGraphic" Visibility="{Binding Progress.InfluenceToNextTier, Converter={StaticResource A_Converter_Progress_NextTier_Influence_To_Visibility}}">
                                        <Control Template="{StaticResource A_ControlTemplate_InfluenceProgress}" DataContext="{Binding Progress}">
                                            <Control.Resources>
                                                <Style x:Key="A_Style_FZMaterial_ThreadColorMaterial_Dynamic" TargetType="local:FZMaterial">
                                                    <Setter Property="Color" Value="#00FFFFFF"/>
                                                </Style>
                                            </Control.Resources>
                                        </Control>
                                    </Grid>
                                </DockPanel>
                            </DockPanel>
                        </ContentControl>
                    </Grid>

                    <local:NavigationArrows Style="{StaticResource A_Style_Control_NavigationArrows}"
                                            Margin="-40,0,-20,0"
                                            CanSelectPrev="{Binding CanSelectPrev, ElementName=Items}"
                                            CanSelectNext="{Binding CanSelectNext, ElementName=Items}"
                                            ScrollPagePrevCommand="{Binding ScrollPagePrevCommand, ElementName=Items}"
                                            ScrollPageNextCommand="{Binding ScrollPageNextCommand, ElementName=Items}" />
                </Grid>
            </StackPanel>
        </Border>
    </Grid>
</Page>
