<Page 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"
      xmlns:local="clr-namespace:ForzaUI"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      x:Class="ForzaUI.Scenes.Anthem.A_UpgradeCarConfirmPopup"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Popup}" />
    </local:UIPageTransitionManager.TransitionManager>

    <Page.Resources>
        <ResourceDictionary>

            <System:Double x:Key="A_Double_Row_Width">668</System:Double>

            <local:NumUnitConverter x:Key="A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat"
                                    FractionDigits="0"
                                    ShowUnit="true" />
            <local:NumUnitConverter x:Key="A_UpgradeCarConfirmPopup_NumUnitConverter_LateralGs"
                                    FractionDigits="1"
                                    ShowUnit="false" />
            <local:NumUnitConverter x:Key="A_UpgradeCarConfirmPopup_NumUnitConverter_PWR"
                                    FractionDigits="2"
                                    ShowUnit="true" />

            <Style TargetType="{x:Type local:FZRun}"
                       x:Key="A_Style_FZRun_UpgradeConfirm_HIGHLIGHT">
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_Yellow}"/>
            </Style>
                <MappingConverter x:Key="A_MappingConverter_UpgradeConfirm">
                        <MappingConverterEntry Key="{NoCase HIGHLIGHT}" Value="{StaticResource A_Style_FZRun_UpgradeConfirm_HIGHLIGHT}" />
                </MappingConverter>

            <Style x:Key="A_Style_FZMaterial_UpgradeCarConfirmPopup_HorizontalDivider"
                    BasedOn="{StaticResource A_Style_FZMaterial_GlassPanel_HorizontalDivider}"
                    TargetType="{x:Type local:FZMaterial}">
                <Setter Property="Margin"
                        Value="9,0,9,0" />
                <Setter Property="Grid.ColumnSpan"
                        Value="5" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_UpgradeCarConfirmPopup_HeaderBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_HeaderBlock}"
                   TargetType="{x:Type local:FZTextBlock}">
                <Setter Property="FontFamily"
                        Value="Horizon_B" />
                <Setter Property="Color"
                        Value="{StaticResource H_Color_Primary_White}" />
                <Setter Property="Stretch"
                        Value="Uniform" />
                <Setter Property="StretchDirection"
                        Value="DownOnly" />
                <Setter Property="HorizontalAlignment"
                        Value="Left" />
                <Setter Property="MaxWidth"
                        Value="200" />
                <Setter Property="CapHeight"
                        Value="20" />
                <Setter Property="Margin"
                        Value="0" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_UpgradeStat_Label" TargetType="FZTextBlock"
                BasedOn="{StaticResource A_Style_FZTextBlock_StatLabel}">
                <Setter Property="Color" Value="{StaticResource H_Color_Primary_White}"/>
                <Setter Property="CapHeight" Value="18"/>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_UpgradeCarConfirmPopup_MsgBody"
                   TargetType="{x:Type local:FZTextBlock}"
                   BasedOn="{StaticResource A_Style_FZTextBlock_PopupText}">
                <Setter Property="Width"
                        Value="Auto" />
                <Setter Property="HorizontalAlignment"
                        Value="Left" />
                <Setter Property="TextAlignment"
                        Value="Left" />
            </Style>

            <DataTemplate x:Key="A_DataTemplate_UpgradeCarConfirmPopup_TextMenu">
                <Decorator Height="48"
                           HorizontalAlignment="Center" IsHitTestVisible="False">
                    <StackPanel Orientation="Horizontal">
                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                                           Margin="0,2,0,2"
                                           Visibility="{Binding Value, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}">
                            <Run Text="{Binding Text, Converter={StaticResource A_StringToUpper}}" />
                            <Run Text=" - " />
                        </local:FZTextBlock>

                        <Control Style="{StaticResource H_Style_Control_CreditsIcon}" Margin="8,8,4,8"
                                 Visibility="{Binding Value, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}"/>
                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                                           Margin="0,2,0,2"
                                           Visibility="{Binding Value, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}">
                            <Run Text="{Binding Value, Converter={StaticResource A_StringToUpper}}"
                                 FontFamily="Horizon_C" />
                        </local:FZTextBlock>

                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                                           Margin="0,2,0,2"
                                           Visibility="{Binding Value, Converter={StaticResource A_StringVisConverter_Inverse}, FallbackValue=Visible}">
                            <Run Text="{Binding Text, Converter={StaticResource A_StringToUpper}}" />
                        </local:FZTextBlock>
                    </StackPanel>
                </Decorator>
            </DataTemplate>

            <Style x:Key="A_Style_RowDefinition_SeparatorRow"
                   TargetType="RowDefinition">
                <Setter Property="Height"
                        Value="2" />
            </Style>

            <Style x:Key="A_Style_Control_ClassControl"
                   TargetType="Control"
                   BasedOn="{StaticResource A_Style_Control_CarClassBadge_Small_Default}">
                <Setter Property="HorizontalAlignment"
                        Value="Left" />
                <Setter Property="VerticalAlignment"
                        Value="Center" />
            </Style>

        </ResourceDictionary>
    </Page.Resources>

    <Grid>
        <local:FZMaterialGlassCapture />
        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Popup_Background}"/>

        <local:PlayerBarControl x:Name="TopBar"
                                Style="{StaticResource A_Style_PlayerBarControl_WithTokens}" />
        <ContentControl x:Name="BottomBar"
                        Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="PART_DefaultHelpPanel"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>
        <Grid Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}">
            <StackPanel x:Name="MainContent"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center">
                <Decorator Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                    <ContentControl Content="{local:Loc UpgradeCar.IDS_Buy}"
                                    Style="{StaticResource A_Style_ContentControl_PopupTitleBlock}"
                                    BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Garage/Basket.png"/>
                </Decorator>

                <!--Header-->
                <Grid Margin="0,4,0,0"
                      Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}"
                      Width="{StaticResource A_Double_Row_Width}">

                    <Grid.RowDefinitions>
                        <RowDefinition Height="44" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="17" />
                        <ColumnDefinition Width="228" />
                        <ColumnDefinition Width="188" />
                        <ColumnDefinition Width="57" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <!--  Column Header Background -->
                    <local:FZMaterial Style="{StaticResource H_Style_Container_GlassHighBlur_Description}"
                                      Color="{StaticResource H_Color_Glass_Purple_60pc}"
                                      Height="auto"
                                      Grid.Row="0"
                                      Grid.Column="0"
                                      Grid.ColumnSpan="5" />

                    <!-- Column Headers -->
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_HeaderBlock}"
                                       Text="{local:Loc Upgrades_flow.IDS_CarStat}"
                                       Grid.Row="0"
                                       Grid.Column="1" />
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_HeaderBlock}"
                                       Text="{local:Loc Upgrades_flow.IDS_Previous}"
                                       Grid.Row="0"
                                       Grid.Column="2" />
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_HeaderBlock}"
                                       Text="{local:Loc Upgrades_flow.IDS_New}"
                                       Grid.Row="0"
                                       Grid.Column="4" />
                </Grid>

                <!--Body-->
                <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}"
                      Width="{StaticResource A_Double_Row_Width}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="52" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition Height="52" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition Height="52" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition Height="52" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition Height="52" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="17" />
                        <ColumnDefinition Width="228" />
                        <ColumnDefinition Width="188" />
                        <ColumnDefinition Width="57" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <!--  Body Background -->
                    <local:FZMaterial Color="{StaticResource H_Color_Glass_Purple_40pc}"
                                      Preset="{StaticResource H_GlassRoundtangle_1px}"
                                      Grid.Row="0"
                                      Grid.Column="0"
                                      Grid.ColumnSpan="5"
                                      Grid.RowSpan="9" />

                    <!-- Weight Row -->
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_UpgradeStat_Label}"
                            Grid.Row="0"
                            Grid.Column="1"
                            Text="{local:Loc Upgrades_flow.IDS_UPGRADE_WEIGHT}" />

                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_StatInfo}"
                            Grid.Row="0"
                            Grid.Column="2" 
                            Text="{Binding CurrentStats.CurbWeight, ConverterParameter=mass, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat}}" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change_Arrow}"
                            Grid.Row="0"
                            Grid.Column="3"
                            Tag="{Binding CurbWeightChange}" 
                            Color="{Binding CurbWeightChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Visibility="{Binding CurbWeightChange, Converter={StaticResource A_Converter_Arrow_ChangeToVisibility}}" />

                    <local:FZTextBlock  Style="{StaticResource A_Style_FZTextBlock_StatInfo}" 
                            Grid.Row="0"
                            Grid.Column="4"
                            Color="{Binding CurbWeightChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Text="{Binding UpgradedStats.CurbWeight, ConverterParameter=mass, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat}}" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_UpgradeCarConfirmPopup_HorizontalDivider}"
                            Grid.Row="1" />
                    
                    <!-- Peak Power Row -->
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_UpgradeStat_Label}"
                            Grid.Row="2"
                            Grid.Column="1"
                            Text="{local:Loc Upgrades_flow.IDS_Peak_Power}" />

                    <local:FZTextBlock Text="{Binding CurrentStats.SimPeakPower, ConverterParameter=power, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat}}"
                                       Style="{StaticResource A_Style_FZTextBlock_StatInfo}"
                                       Grid.Row="2"
                                       Grid.Column="2" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change_Arrow}"
                            Grid.Row="2"
                            Grid.Column="3"
                            Tag="{Binding SimPeakPowerChange}" 
                            Color="{Binding SimPeakPowerChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Visibility="{Binding SimPeakPowerChange, Converter={StaticResource A_Converter_Arrow_ChangeToVisibility}}" />

                    <local:FZTextBlock  Style="{StaticResource A_Style_FZTextBlock_StatInfo}" 
                            Grid.Row="2"
                            Grid.Column="4"
                            Color="{Binding SimPeakPowerChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Text="{Binding UpgradedStats.SimPeakPower, ConverterParameter=power, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat}}" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_UpgradeCarConfirmPopup_HorizontalDivider}"
                            Grid.Row="3" />

                    <!-- PowerToWeight -->
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_UpgradeStat_Label}"
                            Grid.Row="4"
                            Grid.Column="1"
                            Text="{local:Loc Upgrades_flow.IDS_PowerToWeight}" />

                    <local:FZTextBlock Text="{Binding CurrentStats.PowerToWeight, ConverterParameter=PowerToWeight, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_PWR}}"
                                       Style="{StaticResource A_Style_FZTextBlock_StatInfo}"
                                       Grid.Row="4"
                                       Grid.Column="2" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change_Arrow}"
                            Grid.Row="4"
                            Grid.Column="3"
                            Tag="{Binding PowerToWeightChange}" 
                            Color="{Binding PowerToWeightChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Visibility="{Binding PowerToWeightChange, Converter={StaticResource A_Converter_Arrow_ChangeToVisibility}}" />

                    <local:FZTextBlock  Style="{StaticResource A_Style_FZTextBlock_StatInfo}" 
                            Grid.Row="4"
                            Grid.Column="4"
                            Color="{Binding PowerToWeightChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Text="{Binding UpgradedStats.PowerToWeight, ConverterParameter=PowerToWeight, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_PWR}}" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_UpgradeCarConfirmPopup_HorizontalDivider}"
                            Grid.Row="5" />

                    <!-- Lateral G's Row -->
                    <local:FZTextBlock 
                            Grid.Row="6"
                            Grid.Column="1"
                            Text="{local:Loc Upgrades_flow.IDS_Lateral_G}"
                            Style="{StaticResource A_Style_FZTextBlock_UpgradeStat_Label}" />

                    <local:FZTextBlock Text="{Binding CurrentStats.Grip, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_LateralGs}}"
                                       Style="{StaticResource A_Style_FZTextBlock_StatInfo}"
                                       Grid.Row="6"
                                       Grid.Column="2" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change_Arrow}"
                            Grid.Row="6"
                            Grid.Column="3"
                            Tag="{Binding GripChange}" 
                            Color="{Binding GripChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Visibility="{Binding GripChange, Converter={StaticResource A_Converter_Arrow_ChangeToVisibility}}" />

                    <local:FZTextBlock  Style="{StaticResource A_Style_FZTextBlock_StatInfo}" 
                            Grid.Row="6"
                            Grid.Column="4"
                            Color="{Binding GripChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Text="{Binding UpgradedStats.Grip, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_LateralGs}}" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_UpgradeCarConfirmPopup_HorizontalDivider}"
                                      Grid.Row="7" />

                    <!-- Class Row -->
                    <local:FZTextBlock Text="{local:Loc Upgrades_flow.IDS_Class}"
                                        Style="{StaticResource A_Style_FZTextBlock_UpgradeStat_Label}" 
                                        Grid.Row="8"
                                        Grid.Column="1" />

                    <Control Grid.Row="8"
                            Grid.Column="2"
                            Style="{StaticResource A_Style_Control_ClassControl}"
                            local:BindingProxy.A="{Binding CurrentStats.PerformanceIndex}"
                            local:BindingProxy.B="{Binding CurrentStats.ClassID}" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change_Arrow}"
                            Grid.Row="8"
                            Grid.Column="3"
                            Tag="{Binding PerformanceIndexChange}" 
                            Color="{Binding PerformanceIndexChange, Converter={StaticResource A_Converter_ChangeToColor}}"
                            Visibility="{Binding PerformanceIndexChange, Converter={StaticResource A_Converter_Arrow_ChangeToVisibility}}" />

                    <Control Grid.Row="8"
                             Grid.Column="4"
                             Style="{StaticResource A_Style_Control_ClassControl}"
                             local:BindingProxy.A="{Binding UpgradedStats.PerformanceIndex}"
                             local:BindingProxy.B="{Binding UpgradedStats.ClassID}" />

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_UpgradeCarConfirmPopup_HorizontalDivider}"
                            Grid.Row="9" />

                    <!-- Message Row -->
                    <local:FZTextBlock Grid.Row="10"
                                       Grid.ColumnSpan="5"
                                       Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_MsgBody}"
                                       TextAlignment="Center"
                                       Margin="0,25,0,25"
                                       HorizontalAlignment="Center"
                                       MarkupConverter="{StaticResource A_MappingConverter_UpgradeConfirm}"
                                       Text="{Binding Message}" />
                </Grid>

                <!-- Options -->
                <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}"
                            Width="{StaticResource A_Double_Row_Width}"
                            Margin="0,2">
                    <!-- Menu -->
                    <local:CommonListBox x:Name="PART_Menu"
                                             ItemsSource="{Binding Options}"
                                             Style="{StaticResource A_Style_ListBox_TextMenu_Default}"
                                             ItemTemplate="{StaticResource A_DataTemplate_UpgradeCarConfirmPopup_TextMenu}" />
                </StackPanel>

            </StackPanel>
        </Grid>
    </Grid>

</Page>
