<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_HorizonA}">
                <Setter Property="Color" Value="{StaticResource A_Color_White}" />
                <Setter Property="LayoutTransform">
                    <Setter.Value>
                        <TransformGroup>
                            <SkewTransform AngleX="-7"/>
                        </TransformGroup>
                    </Setter.Value>
                </Setter>
            </Style>

            <CornerRadius x:Key="A_SmallCornerRadius_LineEndings">3</CornerRadius>
            <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_LineEndings"
                BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                CornerRadius="{StaticResource A_SmallCornerRadius_LineEndings}"/>

            <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}" />
            </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 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>

            <local:MappingConverter x:Key="A_MappingConverter_Should_Override_CarManufactur_Logo_Dimensions" Default="{StaticResource A_Boolean_False}">
                <local:MappingConverterEntry Key="27" Value="{StaticResource A_Boolean_True}"/>
            </local:MappingConverter>

            <!--Different makes have different overriding size behavior for logo. -->
            <local:MappingConverter x:Key="A_MappingConverter_Override_Logo_Width" Default="180">
                <local:MappingConverterEntry Key="27" Value="332"/> <!-- SENNA -->
            </local:MappingConverter>
            <local:MappingConverter x:Key="A_MappingConverter_Override_Logo_Height" Default="180">
                <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="FontSize" Value="46" />
                <Setter Property="FontFamily" Value="Horizon_C"/>
                <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="FontSize" Value="112" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_InstructionText" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_Base}">
                <Setter Property="FontSize" Value="48" />
                <Setter Property="FontFamily" Value="Horizon_D"/>
            </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" />

            <Thickness x:Key="A_Thickness_CarInfoContainerMargin">4,4,4,0</Thickness>
            <Thickness x:Key="A_Thickness_CarInfoContainerMargin_CHS">4,9,4,0</Thickness>
        </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="Unfocused" GeneratedDuration="0:0:0.3" To="Focused" Storyboard="{StaticResource A_Storyboard_UnfocusedToFocused}" />
                    <VisualTransition From="Focused" GeneratedDuration="0:0:0.3" To="Unfocused" Storyboard="{StaticResource A_Storyboard_FocusedToUnfocused}" />
                    <VisualTransition From="Focused" GeneratedDuration="0:0:0.3" To="Hidden"/>
                    <VisualTransition From="Unfocused" GeneratedDuration="0:0:0.75" To="Hidden" Storyboard="{StaticResource A_Storyboard_FocusedToHidden}" />
                    <VisualTransition From="Hidden" GeneratedDuration="0:0:0.3" To="Focused" Storyboard="{StaticResource A_Storyboard_HiddenToFocused}" />
                    <VisualTransition From="Hidden" GeneratedDuration="0:0:0.3" To="Unfocused" Storyboard="{StaticResource A_Storyboard_HiddenToUnfocused}" />
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Hidden">
                    <Storyboard>
                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ContainerGrid">
                            <DiscreteDoubleKeyFrame KeyTime="0" Value="0.0"/>
                        </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Focused">
                    <Storyboard>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="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="{local:LocalizedResource A_Thickness_CarInfoContainerMargin}" 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, FallbackValue=PORSCHE}" Style="{StaticResource A_Style_FZTextBlock_CarName_Mfr}" HorizontalAlignment="Center" Margin="0,0,0,14"/>
                            <local:FZTextBlock Text="{Binding NameLine2, FallbackValue=CAYMAN GT4}" 
                                       TrackingAdjust="{Binding ModelId, Converter={StaticResource A_MappingConverter_Model_Tracking_Adjust}, FallbackValue=0.1}" 
                                       Style="{StaticResource A_Style_FZTextBlock_CarName}"  
                                       HorizontalAlignment="Center" Margin="0,0,0,14"/>
                        </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 A_Color_White}" Preset="{StaticResource A_FZMaterialPresetRoundtangle_LineEndings}" 
                                  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>
                    <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_Default_ShowAlways}" />
                        </Viewbox>
                        <local:FZTextBlock Text="{local:Loc CarFlow.IDS_CarInfoLabel_InstructionText_RightOnly}" Style="{StaticResource A_Style_FZTextBlock_InstructionText}" />
                    </StackPanel>
                </Decorator>
            </ContentControl>
        </Grid>
        
        <local:AudioEvent x:Name="CarSelectInfoAppearAudioEvent" />
    </Grid>
</Page>
