<Page x:Class="ForzaUI.Scenes.Anthem.A_CarSelectCarInfoLabel"
      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"  
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}">

    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_FZTextBlock_Base" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_HorizonB}">
                <Setter Property="Color" Value="{StaticResource A_Color_White}" />
                <Setter Property="LayoutTransform">
                    <Setter.Value>
                        <TransformGroup>
                            <SkewTransform AngleX="-7"/>
                        </TransformGroup>
                    </Setter.Value>
                </Setter>
            </Style>

            <System:Boolean x:Key="A_Boolean_True">True</System:Boolean>
            <System:Boolean x:Key="A_Boolean_False">False</System:Boolean>
            <!--Use explicit bools so the converter handles it correctly, otherwise it will treat "false" as a string and return true in a multiconverter -->
            <local:MappingConverter x:Key="A_MappingConverter_Show_CarManufactur_Logo" Default="{StaticResource A_Boolean_False}">
                <local:MappingConverterEntry Key="27" Value="{StaticResource A_Boolean_True}"/>
            </local:MappingConverter>
            <local:MultiConverter x:Key="A_MultiMappingConverter_CarManufacturer_Visibility">
                <local:MultiConverterEntry Converter="{StaticResource A_MappingConverter_Show_CarManufactur_Logo}" />
                <local:MultiConverterEntry Converter="{StaticResource A_FZBooleanToVisibilityConverter_UseHidden}" />
            </local:MultiConverter>
            <local:MultiConverter x:Key="A_MultiMappingConverter_CarManufacturer_Visibility_Inverse">
                <local:MultiConverterEntry Converter="{StaticResource A_MappingConverter_Show_CarManufactur_Logo}" />
                <local:MultiConverterEntry Converter="{StaticResource A_FZBooleanToVisibilityConverter_Inverse}" />
            </local:MultiConverter>

            <!--Different car models scale the controller prompt via Viewbox. -->
            <local:MappingConverter x:Key="A_MappingConverter_ControllerPrompt_ViewboxHeight" Default="64">
                <local:MappingConverterEntry Key="4090" Value="96"/> <!-- MIT_LancerEvoVITME_01 -->
            </local:MappingConverter>

            <!--Different car models have different track adjust. -->
            <local:MappingConverter x:Key="A_MappingConverter_Model_Tracking_Adjust" Default="0">
                <local:MappingConverterEntry Key="3105" Value="0.20"/> <!-- E3 SENNA -->
                <local:MappingConverterEntry Key="2529" Value="0.08"/> <!-- CAYMAN -->
                <local:MappingConverterEntry Key="2544" Value="0.08"/> <!-- VIPER -->
                <local:MappingConverterEntry Key="2988" Value="0.20"/> <!-- SENNA -->
                <local:MappingConverterEntry Key="2472" Value="0.08"/> <!-- 570S -->
                <local:MappingConverterEntry Key="2846" Value="0.15"/> <!-- 720S -->
            </local:MappingConverter>

            <!--Different makes have different track adjust. Might change to be car based -->
            <local:MappingConverter x:Key="A_MappingConverter_Make_To_LineDiverMarginAdjust" Default="0">
                <local:MappingConverterEntry Key="27" Value="5,0,4,0"/><!-- SENNA -->
                <local:MappingConverterEntry Key="39" Value="5,0,8,0"/><!-- CAYMAN -->
                <local:MappingConverterEntry Key="11" Value="5,0,4,0"/><!-- VIPER -->
            </local:MappingConverter>

            <!--Different makes have different overriding size behavior for logo. -->
            <local:MappingConverter x:Key="A_MappingConverter_Override_Logo_Width" Default="160">
                <local:MappingConverterEntry Key="27" Value="332"/> <!-- SENNA -->
            </local:MappingConverter>
            <local:MappingConverter x:Key="A_MappingConverter_Override_Logo_Height" Default="160">
                <local:MappingConverterEntry Key="27" Value="48"/>
            </local:MappingConverter>

            <Style x:Key="A_Style_Manufactur_Icon_Texture" TargetType="local:FZMaterial">
                <Setter Property="Visibility" Value="{Binding MfrId, Converter={StaticResource A_MultiMappingConverter_CarManufacturer_Visibility}, FallbackValue=Hidden}"/>
                <Setter Property="ImageSource" Value="{Binding MfrLogo, FallbackValue={StaticResource A_BitmapImage_GamerPicFallback}}"/>
                <Setter Property="Stretch" Value="Fill"/>
                <Setter Property="Width" Value="{Binding MfrId, Converter={StaticResource A_MappingConverter_Override_Logo_Width}, FallbackValue=160}"/>
                <Setter Property="Height" Value="{Binding MfrId, Converter={StaticResource A_MappingConverter_Override_Logo_Height}, FallbackValue=160}"/>
            </Style>
            
            <Style x:Key="A_Style_FZTextBlock_CarName_Mfr" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_Base}">
                <Setter Property="CapHeight" Value="38" />
                <Setter Property="Visibility" Value="{Binding MfrId, Converter={StaticResource A_MultiMappingConverter_CarManufacturer_Visibility_Inverse}, FallbackValue=Visible}"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_CarName" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_Base}">
                <Setter Property="CapHeight" Value="60" />
                <Setter Property="FontFamily" Value="Horizon_A"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_InstructionText" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_Base}">
                <Setter Property="CapHeight" Value="32" />
            </Style>
            <ExponentialEase x:Key="A_EasingFunction_EaseOut" EasingMode="EaseOut"/>

            <local:UIStoryboard x:Key="A_Storyboard_HiddenToFocused">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="LineDivide"
                                               Storyboard.TargetProperty="(FrameworkElement.LayoutTransform).(ScaleTransform.ScaleX)">
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="0" />
                    <EasingDoubleKeyFrame KeyTime="0:0:0.35" Value="1" EasingFunction="{local:QuarticEasing EasingMode=EaseInOut}"/>
                </DoubleAnimationUsingKeyFrames>

                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Tag" Storyboard.TargetName="TagSlideCarInfo">
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="1" />
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.35" Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:0.75" EasingFunction="{StaticResource A_EasingFunction_EaseOut}"  Value="0"/>
                </DoubleAnimationUsingKeyFrames>

                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Tag" Storyboard.TargetName="TagSlideInstruction">
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.0" Value="1" />
                    <DiscreteDoubleKeyFrame KeyTime="0:0:0.35" Value="1" />
                    <EasingDoubleKeyFrame KeyTime="0:0:0.75" EasingFunction="{StaticResource A_EasingFunction_EaseOut}" Value="0"/>
                </DoubleAnimationUsingKeyFrames>

                <StringAnimationUsingKeyFrames Storyboard.TargetName="CarSelectInfoAppearAudioEvent" Storyboard.TargetProperty="(local:AudioEvent.SoundName)">
                    <DiscreteStringKeyFrame KeyTime="0:0:0" Value="/Master/UI/CarMeet/HZ2_SFX_HUD_CarMeet_InfoAppear_01" />
                </StringAnimationUsingKeyFrames>
            </local:UIStoryboard>

            <local:UIStoryboard x:Key="A_Storyboard_HiddenToUnfocused" DurationOverride="0:0:0.3">
            </local:UIStoryboard>

            <local:UIStoryboard x:Key="A_Storyboard_UnfocusedToFocused" DurationOverride="0:0:0.3">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Instruction">
                    <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="1" />
                </DoubleAnimationUsingKeyFrames>
            </local:UIStoryboard>

            <local:UIStoryboard x:Key="A_Storyboard_FocusedToUnfocused" DurationOverride="0:0:0.3">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TagSlideCarInfo">
                    <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="0" />
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Instruction">
                    <LinearDoubleKeyFrame KeyTime="0:0:0.3" Value="0" />
                </DoubleAnimationUsingKeyFrames>
            </local:UIStoryboard>

            <local:UIStoryboard x:Key="A_Storyboard_FocusedToHidden" DurationOverride="0:0:0.3">
            </local:UIStoryboard>

            <local:FZMaterialPresetRoundtangle BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                                           CornerRadius="7"
                                           x:Key="A_FZMaterialPresetRoundtangle_ActivationDot" />

            <MappingConverter x:Key="A_LangStrToCarInfoContainerMargin" Default="4,4,4,0">
                <MappingConverterEntry Key="CHS" Value="4,9,4,0"/>
            </MappingConverter>
        </ResourceDictionary>
    </Page.Resources>

    <Grid x:Name="PART_FrameworkElement_LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="GeneralStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.3"/>
                    <VisualTransition From="PART_Unfocused" GeneratedDuration="0:0:0.3" To="PART_Focused" Storyboard="{StaticResource A_Storyboard_UnfocusedToFocused}" />
                    <VisualTransition From="PART_Focused" GeneratedDuration="0:0:0.3" To="PART_Unfocused" Storyboard="{StaticResource A_Storyboard_FocusedToUnfocused}" />
                    <VisualTransition From="PART_Focused" GeneratedDuration="0:0:0.3" To="PART_Hidden"/>
                    <VisualTransition From="PART_Unfocused" GeneratedDuration="0:0:0.75" To="PART_Hidden" Storyboard="{StaticResource A_Storyboard_FocusedToHidden}" />
                    <VisualTransition From="PART_Hidden" GeneratedDuration="0:0:0.3" To="PART_Focused" Storyboard="{StaticResource A_Storyboard_HiddenToFocused}" />
                    <VisualTransition From="PART_Hidden" GeneratedDuration="0:0:0.3" To="PART_Unfocused" Storyboard="{StaticResource A_Storyboard_HiddenToUnfocused}" />
                </VisualStateGroup.Transitions>
                <VisualState x:Name="PART_Hidden">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ContainerGrid">
                            <DiscreteDoubleKeyFrame KeyTime="0" Value="0.0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="PART_Focused">
                    <Storyboard>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="PART_Unfocused">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="Instruction">
                            <DiscreteDoubleKeyFrame KeyTime="0" Value="0"/>
                        </DoubleAnimationUsingKeyFrames>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ContainerGrid">
                            <DiscreteDoubleKeyFrame KeyTime="0" Value="0.0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid.RowDefinitions>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid x:Name="ContainerGrid" Grid.Row="0" VerticalAlignment="Top">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <!-- CAR INFO (Mfr Icon dependent on make)-->
                <RowDefinition Height="3" />
                <!-- ROW DIVIDER-->
                <RowDefinition Height="*" />
                <!-- INSTRUCTION PROMPT-->
            </Grid.RowDefinitions>

            <ContentControl x:Name="TagSlideCarInfo" Style="{StaticResource A_Style_ContentControl_AnimatedTagSlideFromBottom}" Grid.Row="0" VerticalAlignment="Bottom" HorizontalAlignment="Center">
                <Decorator>
                    <!--Add margin to offset the skew so it does not get clipped by the TagSlideCarInfo control wrapping -->
                    <StackPanel x:Name="CarInfoContainer" Orientation="Vertical" Margin="{Binding LangStr, Source={StaticResource PART_UISceneContext}, Converter={StaticResource  A_LangStrToCarInfoContainerMargin}}" VerticalAlignment="Bottom">
                        <local:FZMaterial x:Name="MfrLogoImage" Style="{StaticResource A_Style_Manufactur_Icon_Texture}"
                                          Margin="0,0,0,18" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>

                        <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
                            <local:FZTextBlock Text="{Binding NameLine1, Converter={StaticResource A_StringToUpper}}" Style="{StaticResource A_Style_FZTextBlock_CarName_Mfr}" HorizontalAlignment="Center" Margin="0,0,0,14"/>
                            <Grid>

                                <local:FZMaterial Margin="-70,-50" ZPanel.DisableClipping="True" ImageSource="/ForzaUI;component/Textures/Anthem/Gradients/PreEventShadow.png" Opacity="{StaticResource A_Double_PreRaceIntro_UnderlayOpacity}"/>
                                <local:FZTextBlock Text="{Binding NameLine2, Converter={StaticResource A_StringToUpper}}" 
                                           TrackingAdjust="{Binding ModelId, Converter={StaticResource A_MappingConverter_Model_Tracking_Adjust}, FallbackValue=0}" 
                                           Style="{StaticResource A_Style_FZTextBlock_CarName}"  
                                           HorizontalAlignment="Center" Margin="0,0,0,14"/>
                            </Grid>
                        </StackPanel>
                    </StackPanel>
                </Decorator>
            </ContentControl>

            <!--Line is margin offset to adjust for left angled view in AR -->
            <Decorator x:Name="LineDivide" HorizontalAlignment="Center" 
                                           Width="{Binding Path=ActualWidth, ElementName=CarInfoContainer}" 
                                           VerticalAlignment="Stretch" Margin="-21,0,0,0" Grid.Row="1">
                <Decorator.LayoutTransform>
                    <ScaleTransform ScaleX="1"/>
                </Decorator.LayoutTransform>
                <local:FZMaterial Color="{StaticResource H_Color_Primary_Yellow}" Height="5"
                                  Margin="{Binding MfrId, Converter={StaticResource A_MappingConverter_Make_To_LineDiverMarginAdjust}}" />
            </Decorator>

            <ContentControl x:Name="TagSlideInstruction" Style="{StaticResource A_Style_ContentControl_AnimatedTagSlideFromTop}" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="-22,22,0,0">
                <Decorator>
                    <Viewbox Height="{Binding ModelId, Converter={StaticResource A_MappingConverter_ControllerPrompt_ViewboxHeight}, FallbackValue=64}" Stretch="Uniform">
                        <StackPanel x:Name="Instruction" Orientation="Horizontal" VerticalAlignment="Top" Margin="8">
                            <Viewbox Height="48"
                                     MinWidth="48"
                                     Margin="0,-8,16,-8">
                                <local:ControllerButtonControl Button="A"
                                                               UseLargeIcon="True"
                                                               AllowMouseClick="False"
                                                               Margin="0"
                                                               HideShadow="True"
                                                               Style="{StaticResource A_Style_ControllerButtonControl_Standalone}" />
                            </Viewbox>
                            <Grid>
                                <local:FZMaterial Margin="-30,-50" ZPanel.DisableClipping="True" ImageSource="/ForzaUI;component/Textures/Anthem/Gradients/PreEventShadow.png" Opacity="{StaticResource A_Double_PreRaceIntro_UnderlayOpacity}"/>
                                <local:FZTextBlock Text="{local:Loc CarFlow.IDS_CarInfoLabel_InstructionText_RightOnly}" Style="{StaticResource A_Style_FZTextBlock_InstructionText}" />
                            </Grid>
                        </StackPanel>
                    </Viewbox>
                </Decorator>
            </ContentControl>
        </Grid>
        
        <local:AudioEvent x:Name="CarSelectInfoAppearAudioEvent" />
    </Grid>
</Page>
