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

        <Style x:Key="A_Style_FZTextBlock_CLC_StatLargeValue"
                TargetType="local:FZTextBlock"
                BasedOn="{StaticResource A_Style_FZTextBlock_CLC_StatValue}">
            <Setter Property="FontSize" Value="465" />
            <Setter Property="Margin" Value="-9,-112,0,0" />
        </Style>

        <Style x:Key="A_Style_FZTextBlock_CLC_StatLargeValueUnit"
                TargetType="local:FZTextBlock"
                BasedOn="{StaticResource A_Style_FZTextBlock_CLC_StatLargeValue}">
            <Setter Property="FontSize" Value="232" />
        </Style>

        <Style x:Key="A_Style_FZTextBlock_CLC_StatSmallValue"
                TargetType="local:FZTextBlock"
                BasedOn="{StaticResource A_Style_FZTextBlock_CLC_StatValue}">
            <Setter Property="FontSize" Value="142" />
            <Setter Property="Margin" Value="0,-36,0,0" />
        </Style>

        <ControlTemplate x:Key="A_Template_CLC_Layout2Stat_Left_Internal" TargetType="Control">
            <Grid Style="{StaticResource A_Style_Grid_ARUIMotionBlur}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                  Grid.Row="0">
                    <local:FZTextBlock Style="{TemplateBinding local:BindingProxy.A}" MaxWidth="700"
                                   Color="{StaticResource A_Color_CLC_ARUI_SubTitle}"
                                   Text="{Binding ItemTitle}" />
                </Grid>
                <StackPanel Orientation="Horizontal"
                        HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                        Grid.Row="1">
                    <Grid>
                        <local:FZTextBlock Style="{TemplateBinding local:BindingProxy.B}"
                                           Color="{StaticResource A_Color_CLC_ARUI_Content}"
                                           Text="{Binding ItemValue}"/>
                    </Grid>
                    <Grid Style="{StaticResource A_Style_Grid_CLC_StatIcon}"
                          Margin="6,6,0,88">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0.35*" />
                            <RowDefinition Height="0.65*" />
                        </Grid.RowDefinitions>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CLC_SkillTokenIcon}" Grid.Row="1"/>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CLC_CreditsIcon}" Grid.Row="1"/>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CLC_XPIcon}" Grid.Row="1"/>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CLC_FansIcon}" Grid.Row="1"/>
                    </Grid>
                    <Grid Style="{StaticResource A_Style_Grid_CLC_StatLabel}"
                          Margin="-4,0,0,52">
                        <local:FZTextBlock Style="{TemplateBinding local:BindingProxy.C}"
                                           Color="{StaticResource A_Color_CLC_ARUI_Content}"
                                           Text="{Binding ItemValueUnitLabel}"
                                           VerticalAlignment="Bottom"/>
                    </Grid>
                </StackPanel>
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="A_Template_CLC_Layout2Stat_Right_Internal" TargetType="Control">
            <Grid Style="{StaticResource A_Style_Grid_ARUIMotionBlur}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                      Grid.Row="0">
                    <local:FZTextBlock Style="{TemplateBinding local:BindingProxy.A}" MaxWidth="700"
                                   Color="{StaticResource A_Color_CLC_ARUI_SubTitle}"
                                   Text="{Binding ItemTitle}" />
                </Grid>
                <StackPanel Orientation="Horizontal"
                        HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                        Grid.Row="1">
                    <Grid>
                        <local:FZTextBlock Style="{TemplateBinding local:BindingProxy.B}"
                                    Color="{StaticResource A_Color_CLC_ARUI_Content}"
                                    Text="{Binding ItemValue}"/>
                    </Grid>
                    <Grid Style="{StaticResource A_Style_Grid_CLC_StatIcon}"
                          Margin="6,6,0,32">
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CLC_SkillTokenIcon}"/>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CLC_CreditsIcon}"/>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CLC_XPIcon}"/>
                        <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_CLC_FansIcon}"/>
                    </Grid>
                    <Grid Style="{StaticResource A_Style_Grid_CLC_StatLabel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Viewbox Grid.Row="1">
                            <Grid Margin="0,14,0,-14">
                                <local:FZTextBlock Style="{TemplateBinding local:BindingProxy.B}"
                                           Color="{StaticResource A_Color_CLC_ARUI_Content}"
                                           Text="{Binding ItemValueUnitLabel}"/>
                            </Grid>
                        </Viewbox>
                    </Grid>
                </StackPanel>
            </Grid>
        </ControlTemplate>

        <ControlTemplate x:Key="A_Template_CLC_Layout2Stat_Left" TargetType="Control">
            <Control Template="{StaticResource A_Template_CLC_Layout2Stat_Left_Internal}"
                     HorizontalAlignment="Left"
                     VerticalAlignment="Top"
                     local:BindingProxy.A="{StaticResource A_Style_FZTextBlock_CLC_StatTitle}"
                     local:BindingProxy.B="{StaticResource A_Style_FZTextBlock_CLC_StatLargeValue}"
                     local:BindingProxy.C="{StaticResource A_Style_FZTextBlock_CLC_StatLargeValueUnit}" />
        </ControlTemplate>

        <ControlTemplate x:Key="A_Template_CLC_Layout2Stat_Right" TargetType="Control">
            <Control Template="{StaticResource A_Template_CLC_Layout2Stat_Right_Internal}"
                     HorizontalAlignment="Right"
                     VerticalAlignment="Top"
                     local:BindingProxy.A="{StaticResource A_Style_FZTextBlock_CLC_StatTitle}"
                     local:BindingProxy.B="{StaticResource A_Style_FZTextBlock_CLC_StatSmallValue}" />

        </ControlTemplate>

    </Page.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="214"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="214"/>
        </Grid.ColumnDefinitions>

        <StackPanel Grid.Column="1">
            <Viewbox>
                <ContentControl x:Name="TitleControl"
                                Template="{StaticResource A_Template_CLC_DoubleLineTitle}" />
            </Viewbox>

            <StackPanel Margin="10,-15,10,0">
                <Grid>
                    <ContentControl x:Name="UnderlineControl"
                                Template="{StaticResource A_Template_CLC_TitleUnderline}" />
                </Grid>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <ContentControl x:Name="Stat0Control"
                                Style="{StaticResource A_Style_CLC_AnimatedControl}"
                                Content="{StaticResource A_Template_CLC_Layout2Stat_Left}"
                                Grid.Column="0"
                                DataContext="{Binding PlayerStats[0]}"/>
                    <StackPanel Orientation="Vertical" Grid.Column="2">
                        <ContentControl x:Name="Stat1Control"
                                    Style="{StaticResource A_Style_CLC_AnimatedControl}"
                                    Content="{StaticResource A_Template_CLC_Layout2Stat_Right}"
                                    Grid.Row="0"
                                    DataContext="{Binding PlayerStats[1]}"/>
                        <ContentControl x:Name="Stat2Control"
                                    Style="{StaticResource A_Style_CLC_AnimatedControl}"
                                    Content="{StaticResource A_Template_CLC_Layout2Stat_Right}"
                                    Grid.Row="1"
                                    DataContext="{Binding PlayerStats[2]}"/>
                    </StackPanel>
                </Grid>

            </StackPanel>
        </StackPanel>

        <local:EventFire x:Name="TitleEventFire" TargetName="TitleControl" />
        <local:EventFire x:Name="UnderlineEventFire" TargetName="UnderlineControl" />
        <local:EventFire x:Name="Stat0ControlEventFire" TargetName="Stat0Control" />
        <local:EventFire x:Name="Stat1ControlEventFire" TargetName="Stat1Control" />
        <local:EventFire x:Name="Stat2ControlEventFire" TargetName="Stat2Control" />

        <!-- Audio Events -->
        <local:AudioEvent x:Name="TitleAudioEvent" />
        <local:AudioEvent x:Name="Stat0AudioEvent" />
        <local:AudioEvent x:Name="Stat1AudioEvent" />
        <local:AudioEvent x:Name="Stat2AudioEvent" />
    </Grid>

</Page>
