<Page 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:local="clr-namespace:ForzaUI"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      mc:Ignorable="d"
      x:Class="ForzaUI.Scenes.Anthem.DLCUpsell"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">
  <Page.Resources>
    <Style x:Key="A_Style_FZMaterial_UpsellBackground"
           TargetType="local:FZMaterial">
      <Style.Setters>
        <Setter Property="Stretch"
                Value="UniformToFill" />
        <Setter Property="MinWidth"
                Value="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Page}}" />
        <Setter Property="MinHeight"
                Value="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Page}}" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="HorizontalAlignment"
                Value="Center" />
      </Style.Setters>
    </Style>
    <DataTemplate x:Key="A_DataTemplate_TextMenu_Upsell">
      <Grid IsHitTestVisible="False"
            Height="{StaticResource A_Double_TextMenu_Height_Default}">
        <DockPanel LastChildFill="True">
            <local:FZTextBlock local:TextBlockInlineMarkup.Markup="{Binding Subext}"
                               local:TextBlockInlineMarkup.ResourceBaseName="A_Style_Run_TextMenu_"
                               Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                               Color="{StaticResource A_Color_Opaque_Highlight}"
                               DockPanel.Dock="Right" />
            <local:FZTextBlock local:TextBlockInlineMarkup.Markup="{Binding Text}"
                               local:TextBlockInlineMarkup.ResourceBaseName="A_Style_Run_TextMenu_"
                               Style="{StaticResource A_Style_FZTextBlock_OptionText}" />
        </DockPanel>
      </Grid>
    </DataTemplate>
    <local:UIStoryboard x:Key="A_Storyboard_ExpansionUpsell_BlendValueInputChanged">
      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CurrentImage"
                                     FillBehavior="Stop"
                                     Storyboard.TargetProperty="Tag">
        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                Value="1" />
        <EasingDoubleKeyFrame KeyTime="0:0:1.8"
                              Value="0">
          <EasingDoubleKeyFrame.EasingFunction>
            <QuarticEase EasingMode="EaseInOut" />
          </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
      </DoubleAnimationUsingKeyFrames>
      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="LastImage"
                                     FillBehavior="Stop"
                                     Storyboard.TargetProperty="Tag">
        <DiscreteDoubleKeyFrame KeyTime="0:0:0"
                                Value="0" />
        <EasingDoubleKeyFrame KeyTime="0:0:1.8"
                              Value="1">
          <EasingDoubleKeyFrame.EasingFunction>
            <QuarticEase EasingMode="EaseInOut" />
          </EasingDoubleKeyFrame.EasingFunction>
        </EasingDoubleKeyFrame>
      </DoubleAnimationUsingKeyFrames>
    </local:UIStoryboard>

    <Style x:Key="A_Style_AutoScrollPanel_ExpansionUpsell"
        BasedOn="{StaticResource A_Style_AutoScrollPanel_Masked}"
        TargetType="local:AutoScrollPanel">
        <Style.Resources>
            <ControlTemplate x:Key="A_ControlTemplate_AutoscrollTemplate_Dynamic">
                <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_DescriptionBlockBody}"
                                   Text="{Binding Description}"
                                   TextWrapping="Wrap" />
            </ControlTemplate>
        </Style.Resources>
    </Style>

  </Page.Resources>

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

  <Grid x:Name="LayoutRoot"
        Style="{StaticResource A_Style_FrameworkElement_FadeOnlyTransition_0}"
        local:BlendValue.InputChangedStoryboard="{StaticResource A_Storyboard_ExpansionUpsell_BlendValueInputChanged}"
        local:BlendValue.ShouldSkipInitialInputChange="True"
        local:BlendValue.Input="{Binding CurrentImage}">

    <!-- Static current image prevents AA gaps from appearing around the edges during animation -->
    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_UpsellBackground}"
                      ImageSource="{Binding CurrentImage}" />
                      
    <ContentControl Style="{StaticResource A_Style_ContentControl_AnimatedTagSlideFromLeft}"
                    local:UIPageTransitionManager.TransitionIndex="0"
                    x:Name="LastImage">
      <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_UpsellBackground}"
                        ImageSource="{Binding LastImage}"
                        ClipToBounds="True" />
    </ContentControl>

    <ContentControl Style="{StaticResource A_Style_ContentControl_AnimatedTagSlideFromRight}"
                    local:UIPageTransitionManager.TransitionIndex="0"
                    x:Name="CurrentImage">
      <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_UpsellBackground}"
                        ImageSource="{Binding CurrentImage}"
                        ClipToBounds="True" />
    </ContentControl>

    <local:FZMaterialGlassCapture />

    <ContentControl x:Name="BottomBar"
                    Style="{StaticResource A_Style_ButtonBar}">
      <ContentControl x:Name="DefaultHelpPanel"
                      local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                      Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
    </ContentControl>

    <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
      <StackPanel Orientation="Vertical"
                  HorizontalAlignment="Left"
                  Margin="72">
        <local:FZMaterial Width="500"
                          Height="200"
                          ImageSource="{Binding LogoImage}"
                          Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}" />
        <DockPanel LastChildFill="True"
                   Height="668"
                   Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}">
          <local:CommonListBox DockPanel.Dock="Bottom"
                               Style="{StaticResource A_Style_ListBox_TextMenu_Default}"
                               SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"
                               ItemContainerStyle="{StaticResource A_Style_ListBoxItem_TextMenu_Default}"
                               ItemTemplate="{StaticResource A_DataTemplate_TextMenu_Upsell}"
                               ItemsSource="{Binding Collection}"
                               Width="448"
                               x:Name="PART_List" />
          <Decorator DockPanel.Dock="Bottom"
                     Height="5" />
          <ContentControl Template="{StaticResource A_ControlTemplate_SidePanel}"
                          Tag="{Binding Title}"
                          Width="448">
            <local:AutoScrollPanel Style="{StaticResource A_Style_AutoScrollPanel_ExpansionUpsell}"
                                   AnimationContext="{Binding Description}"
                                   Margin="30,20"/>
          </ContentControl>
        </DockPanel>
      </StackPanel>
    </Grid>
  </Grid>
</Page>
