<Page DataContext="{Binding RelativeSource={x:Static RelativeSource.Self}}"
      Style="{StaticResource A_Style_Page_Generic}"
      WindowTitle="Page"
      mc:Ignorable="d"
      x:Class="ForzaUI.A_CarDetails"
      x:Name="Page"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="clr-namespace:ForzaUI"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_NoAudio}"/>
    </local:UIPageTransitionManager.TransitionManager>
    <Page.Resources>
        <ResourceDictionary>
            <Style TargetType="FrameworkElement"
                   x:Key="A_Style_FrameworkElement_CarDetailsCost">
                <Setter Property="Opacity"
                        Value="0" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ShowCost}"
                                 Value="True">
                        <DataTrigger.EnterActions>
                            <BeginStoryboard>
                                <BeginStoryboard.Storyboard>
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                                  Value="1" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard.Storyboard>
                            </BeginStoryboard>
                        </DataTrigger.EnterActions>
                        <DataTrigger.ExitActions>
                            <BeginStoryboard>
                                <BeginStoryboard.Storyboard>
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="0:0:0.3"
                                                                  Value="0" />
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </BeginStoryboard.Storyboard>
                            </BeginStoryboard>
                        </DataTrigger.ExitActions>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
            <local:FZMaterialPresetAcrylicPanel x:Key="A_FZMaterialPresetAcrylicPanel_CRPanel"
                                        GlassColor="#FFA1A1A1"
                                        EdgeColor="#ff505050"
                                        Depth="0"
                                        FrontEdgeTransparency="0.5"
                                        BlurAmount="High"
                                        Reflectivity="0.2"
                                        ReflectionTextureType="Soft"
                                        NormalDepth="0.01"
                                        BasedOn="{StaticResource A_FZMaterialPresetAcrylicPanel_Base}"/>
            <Style x:Key="A_Style_FZMaterial_AcrylicPanel_CRPanel" TargetType="local:FZMaterial" >
                <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetAcrylicPanel_CRPanel}" />
                <Setter Property="Color" Value="{StaticResource A_Color_Acrylic_BodyPanel}" />
            </Style>

            <!--The preset for a small rounded corners for a material. Used in creating the linethrough effect-->
            <CornerRadius x:Key="A_SmallCornerRadius_Outer_All">3</CornerRadius>
            <local:FZMaterialPresetRoundtangle x:Key="A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll_Small"
                BasedOn="{StaticResource A_FZMaterialPreset_FlatPanel_Base}"
                CornerRadius="{StaticResource A_SmallCornerRadius_Outer_All}"/>

            <!-- Sale versions of IconValueBar overwrites backpanel colour in control-->
            <Style TargetType="Control" x:Key="A_Style_IconValueBar_SaleIcon" BasedOn="{StaticResource A_Style_IconValueBar}">
                <Style.Resources>
                    <Style x:Key="A_Style_IconBackground" TargetType="local:FZMaterial" BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_Base}">
                        <Setter Property="Color" Value="{StaticResource A_Color_CarDetails_Icon_SaleBackground}" />
                        <Setter Property="Preset" Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterLeftOnly}"/>
                    </Style>
                </Style.Resources>
            </Style>

            <!--Standard Version of IconValueBar. Style replaces the textblock resource with a textblock that has logic to handle displaying FREE condition-->
            <Style TargetType="Control" x:Key="A_Style_IconValueBar_FreeConditional" BasedOn="{StaticResource A_Style_IconValueBar}">
                <Style.Resources>
                    <Style x:Key="A_Style_FZTextBlock_IconValueBar" TargetType="local:FZTextBlock" BasedOn="{StaticResource A_Style_FZTextBlock_IconBarText}">
                        <Setter Property="Text" Value="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding (local:BindingProxy.A), RelativeSource={RelativeSource TemplatedParent}}" Value="0">
                                <Setter Property="Text" Value="{local:Loc InGameMarketplace.IDS_Free}" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Style.Resources>
            </Style>

            <!--Style Credits-->
            <Style TargetType="Control" x:Key="A_Style_IconValueBar_Credits" BasedOn="{StaticResource A_Style_IconValueBar_FreeConditional}">
                <Style.Resources>
                    <Style x:Key="A_Style_IconColor" TargetType="local:FZMaterial">
                        <Setter Property="Color" Value="{StaticResource A_Color_CarDetails_IconColor}" />
                        <Setter Property="ImageSourceNoPreload" Value="/ForzaUI;component/Textures/Anthem/Icons/Garage/Credits.png" />
                    </Style>
                </Style.Resources>
            </Style>

            <!--Style Tokens-->
            <Style TargetType="Control" x:Key="A_Style_IconValueBar_Tokens" BasedOn="{StaticResource A_Style_IconValueBar_FreeConditional}">
                <Style.Resources>
                    <Style x:Key="A_Style_IconColor" TargetType="local:FZMaterial">
                        <Setter Property="Color" Value="{StaticResource A_Color_CarDetails_IconColor}" />
                        <Setter Property="ImageSourceNoPreload" Value="/ForzaUI;component/Textures/Anthem/Icons/Garage/Tokens.png" />
                    </Style>
                </Style.Resources>
            </Style>

            <!--Style Sale Credits-->
            <Style TargetType="Control" x:Key="A_Style_IconValueBar_SaleCredits" BasedOn="{StaticResource A_Style_IconValueBar_SaleIcon}">
                <Style.Resources>
                    <Style x:Key="A_Style_IconColor" TargetType="local:FZMaterial">
                        <Setter Property="Color" Value="{StaticResource A_Color_CarDetails_IconColor}" />
                        <Setter Property="ImageSourceNoPreload" Value="/ForzaUI;component/Textures/Anthem/Icons/Garage/Credits.png" />
                    </Style>
                </Style.Resources>
            </Style>

            <!--Style Sale Tokens-->
            <Style TargetType="Control" x:Key="A_Style_IconValueBar_SaleTokens" BasedOn="{StaticResource A_Style_IconValueBar_SaleIcon}">
                <Style.Resources>
                    <Style x:Key="A_Style_IconColor" TargetType="local:FZMaterial">
                        <Setter Property="Color" Value="{StaticResource A_Color_CarDetails_IconColor}" />
                        <Setter Property="ImageSourceNoPreload" Value="/ForzaUI;component/Textures/Anthem/Icons/Garage/Tokens.png" />
                    </Style>
                </Style.Resources>
            </Style>

            <!--Style Sale Percentage-->
            <Style TargetType="Control" x:Key="A_Style_IconValueBar_SalePercentage" BasedOn="{StaticResource A_Style_IconValueBar_SaleIcon}">
                <Style.Resources>
                    <Style x:Key="A_Style_IconColor" TargetType="local:FZMaterial">
                        <Setter Property="Color" Value="{StaticResource A_Color_CarDetails_IconColor}" />
                        <Setter Property="ImageSourceNoPreload" Value="/ForzaUI;component/Textures/Anthem/Icons/Garage/Sales_Icon.png" />
                    </Style>
                </Style.Resources>
            </Style>

        </ResourceDictionary>
    </Page.Resources>

    <Grid x:Name="LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="Price">
                <VisualState x:Name="OnSale">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="SaleRow">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <local:PlayerBarControl Style="{StaticResource A_Style_PlayerBarControl_WithTokens}"
                        x:Name="TopBar" />
        <ContentControl Style="{StaticResource A_Style_ButtonBar}"
                        x:Name="BottomBar">
            <ContentControl Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}"
                            local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_Select}"
                            local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                            local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_ChangeCamera}"
                            x:Name="DefaultHelpPanel" />
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding}">
            <Grid Margin="-11,24,0,57"
                  Visibility="{Binding ShowCost, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}"
                  Style="{StaticResource A_Style_FrameworkElement_FadeOnlyTransition_0}"
                  x:Name="Costs" VerticalAlignment="Bottom">

                <StackPanel Orientation="Vertical">

                    <!-- Row of Original Cost. Original Credits, Original Tokens. Dashed line only exists during a sale (sale row visible)-->
                    <StackPanel Visibility="Visible" Orientation="Horizontal">
                        <!--Original Credit Cost-->
                        <Grid x:Name="CreditBlock">
                            <Control Style="{StaticResource A_Style_IconValueBar_Credits}"
                                    local:BindingProxy.A="{Binding CarCreditCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"
                                    Tag="{Binding OriginalCreditCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"/>

                            <local:FZMaterial x:Name="DashedCredit" Height="3" Color="{StaticResource A_Color_CarDetails_Text}"
                                              Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll_Small}"
                                              Margin="81,0,9,0" Visibility="{Binding Visibility, ElementName=SaleRow}"/>
                        </Grid>
                        <!--Original Token Cost-->
                        <Grid x:Name="TokenBlock" Visibility="{Binding AreTokensEnabled, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                            <Control Style="{StaticResource A_Style_IconValueBar_Tokens}"
                              local:BindingProxy.A="{Binding CarTokenCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"
                              Tag="{Binding OriginalTokenCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"/>

                            <local:FZMaterial x:Name="DashedToken" Height="3" Color="{StaticResource A_Color_CarDetails_Text}"
                                              Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll_Small}"
                                              Margin="81,0,9,0" Visibility="{Binding Visibility, ElementName=SaleRow}"/>
                        </Grid>
                    </StackPanel>

                    <!-- Row of Sale. Sale Credit Price, Sale Token Price, Percentage Discount Tag.-->
                    <StackPanel x:Name="SaleRow" Visibility="Collapsed" Orientation="Horizontal" Margin="0,6,0,0">
                        <!-- Sale Credits-->
                        <Decorator x:Name="DiscountedCreditBlock">
                            <Control Style="{StaticResource A_Style_IconValueBar_SaleCredits}"
                                    Tag="{Binding CarCreditCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"/>
                        </Decorator>
                        <!-- Sale Tokens-->
                        <Decorator x:Name="DiscountedTokenBlock" Visibility="{Binding AreTokensEnabled, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                            <Control Style="{StaticResource A_Style_IconValueBar_SaleTokens}"
                                    Tag="{Binding CarTokenCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"/>
                        </Decorator>
                        <!--Percentage Sale-->
                        <Decorator x:Name="DiscountBlock">
                            <Control Style="{StaticResource A_Style_IconValueBar_SalePercentage}"
                                    Tag="{Binding DiscountPercentage}"/>
                        </Decorator>
                    </StackPanel>

                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Page>
