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

            <Style x:Key="A_Style_FZTextBlock_Sales" TargetType="local:FZTextBlock" 
                BasedOn="{StaticResource A_Style_FZTextBlock_IconBarText}">
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}" />
                <Setter Property="TextAlignment" Value="Center" />
                <Setter Property="Margin" Value="10,0" />
            </Style>

            <Style x:Key="A_Style_IconValueBar_SaleIcon" TargetType="Control">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Control">
                            <Grid Height="68">
                                <StackPanel Orientation="Horizontal">
                                    <FZMaterial Width="38" 
                                                ImageSourceNoPreload="/ForzaUI;component/Textures/Anthem/Icons/Garage/Discount_Tag_End_1.png" />
                                    <FZMaterial Margin="-1,0" 
                                                ImageSourceNoPreload="/ForzaUI;component/Textures/Anthem/Icons/Garage/Discount_Tag_Middle.png">
                                        <FZTextBlock Style="{StaticResource A_Style_FZTextBlock_Sales}"
                                                     Text="{TemplateBinding Tag}"/>
                                    </FZMaterial>
                                    <FZMaterial Width="16" 
                                                ImageSourceNoPreload="/ForzaUI;component/Textures/Anthem/Icons/Garage/Discount_Tag_End_2.png" />
                                </StackPanel>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="A_Style_IconValueBar" TargetType="Control">
                <Style.Resources>
                    <ResourceDictionary>
                        <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>
                        <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_Background}" />
                            <Setter Property="Preset"
                                    Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll1px}" />
                            <Setter Property="Width"
                                    Value="300" />
                        </Style>
                        <Style x:Key="A_Style_IconColor" TargetType="local:FZMaterial">
                            <Setter Property="ImageSourceNoPreload"
                                    Value="game:\Media\UI\Textures\Data_Bound\Currency\Credits_Large.png" />
                        </Style>
                    
                    </ResourceDictionary>
                </Style.Resources>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Control">
                            <FZMaterial Style="{DynamicResource A_Style_IconBackground}">
                                <StackPanel Orientation="Horizontal"
                                            Margin="48,0,48,0"
                                            HorizontalAlignment="Center">
                                    <FZMaterial Style="{DynamicResource A_Style_IconColor}"
                                                Width="28"
                                                Height="28" 
                                                Margin="5,0"/>
                                    <Grid>
                                        <FZTextBlock x:Name="RetailPrice"
                                                    Style="{DynamicResource A_Style_FZTextBlock_IconValueBar}" />

                                        <FZMaterial x:Name="DashedCredit" 
                                                    Height="3" 
                                                    Color="{StaticResource A_Color_CarDetails_Text}"
                                                    Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterAll_Small}"
                                                    Width="{Binding ActualWidth, ElementName=RetailPrice, Converter={LinearTransformConverter Add=20}}"
                                                    Margin="0,0,10,0" 
                                                    Visibility="{Binding (BindingProxy.B), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource A_Converter_BoolToVis}}"/>
                                    </Grid>
                                </StackPanel>
                            </FZMaterial>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </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 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="ImageSourceNoPreload" Value="/ForzaUI;component/Textures/Anthem/Icons/Garage/Tokens_Icon.png" />
                    </Style>
                </Style.Resources>
            </Style>

        </ResourceDictionary>
    </Page.Resources>

    <Grid x:Name="PART_LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="Price">
                <VisualState x:Name="PART_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="PART_DefaultHelpPanel" />
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding}">
            <Grid Margin="-2,24,0,43"
                  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 x:Name="CreditCost"
                                     Style="{StaticResource A_Style_IconValueBar_FreeConditional}"
                                     BindingProxy.A="{Binding CarCreditCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"
                                     BindingProxy.B="{Binding Visibility, ElementName=SaleRow, Converter={StaticResource A_Converter_VisibilityToBool}}"
                                     Tag="{Binding OriginalCreditCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"/>
                        </Grid>
                        <!--Original Token Cost-->
                        <Grid x:Name="TokenBlock" Visibility="{Binding AreTokensEnabled, Source={StaticResource PART_UISceneContext}, 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}"
                              BindingProxy.B="{Binding Visibility, ElementName=SaleRow, Converter={StaticResource A_Converter_VisibilityToBool}}"
                              Tag="{Binding OriginalTokenCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"/>
                        </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_FreeConditional}"
                                    Tag="{Binding CarCreditCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"/>
                        </Decorator>
                        <!-- Sale Tokens-->
                        <Decorator x:Name="DiscountedTokenBlock" 
                                   Visibility="{Binding AreTokensEnabled, Source={StaticResource PART_UISceneContext}, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                            <Control Style="{StaticResource A_Style_IconValueBar_Tokens}"
                                     Tag="{Binding CarTokenCost, ConverterParameter=money, Converter={StaticResource A_NumUnitConverter_NoUnit_0dp}, FallbackValue=0}"/>
                        </Decorator>
                        <!--Percentage Sale-->
                        <Decorator x:Name="DiscountBlock"
                                   Margin="8,0,0,0">
                            <Control Style="{StaticResource A_Style_IconValueBar_SaleIcon}"
                                     Tag="{Binding DiscountPercentage}"/>
                        </Decorator>
                    </StackPanel>

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