<Page x:Class="ForzaUI.Scenes.Anthem.A_CampaignEventSelect"
      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"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      mc:Ignorable="d"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      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>

        <local:FZMaterialPresetRoundtangleStroke x:Key="A_FZMaterialPresetRoundtangleStroke_CampaignEventSelection"
                                                 BasedOn="{StaticResource A_FZMaterialPresetRoundtangle_GradientHighlight}"
                                                 CornerRadius="22"
                                                 Thickness="6.5"/>
        
        <ControlTemplate x:Key="A_Template_EventTitleBlock"
                         TargetType="Control">
            <Grid VerticalAlignment="Bottom"
                Height="{StaticResource A_Double_Size_Tile_TitlePanel}">
                <UniformGrid Margin="{StaticResource A_Thickness_TilePadding}" Rows="2" RenderTransformOrigin="0.5,0.5">
                    <UniformGrid.RenderTransform>
                        <TranslateTransform Y="0"/>
                    </UniformGrid.RenderTransform>
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_TileTitle}"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Top"
                        Grid.Row="0"
                        Text="{Binding Title, Converter={StaticResource A_StringToUpper}}"/>
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_TileText_ImageTile}"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Bottom"
                        Grid.Row="1"
                        local:TextBlockInlineMarkup.Markup="{Binding Subtitle}"/>
                </UniformGrid>
            </Grid>
        </ControlTemplate>

        <Style x:Key="A_Style_FZMaterial_EventSelect_MainContent"
               TargetType="local:FZMaterial"
               BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_Tile}">
            <Setter Property="Width"
                    Value="412" />
            <Setter Property="Height"
                    Value="611" />
            <Setter Property="HorizontalAlignment"
                    Value="Center" />
            <Setter Property="VerticalAlignment"
                    Value="Top" />
            <Setter Property="Margin"
                    Value="0,6,0,0" />
            <Setter Property="Preset">
                <Setter.Value>
                    <local:FZMaterialPresetRoundtangle BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                                                       CornerRadius="10" />
                </Setter.Value>
            </Setter>
        </Style>

        <local:EventBlueprintFlyerTemplateSelector x:Key="A_EventSelect_FlyerTemplateSelector" DataTemplateBaseName="A_DataTemplate_CampaignSetup_Tile" />

        <DataTemplate DataType="{x:Type local:CampaignEventSelectFixedImage}">
            <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                  local:UIPageTransitionManager.TransitionIndex="{Binding (local:UIPageTransitionManager.TransitionIndex), RelativeSource={RelativeSource TemplatedParent}}">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_EventSelect_MainContent}"
                                  ImageSource="{Binding Image}">
                </local:FZMaterial>

                <Control Template="{StaticResource A_Template_EventTitleBlock}"/>
            </Grid>
        </DataTemplate>
    
        <DataTemplate DataType="{x:Type local:CampaignEventSelectRoute}">
            <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition}"
                  local:UIPageTransitionManager.TransitionIndex="{Binding (local:UIPageTransitionManager.TransitionIndex), RelativeSource={RelativeSource TemplatedParent}}">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_EventSelect_MainContent}"
                                  CaptureSubgraph="True">
                    <Viewbox Stretch="Uniform">
                        <ContentControl Style="{StaticResource A_Style_ContentControl_CampaignFlyerFront}" 
                                        ContentTemplateSelector="{StaticResource A_EventSelect_FlyerTemplateSelector}"
                                        DataContext="{Binding CampaignSetupItem}" />
                    </Viewbox>
                </local:FZMaterial>

                <Control Template="{StaticResource A_Template_EventTitleBlock}"/>
            </Grid>
        </DataTemplate>

        <System:Double x:Key="A_Double_Carousel_Tile_Width">424</System:Double>
        <System:Double x:Key="A_Double_Carousel_Tile_Height">704</System:Double>

        <Style x:Key="A_Style_ContentControl_Carousel_ContainerStyle_CampaignEventSelect"
               BasedOn="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle_CampaignEventFlyer_SelectOnMouseHover}"
               TargetType="ContentControl">
            <Setter Property="Height" Value="{StaticResource A_Double_Carousel_Tile_Height}"/>
            <Setter Property="Width" Value="{StaticResource A_Double_Carousel_Tile_Width}"/>
        </Style>

        <Style TargetType="local:CommonListBox"
               x:Key="A_Style_Carousel_CampaignEventSelect">
            <Style.Resources>
                <CornerRadius x:Key="A_Dynamic_CornerRadius_Carousel_SelectionStroke">22</CornerRadius>
                <Thickness x:Key="A_Dynamic_Thickness_Carousel_SelectionStroke">6.5</Thickness>
                <CornerRadius x:Key="A_CornerRadius_Dynamic_CarouselTile">16</CornerRadius>
                <Style x:Key="A_Style_FZMaterial_MouseRollOverVisual_Dynamic"
                       BasedOn="{StaticResource A_Style_FZMaterial_MouseRollOverVisual_Default}"
                       TargetType="local:FZMaterial">
                    <Setter Property="Margin" Value="-0.5"/>
                    <Setter Property="Preset">
                        <Setter.Value>
                            <local:FZMaterialPresetRoundtangleStroke BasedOn="{StaticResource A_FZMaterialPresetRoundtangleStroke_Rollover_Outer_All}"
                                                                     CornerRadius="16"/>
                        </Setter.Value>
                    </Setter>
                </Style>
                <Style x:Key="A_Style_FZMaterial_ShadowBase_Dynamic"
                        TargetType="local:FZMaterial"
                        BasedOn="{StaticResource A_Style_FZMaterial_ShadowBase_Dynamic}">
                        <Setter Property="Margin"
                            Value="-20,0,-20,0" />
                </Style>
                <Style x:Key="A_Style_FZMaterial_RaiseFocusItemBackground_Dynamic"
                    BasedOn="{StaticResource A_Style_FZMaterial_RaiseFocusItemBackground}"
                    TargetType="local:FZMaterial">
                    <Setter Property="Preset">
                        <Setter.Value>
                            <local:FZMaterialPresetRoundtangleStroke BasedOn="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll}"
                                CornerRadius="{DynamicResource A_CornerRadius_Dynamic_CarouselTile}"
                                Thickness="7.5,7.5,7.5,90"/>
                        </Setter.Value>
                    </Setter>
                </Style>
            </Style.Resources>
            <Setter Property="ItemContainerStyle"
                    Value="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle_CampaignEventSelect}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type local:CommonListBox}">
                        <StackPanel KeyboardNavigation.DirectionalNavigation="Contained"
                            Orientation="Horizontal"
                            IsItemsHost="True"/>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Page.Resources>


    <Grid>
        <!-- Background Blur -->
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <local:PlayerBarControl x:Name="TopBar" Style="{StaticResource A_Style_PlayerBarControl}" />
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        Width="Auto">
            <ContentControl x:Name="DefaultHelpPanel"
                            local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding}">
            <Grid x:Name="LayoutRoot" KeyboardNavigation.DirectionalNavigation="Contained">
                <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
                    <Decorator Margin="0,0" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                        <ContentControl Content="{Binding ScreenTitle, Converter={StaticResource A_StringToUpper}}" 
                                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                        HorizontalAlignment="Left"
                                        local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/PlayerCreatedRoutes.png"/>
                    </Decorator>

                    <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}"
                          Margin="0,10,0,0">
                        <local:CommonListBox Style="{StaticResource A_Style_Carousel_CampaignEventSelect}"
                            ItemsSource="{Binding Collection}"
                            SelectedItem="{Binding SelectedItem, Mode=TwoWay}"/>
                    </Grid>
                </StackPanel>
            </Grid>
        </Border>

    </Grid>
</Page>
