<Page DataContext="{Binding RelativeSource={RelativeSource Self}}"
      Style="{StaticResource A_Style_Page_Generic}"
      mc:Ignorable="d"
      x:Class="ForzaUI.A_EventAdditionalInfo"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
      xmlns:local="clr-namespace:ForzaUI;assembly="
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_WrapListBoxItem_EventAdditionalInfo" TargetType="ContentControl" BasedOn="{StaticResource H_Style_ContentControl_Carousel_ContainerStyle}">
                <Setter Property="Margin" Value="0,2,0,2"/>
                <Setter Property="local:BindingProxy.A" Value="{Binding EventInfoDataView.CampaignSetupItem, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Page}}}" />
                <Setter Property="DynamicData.Data">
                    <Setter.Value>
                        <DynamicDataSource>
                            <DynamicDataItem Name="ScaledContainerStyle"
                                             DataType="Style">
                                <DynamicDataItem.Value>
                                    <Style TargetType="FrameworkElement">
                                        <Setter
                                            Property="RenderTransform">
                                            <Setter.Value>
                                                <ScaleTransform />
                                            </Setter.Value>
                                        </Setter>
                                        <Style.Triggers>
                                            <DataTrigger
                                                Binding="{Binding (Selector.IsSelected), RelativeSource={RelativeSource AncestorType=ListBoxItem}}"
                                                Value="True">
                                                <DataTrigger.EnterActions>
                                                    <BeginStoryboard
                                                        HandoffBehavior="SnapshotAndReplace">
                                                        <Storyboard>
                                                            <DoubleAnimationUsingKeyFrames
                                                                Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(ScaleTransform.ScaleX)">
                                                                <DiscreteDoubleKeyFrame
                                                                    KeyTime="0:0:0.0"
                                                                    Value="1.015" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                            <DoubleAnimationUsingKeyFrames
                                                                Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(ScaleTransform.ScaleY)">
                                                                <DiscreteDoubleKeyFrame
                                                                    KeyTime="0:0:0.0"
                                                                    Value="1.015" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.EnterActions>
                                                <DataTrigger.ExitActions>
                                                    <BeginStoryboard
                                                        HandoffBehavior="SnapshotAndReplace">
                                                        <Storyboard>
                                                            <DoubleAnimationUsingKeyFrames
                                                                Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(ScaleTransform.ScaleX)">
                                                                <EasingDoubleKeyFrame
                                                                    KeyTime="0:0:0.3"
                                                                    Value="1.0"
                                                                    EasingFunction="{CircleEasing}" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                            <DoubleAnimationUsingKeyFrames
                                                                Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(ScaleTransform.ScaleY)">
                                                                <EasingDoubleKeyFrame
                                                                    KeyTime="0:0:0.3"
                                                                    Value="1.0"
                                                                    EasingFunction="{CircleEasing}" />
                                                            </DoubleAnimationUsingKeyFrames>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.ExitActions>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </DynamicDataItem.Value>
                            </DynamicDataItem>
                            <DynamicDataItem Name="DropShadowStyle"
                                             DataType="Style">
                                <DynamicDataItem.Value>
                                    <Style BasedOn="{StaticResource H_Style_FZMaterial_ShadowBase_ForSubgraph}"
                                           TargetType="{Type FZMaterial}">
                                        <Setter Property="Preset">
                                            <Setter.Value>
                                                <FZMaterialPresetRoundtangle
                                                    Softness="30"
                                                    CornerRadius="20"
                                                    AlphaMode="MultiplyInvColorOnly"
                                                    Unlit="True" />
                                            </Setter.Value>
                                        </Setter>
                                        <Setter Property="Margin"
                                            Value="0,-20,-10,-28" />
                                    </Style>
                                </DynamicDataItem.Value>
                            </DynamicDataItem>
                        </DynamicDataSource>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ContentControl}">
                            <ControlTemplate.Resources>
                                <ResourceDictionary>
                                    <Storyboard x:Key="SelectItemStory">
                                        <Int32AnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(ZPanel.ClippingBias)">
                                            <DiscreteInt32KeyFrame
                                                KeyTime="0:0:0.0"
                                                Value="1" />
                                        </Int32AnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(UIElement.Opacity)"
                                                Storyboard.TargetName="DropShadow">
                                            <DiscreteDoubleKeyFrame
                                                KeyTime="0:0:0.0"
                                                Value="0.6" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
                                                Storyboard.TargetName="ShadowScale">
                                            <DiscreteDoubleKeyFrame
                                                KeyTime="0:0:0.0"
                                                Value="1.1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
                                                Storyboard.TargetName="ShadowScale">
                                            <DiscreteDoubleKeyFrame
                                                KeyTime="0:0:0.0"
                                                Value="1.1" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <Int32AnimationUsingKeyFrames
                                                Storyboard.TargetProperty="(Panel.ZIndex)"
                                                Storyboard.Target="{Binding RelativeSource={RelativeSource AncestorType=ContentPresenter}}">
                                            <DiscreteInt32KeyFrame
                                                KeyTime="0:0:0.0"
                                                Value="20" />
                                        </Int32AnimationUsingKeyFrames>
                                    </Storyboard>
                                    <UIStoryboard
                                            x:Key="DeselectItemStory"
                                            Duration="0:0:0.36">
                                        <Int32AnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(ZPanel.ClippingBias)">
                                            <DiscreteInt32KeyFrame
                                            KeyTime="0:0:0.0"
                                            Value="1" />
                                            <DiscreteInt32KeyFrame
                                            KeyTime="0:0:0.3"
                                            Value="{x:Static Int32.MaxValue}" />
                                        </Int32AnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(UIElement.Opacity)"
                                            Storyboard.TargetName="DropShadow">
                                            <EasingDoubleKeyFrame
                                            KeyTime="0:0:0.3"
                                            Value="0"
                                            EasingFunction="{CircleEasing}" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames
                                             Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
                                             Storyboard.TargetName="ShadowScale">
                                            <EasingDoubleKeyFrame
                                            KeyTime="0:0:0.3"
                                            Value="0.75"
                                            EasingFunction="{CircleEasing}" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(ScaleTransform.ScaleY)"
                                            Storyboard.TargetName="ShadowScale">
                                            <EasingDoubleKeyFrame
                                            KeyTime="0:0:0.3"
                                            Value="0.75"
                                            EasingFunction="{CircleEasing}" />
                                        </DoubleAnimationUsingKeyFrames>
                                        <Int32AnimationUsingKeyFrames
                                            Storyboard.TargetProperty="(Panel.ZIndex)"
                                            Storyboard.Target="{Binding RelativeSource={RelativeSource AncestorType=ContentPresenter}}">
                                            <EasingInt32KeyFrame
                                            KeyTime="0:0:0.3"
                                            Value="0"
                                            EasingFunction="{CircleEasing}" />
                                        </Int32AnimationUsingKeyFrames>
                                    </UIStoryboard>
                                    <Storyboard
                                        x:Key="PART_TransitionOut" />
                                </ResourceDictionary>
                            </ControlTemplate.Resources>
                            <DockPanel VerticalAlignment="Stretch">
                                <FZMaterial Margin="0,0,6,0" DockPanel.Dock="Left" Width="48"
                                        Preset="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_Base}"
                                        Color="{StaticResource A_Color_GlassPanel_NonInteractive}">
                                    <local:FZTextBlock Text="{Binding EventIndex, Converter={StaticResource A_NumUnitConverter_Min2Digits_0dp}}" FontFamily="Horizon_A" 
                                                       VerticalAlignment="Center" HorizontalAlignment="Center"
                                                       Color="{StaticResource H_Color_Primary_White}" CapHeight="18" />
                                </FZMaterial>
                                <Grid>
                                    <FZMaterial x:Name="DropShadow"
                                                Style="{DynamicDataBinding DropShadowStyle, FallbackValue={StaticResource H_Style_FZMaterial_ShadowBase_ForSubgraph}}">
                                        <FZMaterial.RenderTransform>
                                            <TransformGroup>
                                                <ScaleTransform
                                                    ScaleX="0"
                                                    ScaleY="0"
                                                    x:Name="ShadowScale" />
                                            </TransformGroup>
                                        </FZMaterial.RenderTransform>
                                    </FZMaterial>
                                    <Grid                     
                                        x:Name="ScaledContainer"
                                        RenderTransformOrigin="0.5,0.5"
                                        ZPanel.ZOffset="0"
                                        Style="{DynamicDataBinding ScaledContainerStyle, FallbackValue={StaticResource H_Style_FrameworkElement_CarouselSelectionScale}}">
                                        <StrokeHighlightControl
                                                x:Name="FocusHighlight"
                                                Style="{StaticResource H_Style_StrokeHighlight_Animated}"
                                                IsEnabled="{Binding (Selector.IsSelected), FallbackValue=False, RelativeSource={RelativeSource TemplatedParent}}" />

                                        <local:FZMaterial Preset="{StaticResource H_Roundtangle_Outer_1px}"/>
                                        <ContentPresenter />
                                        <Control
                                                x:Name="MouseRollover"
                                                Style="{StaticResource H_Style_TemplatedElement_MouseRollover_ListBoxItem}" />
                                    </Grid>
                                </Grid>
                            </DockPanel>
                            <ControlTemplate.Triggers>
                                <Trigger
                            Property="Selector.IsSelected"
                            Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard
                                    x:Name="ShowSelected_BeginStoryboard2"
                                    HandoffBehavior="SnapshotAndReplace"
                                    Storyboard="{StaticResource SelectItemStory}" />
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard
                                    x:Name="HideSelected_BeginStoryboard2"
                                    HandoffBehavior="SnapshotAndReplace"
                                    Storyboard="{StaticResource DeselectItemStory}" />
                                    </Trigger.ExitActions>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

        </ResourceDictionary>
    </Page.Resources>
        
    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>
    <Grid x:Name="PART_LayoutRoot">
        <local:FZMaterialGlassCapture />

        <MappingConverterResourcePreloader Converter="{StaticResource A_Converter_RaceMode_To_FlyerBackRaceIcon}"
                                           ValueType="BitmapImage"/>

        <Control x:Name="DefaultBackground"
                 Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <DockPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                <Decorator Style="{StaticResource A_Style_FrameworkElement_TiledMenuTransition_0}"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Bottom"
                    Margin="54,0,0,0"
                    DockPanel.Dock="Top">
                    <ContentControl Content="{Binding EventInfoDataView.CampaignSetupItem.Name, Converter={StaticResource A_StringToUpper}}"
                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"/>
                </Decorator>

                <DockPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                    <Decorator DockPanel.Dock="Right" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                        <Control Width="364"
                            Margin="0"
                            VerticalAlignment="Center" Height="740"
                            DataContext="{Binding EventInfoDataView}"
                            Style="{StaticResource A_Style_Event_RaceInfoPanel_PreRace}"/>
                    </Decorator>
                    <Decorator DockPanel.Dock="Left" Margin="0,0,2,0" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                        <WrapListBox x:Name="PART_RaceList"
                                     Width="1034"
                                     Template="{StaticResource H_ControlTemplate_TextMenu_Default}"
                                     ScrollOrientation="Vertical"
                                     Height="740"
                                     FocusOnPageFocusGained.SelectorSelectedItem="True"
                                     ItemHeight="124"
                                     Margin="0,-4,0,-4"
                                     ItemWidth="1016"
                                     AlternationCount="10000"
                                     HorizontalAlignment="Center"
                                     SelectedItem="{Binding EventInfoDataView.SelectedRace}"
                                     ItemsSource="{Binding EventInfoDataView.CampaignSetupItem.RaceSetups}"
                                     ItemContainerStyle="{StaticResource A_Style_WrapListBoxItem_EventAdditionalInfo}"
                                     EmptyItemStyle="{StaticResource A_Style_Control_EmptyItemStyle}"
                                     ItemTemplate="{StaticResource A_DataTemplate_RaceSetupItem}" />
                    </Decorator>
                </DockPanel>
            </DockPanel>
        </Grid>
        <PageInputHandler 
            x:Name="ActionButtonInput"
            Command="{Binding PlayerActionCommand}"
            Button="X" />
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        x:Name="BottomBar">
            <local:ControllerButtonPanel x:Name="PART_HelpPanel"
                                         Style="{StaticResource A_Style_ControllerButtonPanel_Default}">
                <local:ControllerButtonControl Button="B"
                                               Description="{local:Loc HelpButtons.IDS_Back}" />
                <local:ControllerButtonControl Button="X"
                                               Visibility="{Binding Command.Enabled, ElementName=ActionButtonInput, Converter={StaticResource A_FZBooleanToVisibilityConverter}, FallbackValue=Collapsed}"
                                               Description="{local:Loc HelpButtons.IDS_PlayerOptions}" />
            </local:ControllerButtonPanel>
        </ContentControl>
    </Grid>
</Page>
