<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>
            <local:NumUnitConverter x:Key="A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat"
                                    FractionDigits="0"
                                    ShowUnit="true" />
            <local:NumUnitConverter x:Key="A_UpgradeCarConfirmPopup_NumUnitConverter_LateralGs"
                                    FractionDigits="1"
                                    ShowUnit="false" />

            <Style x:Key="A_Style_FZTextBlock_UpgradeCarConfirmPopup_HeaderBlock"
                   BasedOn="{StaticResource A_Style_FZTextBlock_HeaderBlock}"
                   TargetType="{x:Type local:FZTextBlock}">
                <Setter Property="Stretch"
                        Value="Uniform" />
                <Setter Property="StretchDirection"
                        Value="DownOnly" />
                <Setter Property="MaxWidth"
                        Value="200" />
                <Setter Property="FontSize"
                        Value="32" />
                <Setter Property="Margin"
                        Value="0" />
            </Style>

            <Style x:Key="A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo"
                   TargetType="{x:Type local:FZTextBlock}"
                   BasedOn="{StaticResource A_Style_FZTextBlock_Heading_Small}">
                <Setter Property="CapHeight"
                        Value="16" />
                <Setter Property="Color"
                        Value="{StaticResource A_Color_SubHeader_Text}" />
                <Setter Property="HorizontalAlignment"
                        Value="Center" />
                <Setter Property="VerticalAlignment"
                        Value="Center" />
                <Setter Property="Stretch"
                        Value="Uniform" />
                <Setter Property="Margin"
                        Value="10" />
                <Setter Property="StretchDirection"
                        Value="DownOnly" />
                <Setter Property="MaxWidth"
                        Value="200" />
                <Style.Triggers>
                    <Trigger Property="Grid.Column">
                        <Trigger.Value>
                            <System:Int32>1</System:Int32>
                        </Trigger.Value>
                        <Setter Property="HorizontalAlignment"
                                Value="Left" />
                    </Trigger>
                </Style.Triggers>
            </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">
                    <Grid>
                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_OptionText}"
                                           Visibility="{Binding Value, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}">
                            <Run Text="{Binding Text, Converter={StaticResource A_StringToUpper}}" />
                            <Run Text=" - " />
                            <Run Text="{Binding Value, Converter={StaticResource A_StringToUpper}}"
                                 FontFamily="Horizon_C" />
                        </local:FZTextBlock>

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

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

            <Style x:Key="A_Style_RowDefinition_DataRow"
                   TargetType="RowDefinition">
                <Setter Property="Height"
                        Value="64" />
            </Style>

            <Style x:Key="A_Style_RowDefinition_ClassDataRow"
                   TargetType="RowDefinition">
                <Setter Property="Height"
                        Value="133" />
            </Style>

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

            <Style TargetType="local:FZMaterial"
                   x:Key="A_Style_FZMaterial_Change"
                       BasedOn="{StaticResource A_Style_FZMaterial_PerformanceStatsDelta}">
                <Setter Property="Preset"
                        Value="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_InnerAll}" />
                <Setter Property="Height"
                        Value="35" />
                <Setter Property="HorizontalAlignment"
                        Value="Center" />
                <Style.Triggers>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <System:Int32>0</System:Int32>
                            <!-- 0 IsNeutral -->
                        </Trigger.Value>
                        <Setter Property="Color"
                                Value="#00000000" />
                    </Trigger>
                    <Trigger Property="Grid.Column">
                        <Trigger.Value>
                            <System:Int32>1</System:Int32>
                        </Trigger.Value>
                        <Setter Property="HorizontalAlignment"
                                Value="Left" />
                        <Setter Property="Margin"
                                Value="14,0,0,0" />
                    </Trigger>
                </Style.Triggers>
            </Style>
            
            <Style TargetType="local:FZMaterial"
                   x:Key="A_Style_FZMaterial_Change_Arrow"
                   BasedOn="{StaticResource A_Style_FZMaterial_Change}">
                <Setter Property="Height"
                        Value="35" />
                <Setter Property="Width"
                        Value="43" />
                <Style.Triggers>
                    <Trigger Property="Tag">
                        <Trigger.Value>
                            <System:Int32>0</System:Int32>
                            <!-- 0 IsNeutral -->
                        </Trigger.Value>
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_Stat_Neutral_Light}" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <local:FZMaterialPresetGlassRoundtangle x:Key="A_Preset_BackgroundGlass"
                                                    BasedOn="{StaticResource A_FZMaterialPresetGlassRoundtangle_GlassPanel_OuterBottomOnly}"
                                                    BlurAmount="High"/>


        </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="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_ScreenTitleBlock}"
                                    local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Garage/Basket.png"
                                    HorizontalAlignment="Left" />
                </Decorator>
                <Grid Margin="0,0,0,6"
                      Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_1}"
                      Width="850">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="72" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition Height="52" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition Height="45" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition Height="45" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition Height="55" />
                        <RowDefinition Style="{StaticResource A_Style_RowDefinition_SeparatorRow}" />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition Height="22" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="25" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="0.75*" />
                        <ColumnDefinition Width="25" />
                    </Grid.ColumnDefinitions>

                    <!--  Body Background -->
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_BodyPanel}"
                                      Preset="{StaticResource A_Preset_BackgroundGlass}"
                                      Grid.Row="1"
                                      Grid.Column="0"
                                      Grid.ColumnSpan="6"
                                      Grid.RowSpan="12" />

                    <!--  Column Header Background -->
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FlatPanel_HeaderPanel}"
                                      Grid.Row="0"
                                      Grid.Column="0"
                                      Grid.ColumnSpan="6" />

                    <!-- Column Headers -->
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_HeaderBlock}"
                                       Text="{local:Loc Upgrades_flow.IDS_CarStat}"
                                       Grid.Row="0"
                                       Grid.Column="1"
                                       HorizontalAlignment="Left"
                                       Margin="17,0,0,0" />
                    <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="3" />
                    <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_HeaderBlock}"
                                       Text="{local:Loc Upgrades_flow.IDS_Result}"
                                       Grid.Row="0"
                                       Grid.Column="4"
                                       HorizontalAlignment="Center" />

                    <!-- Weight Row -->
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change}"
                                      Grid.Row="2"
                                      Grid.Column="1"
                                      VerticalAlignment="Bottom"
                                      Margin="14,5"
                                      Tag="{Binding CurbWeightChange}">
                        <local:FZTextBlock Text="{local:Loc Upgrades_flow.IDS_UPGRADE_WEIGHT}"
                                           Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}" />
                    </local:FZMaterial>
                    <local:FZTextBlock Text="{Binding CurrentStats.CurbWeight, ConverterParameter=mass, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat}}"
                                       Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}"
                                       VerticalAlignment="Bottom"
                                       Margin="0,15"
                                       Grid.Row="2"
                                       Grid.Column="2" />
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change}"
                                      Grid.Row="2"
                                      Grid.Column="3"
                                      VerticalAlignment="Bottom"
                                      Margin="0,5"
                                      Tag="{Binding CurbWeightChange}">
                        <local:FZTextBlock Text="{Binding UpgradedStats.CurbWeight, ConverterParameter=mass, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat}}"
                                           Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}" />
                    </local:FZMaterial>
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change_Arrow}"
                                      Grid.Row="2"
                                      Grid.Column="4"
                                      VerticalAlignment="Bottom"
                                      Margin="0,5"
                                      Tag="{Binding CurbWeightChange}">
                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetStreak_FloatingIconShadow}" CaptureSubgraph="True">
                            <Viewbox Margin="10">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrow}"
                                              Tag="{Binding CurbWeightChange}" />
                            </Viewbox>
                        </local:FZMaterial>
                    </local:FZMaterial>

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_HorizontalDivider}"
                                      Grid.Row="3"
                                      Grid.Column="1"
                                      Grid.ColumnSpan="4" />

                    <!-- Peak Power Row -->
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change}"
                                      Grid.Row="4"
                                      Grid.Column="1"
                                      Tag="{Binding SimPeakPowerChange}">
                        <local:FZTextBlock Text="{local:Loc Upgrades_flow.IDS_Peak_Power}"
                                           Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}" />
                    </local:FZMaterial>
                    <local:FZTextBlock Text="{Binding CurrentStats.SimPeakPower, ConverterParameter=power, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat}}"
                                       Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}"
                                       Grid.Row="4"
                                       Grid.Column="2" />
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change}"
                                      Grid.Row="4"
                                      Grid.Column="3"
                                      Tag="{Binding SimPeakPowerChange}">
                        <local:FZTextBlock Text="{Binding UpgradedStats.SimPeakPower, ConverterParameter=power, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_CarStat}}"
                                           Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}" />
                    </local:FZMaterial>
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change_Arrow}"
                                      Grid.Row="4"
                                      Grid.Column="4"
                                      Tag="{Binding SimPeakPowerChange}">
                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetStreak_FloatingIconShadow}"
                                          CaptureSubgraph="True">
                            <Viewbox Margin="10">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrow}"
                                                  Tag="{Binding SimPeakPowerChange}" />
                            </Viewbox>
                        </local:FZMaterial>
                    </local:FZMaterial>

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_HorizontalDivider}"
                                      Grid.Row="5"
                                      Grid.Column="1"
                                      Grid.ColumnSpan="4" />

                    <!-- Lateral G's Row -->
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change}"
                                      Grid.Row="6"
                                      Grid.Column="1"
                                      Tag="{Binding GripChange}">
                        <local:FZTextBlock Text="{local:Loc Upgrades_flow.IDS_Lateral_G}"
                                           Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}" />
                    </local:FZMaterial>
                    <local:FZTextBlock Text="{Binding CurrentStats.Grip, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_LateralGs}}"
                                       Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}"
                                       Grid.Row="6"
                                       Grid.Column="2" />
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change}"
                                      Grid.Row="6"
                                      Grid.Column="3"
                                      Tag="{Binding GripChange}">
                        <local:FZTextBlock Text="{Binding UpgradedStats.Grip, Converter={StaticResource A_UpgradeCarConfirmPopup_NumUnitConverter_LateralGs}}"
                                           Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}" />
                    </local:FZMaterial>
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change_Arrow}"
                                      Grid.Row="6"
                                      Grid.Column="4"
                                      Tag="{Binding GripChange}">
                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetStreak_FloatingIconShadow}"
                                          CaptureSubgraph="True">
                            <Viewbox Margin="10">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrow}"
                                                  Tag="{Binding GripChange}" />
                            </Viewbox>
                        </local:FZMaterial>
                    </local:FZMaterial>

                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_GlassPanel_HorizontalDivider}"
                                      Grid.Row="7"
                                      Grid.Column="1"
                                      Grid.ColumnSpan="4" />

                    <!-- Class Row -->
                    <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_Change}"
                                      VerticalAlignment="Bottom"
                                      Grid.Row="8"
                                      Grid.Column="1"
                                      Tag="{Binding PerformanceIndexChange}">
                        <local:FZTextBlock Text="{local:Loc Upgrades_flow.IDS_Class}"
                                           Style="{StaticResource A_Style_FZTextBlock_UpgradeCarConfirmPopup_StatInfo}" />
                    </local:FZMaterial>
                    <Control Grid.Row="8"
                             Grid.Column="2"
                             VerticalAlignment="Bottom"
                             Style="{StaticResource A_Style_Control_ClassControl}"
                             local:BindingProxy.A="{Binding CurrentStats.PerformanceIndex}"
                             local:BindingProxy.B="{Binding CurrentStats.ClassID}" />
                    <Control Grid.Row="8"
                             Grid.Column="3"
                             VerticalAlignment="Bottom"
                             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_Change_Arrow}"
                                      VerticalAlignment="Bottom"
                                      Grid.Row="8"
                                      Grid.Column="4"
                                      Tag="{Binding PerformanceIndexChange}">
                        <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetStreak_FloatingIconShadow}"
                                          CaptureSubgraph="True">
                            <Viewbox Margin="10">
                                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_PerformanceChangeArrow}"
                                                  Tag="{Binding PerformanceIndexChange}" />
                            </Viewbox>
                        </local:FZMaterial>
                    </local:FZMaterial>

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

                    <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_2}"
                                Grid.Row="11"
                                Grid.ColumnSpan="4"
                                Grid.Column="1">
                        <!-- Menu -->
                        <local:CommonListBox x:Name="ListBox_Menu"
                                             ItemsSource="{Binding MenuItems}"
                                             Style="{StaticResource A_Style_ListBox_TextMenu_Default}"
                                             ItemTemplate="{StaticResource A_DataTemplate_UpgradeCarConfirmPopup_TextMenu}" />
                    </StackPanel>
                </Grid>

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

</Page>
