<Page x:Name="Page"
      x:Class="ForzaUI.A_LiveryBackground"
      xmlns:local="clr-namespace:ForzaUI"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      mc:Ignorable="d"
      DataContext="{Binding RelativeSource={x:Static RelativeSource.Self}}">

    <Page.Resources>
        <ResourceDictionary>
            <System:Double x:Key="A_Double_BackgroundScale">0.0000618</System:Double>

            <Style x:Key="A_Style_FZMaterial_BackgroundTile"
                   TargetType="local:FZMaterial">
                <Setter Property="TextureWrap"
                        Value="True"/>
                <Setter Property="ImageTransform">
                    <Setter.Value>
                        <TransformGroup>
                            <ScaleTransform ScaleX="{Binding BackgroundScaleY, RelativeSource={RelativeSource AncestorType=Page}}"
                                            ScaleY="{Binding BackgroundScaleX, RelativeSource={RelativeSource AncestorType=Page}}" />
                            <TranslateTransform X="1"
                                                Y="-0.044" />
                        </TransformGroup>
                    </Setter.Value>
                </Setter>
            </Style>

        </ResourceDictionary>
    </Page.Resources>

    <Grid x:Name="LayoutRoot">
        <local:FZMaterial x:Name="CompositionTarget" CaptureSubgraph="True">
            <Grid>
                <local:FZMaterial x:Name="DarkBackground" ImageSource="/ForzaUI;component/Textures/Anthem/Paintshop/Grid_Vignette_Dark_BG.png"/>

                <local:FZMaterial x:Name="LightBackground" ImageSource="/ForzaUI;component/Textures/Anthem/Paintshop/Grid_Vignette_Light_BG.png" Color="#FFCCCCC3"
                                    Visibility="{Binding UseDarkBackground, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}" />

                <local:LiveryTextureRenderElement x:Name="PART_Image_BackgroundTexture"
                                                  Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Page}}"
                                                  Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Page}}"
                                                  HorizontalAlignment="Center"
                                                  VerticalAlignment="Center">
                    <local:LiveryTextureRenderElement.RenderSize>
                        <Size Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Page}}"
                              Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType=Page}}" />
                    </local:LiveryTextureRenderElement.RenderSize>
                </local:LiveryTextureRenderElement>
            </Grid>
        </local:FZMaterial>

        <Grid x:Name="Grid_LiveryLines" Margin="-45,-63" Visibility="{Binding ShowGrid, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">			    
            <Grid Visibility="{Binding UseDarkBackground, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">   
                <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Anthem/Paintshop/Livery_Grid_Tile_ForDarkVignette.png"
                                  Style="{StaticResource A_Style_FZMaterial_BackgroundTile}" />
            </Grid>

            <Grid Visibility="{Binding UseDarkBackground, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Anthem/Paintshop/Livery_Grid_Tile_ForLightVignette.png"
                                  Style="{StaticResource A_Style_FZMaterial_BackgroundTile}" />
            </Grid>
        </Grid>

        <!-- When this scene is up there is no world to capture for the popups, so put one here -->
        <local:FZMaterialGlassCapture />

    </Grid>
</Page>