<Page xmlns:local="clr-namespace:ForzaUI"
      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"
      x:Class="ForzaUI.A_CampaignBlueprintSelect"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Margin="0">
    
    <Page.Resources>
        <ResourceDictionary>

            <!-- Event Setup ControlTemplate and Style -->
            <ControlTemplate x:Key="A_ControlTemplate_ContentControl_ItemTile" TargetType="ContentControl">
                <ControlTemplate.Resources>
                    <Storyboard x:Key="SelectItemStory">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                                           Storyboard.TargetName="ScaledContainer">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="1.06" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                                           Storyboard.TargetName="ScaledContainer">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="1.06" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                           Storyboard.TargetName="DropShadow">
                            <EasingDoubleKeyFrame KeyTime="0:0:0"
                                                      Value="0" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="0.6" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                                           Storyboard.TargetName="DropShadow">
                            <EasingDoubleKeyFrame KeyTime="0:0:0"
                                                      Value="0.75" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="1.06" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                                           Storyboard.TargetName="DropShadow">
                            <EasingDoubleKeyFrame KeyTime="0:0:0"
                                                      Value="0.75" />
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="1.06" />
                        </DoubleAnimationUsingKeyFrames>
                        <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.ZIndex)"
                                                      Storyboard.Target="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}}">
                            <EasingInt32KeyFrame KeyTime="0:0:0.3"
                                                     Value="20" />
                        </Int32AnimationUsingKeyFrames>
                    </Storyboard>
                    <Storyboard x:Key="DeselectItemStory">
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                                           Storyboard.TargetName="ScaledContainer">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="1.0" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                                           Storyboard.TargetName="ScaledContainer">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="1.0" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)"
                                                           Storyboard.TargetName="DropShadow">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="0" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
                                                           Storyboard.TargetName="DropShadow">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="0.75" />
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
                                                           Storyboard.TargetName="DropShadow">
                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                      Value="0.75" />
                        </DoubleAnimationUsingKeyFrames>
                        <Int32AnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.ZIndex)"
                                                          Storyboard.Target="{Binding RelativeSource={RelativeSource AncestorType=ListBoxItem}}">
                            <EasingInt32KeyFrame KeyTime="0:0:0.3"
                                                     Value="0" />
                        </Int32AnimationUsingKeyFrames>
                    </Storyboard>

                    <Style x:Key="A_Style_FZMaterial_MouseRollOverVisual_Dynamic"
                           BasedOn="{StaticResource A_Style_FZMaterial_MouseRollOverVisual_Default}"
                           TargetType="local:FZMaterial">
                        <Setter Property="Preset">
                            <Setter.Value>
                                <local:FZMaterialPresetRoundtangleStroke BasedOn="{StaticResource A_FZMaterialPresetRoundtangleStroke_Rollover}"
                                                                         CornerRadius="{StaticResource A_CornerRadius_FlyerOuterBorder}"
                                                                         Thickness="8" />
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ControlTemplate.Resources>
                <Grid Margin="-6,-6,0,0">
                    <Decorator RenderTransformOrigin="0.5,0.5">
                        <Decorator.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform ScaleX="{Binding Tag, ElementName=Flyer, Converter={StaticResource A_LinearTransformConverter_FlyerFlippingShadow}}" />
                            </TransformGroup>
                        </Decorator.RenderTransform>
                        <local:FZMaterial x:Name="DropShadow"
                                      Style="{StaticResource A_Style_FZMaterial_ShadowBase_ForSubgraph}"
                                      Margin="-12"
                                      RenderTransformOrigin="0.5,0.5"
                                      IsHitTestVisible="False">
                            <local:FZMaterial.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform ScaleX="0.75" ScaleY="0.75" />
                                    <TranslateTransform />
                                </TransformGroup>
                            </local:FZMaterial.RenderTransform>
                        </local:FZMaterial>
                    </Decorator>
                    <Decorator x:Name="ScaledContainer"
                          Width="{StaticResource A_Double_CampaignEventFlyer_Carousel_Tile_Width}"
                          Height="{StaticResource A_Double_CampaignEventFlyer_Carousel_Tile_Height}"
                          RenderTransformOrigin="0.5,0.5">
                        <Decorator.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform ScaleX="1" ScaleY="1" />
                                <TranslateTransform />
                            </TransformGroup>
                        </Decorator.RenderTransform>
                        <Viewbox Width="484"
                                 Height="703">
                            <Grid>
                                <local:AudioEvent x:Name="Audio" />
                                <local:RoutedEventCommand x:Name="ClickOnMouseItem"
                                                          RoutedEvent="UIElement.MouseLeftButtonDown"/>
                                <Control x:Name="Flyer" Style="{StaticResource A_Style_Control_CampaignFlyer_Internal_BorderedWithSelectionHighlight}" />
                                <local:FZMaterial Color="#00000000"
                                                  x:Name="HitTestHelper"
                                                  local:RoutedEventCommand.Action="{Binding ElementName=ClickOnMouseItem}"/>
                            </Grid>
                        </Viewbox>
                    </Decorator>
                </Grid>
                <ControlTemplate.Triggers>
                    <DataTrigger Binding="{Binding (Selector.IsSelected), RelativeSource={RelativeSource Self}}"
                                     Value="True">
                        <Setter TargetName="ClickOnMouseItem" Property="Command" Value="{Binding SelectCommand, RelativeSource={RelativeSource AncestorType=Page}}"/>
                        <DataTrigger.EnterActions>
                            <BeginStoryboard HandoffBehavior="SnapshotAndReplace"
                                                         Storyboard="{StaticResource SelectItemStory}" />
                        </DataTrigger.EnterActions>
                        <DataTrigger.ExitActions>
                            <BeginStoryboard HandoffBehavior="SnapshotAndReplace"
                                                         Storyboard="{StaticResource DeselectItemStory}" />
                        </DataTrigger.ExitActions>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding IsFlyerFlipped}" Value="True">
                        <DataTrigger.EnterActions>
                            <BeginStoryboard HandoffBehavior="SnapshotAndReplace"
                                                         Storyboard="{StaticResource A_Storyboard_ShowBackOfFlyer}" />
                        </DataTrigger.EnterActions>
                        <DataTrigger.ExitActions>
                            <BeginStoryboard HandoffBehavior="SnapshotAndReplace"
                                                         Storyboard="{StaticResource A_Storyboard_ShowFrontOfFlyer}" />
                        </DataTrigger.ExitActions>
                    </DataTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <Style x:Key="A_Style_ListBoxItem_ItemTile" TargetType="ListBoxItem">
                <!--Setter Property="Height" Value="716" />
                <Setter Property="Width" Value="494" /-->
                <Setter Property="Focusable" Value="True" />
                <Setter Property="Template" Value="{StaticResource A_ControlTemplate_ContentControl_ItemTile}" />
                <Setter Property="local:ZPanel.DisableClipping" Value="True" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsSelectable}" Value="False" >
                        <Setter Property="Focusable" Value="False" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

        </ResourceDictionary>
    </Page.Resources>

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

    <Grid>
	<Control Style="{StaticResource A_Style_Control_ScreenBackground}" />
        <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.BDescription="{local:Loc HelpButtons.IDS_Back}"
                    Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>
        <local:NetworkCountdownControl Style="{StaticResource A_Style_NetworkCountdownControl_EventSetup}" />

        <Border x:Name="LayoutRoot"
                Style="{StaticResource A_Style_Border_ScenePadding}">
            <Grid Style="{StaticResource A_Style_FrameworkElement_ScreenTilt}"
                  Margin="0,40,0,0">
                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                    <StackPanel VerticalAlignment="Top" HorizontalAlignment="Center">
                        <ContentControl Content="{Binding Title}" 
                                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                        HorizontalAlignment="Left"
                                        local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/PlayerCreatedRoutes.png"/>
                        <local:ItemsSelector x:Name="CategoryList"
                                             ItemsSource="{Binding Categories}"
                                             SelectedItem="{Binding SelectedCategory}"
                                             Focusable="False"
                                             HorizontalAlignment="Left"
                                             Margin="0,0,0,12"
                                             WrapSelection="True"
                                             Style="{StaticResource A_Style_Carousel6ItemList_TabBar}"
                                             PageSize="1"
                                             Visibility="{Binding Categories.Count, Converter={StaticResource A_Converter_Categories_CountToVisibility}, FallbackValue=Collapsed}"
                                             local:AttachedRoutedEventCommand.RoutedEvent="Selector.SelectionChanged"
                                             local:AttachedRoutedEventCommand.Command="{Binding CategorySelectionChangedCommand}" />
                        <Grid Margin="0,15,0,0">
                            <local:WrapListBox x:Name="PART_ItemListBox"
                                               Style="{StaticResource A_Style_Carousel_CampaignEventFlyer}"
                                               ItemsSource="{Binding SelectedCategory.CampaignSetups}"
                                               SelectedItem="{Binding SelectedCategory.SelectedItem}"
                                               ItemContainerStyle="{StaticResource A_Style_ListBoxItem_ItemTile}"
                                               ItemTemplateSelector="{StaticResource A_EventBlueprintFlyerTemplateSelector}"
                                               PageSize="1"
                                               IsEnabled="{Binding SelectorIsEnabled}"
                                               local:AttachedRoutedEventCommand.RoutedEvent="Selector.SelectionChanged"
                                               local:AttachedRoutedEventCommand.Command="{Binding CampaignSetupSelectionChangedCommand}"
                                               local:FocusOnPageFocusGained.SelectorSelectedItem="True" />
                            <Decorator Width="400"
                                       Height="400"
                                       HorizontalAlignment="Center"
                                       Tag="{Binding SelectedCategory.CampaignSetups.Count}">
                              <Decorator.Style>
                                <Style TargetType="FrameworkElement">
                                  <Setter Property="Visibility" Value="Collapsed" />
                                  <Style.Triggers>
                                    <MultiDataTrigger>
                                      <MultiDataTrigger.Conditions>
                                        <Condition Binding="{Binding Tag, RelativeSource={RelativeSource Self}}">
                                          <Condition.Value>
                                            <System:Int32>0</System:Int32>
                                          </Condition.Value>
                                        </Condition>
                                        <Condition Binding="{Binding IsLoading, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}}" Value="False"/>
                                      </MultiDataTrigger.Conditions>
                                      <Setter Property="Visibility" Value="Visible"/>
                                    </MultiDataTrigger>
                                  </Style.Triggers>
                                </Style>
                              </Decorator.Style>
                              <local:FZTextBlock Color="{StaticResource A_Color_SubHeader_Text}"
                                                 HorizontalAlignment="Center"
                                                 TextAlignment="Center"
                                                 Style="{StaticResource A_Style_FZTextBlock_Heading_Tight}"
                                                 Text="{local:Loc EventBlueprint.IDS_UGC_NoEventsFound}"
                                                 VerticalAlignment="Center"
                                                 TextWrapping="Wrap"/>
                            </Decorator>
                            <ProgressBar x:Name="IdleIndicator"
                                         IsIndeterminate="True"
                                         Style="{StaticResource A_Style_ProgressBar_WaitSpinner}"
                                         Height="56"
                                         Visibility="{Binding IsLoading, RelativeSource={RelativeSource FindAncestor, AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"/>
                        </Grid>
                    </StackPanel>
                </Grid>
            </Grid>
        </Border>
    </Grid>
</Page>
