<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:system="clr-namespace:System;assembly=mscorlib">

    <BooleanToVisibilityConverter x:Key="BoolToVisConverter"/>

    <!-- PROGRESSION RAMP DATA TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <DataTemplate x:Key="Content.ProgressionRamp">
        <Grid Height="72" Width="72">
            <Path
                Data="F1M28.9915,1.16625C30.2334,0.445125 31.7666,0.445125 33.0085,1.16625L60.0085,16.8437C61.2413,17.5595 62,18.8773 62,20.3028V51.6972C62,53.1227 61.2413,54.4405 60.0085,55.1563L33.0085,70.8337C31.7666,71.5549 30.2334,71.5549 28.9915,70.8337L1.99146,55.1563C0.758669,54.4405 0,53.1227 0,51.6972V20.3028C0,18.8773 0.75867,17.5595 1.99146,16.8437L28.9915,1.16625z"
                Stretch="Fill"
                Height="72"
                Width="62"
                Fill="{DynamicResource Color.Fill.Player.ProgressionRamp}"
                Stroke="{DynamicResource Color.Border.Player.ProgressionRamp}"
                StrokeThickness="2"/>

            <Image
                Source="{Binding Icon}"
                Width="48"
                Height="48"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"/>

            <TextBlock
                Text="{Binding Number}"
                TextAlignment="Center"
                VerticalAlignment="Bottom"
                HorizontalAlignment="Center"
                FontFamily="{DynamicResource Font.LexendBold}"
                FontSize="{DynamicResource Font.Size.Default}"
                Foreground="{DynamicResource Color.Text}"
                Margin="0,0,0,8"
                Stroke="{DynamicResource Color.TextStrokeHeavy}"
                StrokeThickness="4"
                Effect="{DynamicResource Shadow.Text}"/>
        </Grid>
    </DataTemplate>

    <!-- BUSINESS CARD DATA TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <DataTemplate x:Key="Content.BusinessCard">
        <Grid
            x:Name="Content"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            Background="Transparent"
            ContextMenu="{DynamicResource ContextMenu.SocialItem}">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="8"/>
                <ColumnDefinition Width="72"/>
                <ColumnDefinition Width="12"/>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="16"/>
            </Grid.ColumnDefinitions>

            <Border
                x:Name="Player.ProfilePicture"
                Grid.Column="1"
                Height="72"
                Width="72"
                CornerRadius="36"
                ClipToBounds="True"
                BorderThickness="2"
                BorderBrush="{DynamicResource Color.Border.Player.ProfilePicture}"
                Margin="0"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">

                <Border.Background>
                    <ImageBrush ImageSource="{Binding ProfilePictureImage}"/>
                </Border.Background>
            </Border>

            <StackPanel
                x:Name="Player.Info"
                Grid.Column="3"
                VerticalAlignment="Center">

                <TextBlock
                    x:Name="Player.Name"
                    Text="{Binding LocalPlayerName.Value}"
                    TextWrapping="Wrap"
                    FontFamily="{DynamicResource Font.CoreSansBold}"
                    FontSize="{DynamicResource Font.Size.Heading2}"
                    Foreground="{DynamicResource Color.Text}"
                    Effect="{DynamicResource Shadow.Text}"/>

                <TextBlock
                    x:Name="Player.Title"
                    Text="{Binding Title}"
                    TextWrapping="Wrap"
                    FontFamily="{DynamicResource Font.CoreSans}"
                    FontSize="{DynamicResource Font.Size.Default}"
                    Foreground="{DynamicResource Color.Text}"
                    Effect="{DynamicResource Shadow.Text}"/>
            </StackPanel>

            <ItemsControl
                x:Name="ProgressionRampControl"
                Grid.Column="4"
                ItemsSource="{Binding ProgressionRamps.ProgressionItems}"
                ItemTemplate="{StaticResource Content.ProgressionRamp}"
                HorizontalAlignment="Right"
                Focusable="False">

                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Grid>

        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Title}" Value="">
                <Setter Property="Visibility" Value="Collapsed" TargetName="Player.Title"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <!-- BUSINESS CARD DISPLAYED IN HUD TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <ControlTemplate x:Key="Template.BusinessCard">
        <Grid x:Name="Root"
            Width="644"
            Height="88"
            Background="Transparent">

            <Border
                x:Name="BackgroundImage"
                CornerRadius="4"
                Effect="{DynamicResource Shadow.BusinessCard}">

                <!-- We've moved the BackgroundImage outside of the Business Card content as we'll be using it in other contexts outside of
                     the Business Card and we want to have flexibility in how we style and display it -->
                <Border.Background>
                    <ImageBrush ImageSource="{Binding BackgroundImage}" Stretch="None"/>
                </Border.Background>
            </Border>

            <!-- This overlay ensures that the Player Name and Title will be readable regardless of the background image the player uses -->
            <Border
                x:Name="BackgroundOverlay"
                CornerRadius="4"
                Background="{DynamicResource Color.Background.Overlay.Player.BusinessCard}"
                Opacity="0.5"/>

            <Border
                x:Name="BedazzleImage"
                CornerRadius="4"
                Opacity="0.5"
                Visibility="{Binding IsBedazzled, Converter={StaticResource BoolToVisConverter}}">

                <Border.Background>
                    <ImageBrush ImageSource="../Textures/PlayerIdentity/foileffect02.png"/>
                </Border.Background>
            </Border>

            <!-- The ContentPresenter renders content inside of the business card -->
            <ContentPresenter
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Grid>
    </ControlTemplate>

    <!-- BUSINESS CARD DISPLAYED IN HUD STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.BusinessCard.HUD" TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ContentControl}}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template" Value="{StaticResource Template.BusinessCard}"/>
    </Style>

    <!-- LOCAL PLAYER BUSINESS CARD TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <ControlTemplate x:Key="Template.BusinessCard.Local" TargetType="ContentControl">
        <Grid x:Name="Root"
            Width="644"
            Height="88"
            Background="Transparent">

            <Border
                x:Name="BackgroundImage"
                CornerRadius="4"
                Effect="{DynamicResource Shadow.BusinessCard}">

                <!-- We've moved the BackgroundImage outside of the Business Card content as we'll be using it in other contexts outside of
                     the Business Card and we want to have flexibility in how we style and display it -->
                <Border.Background>
                    <ImageBrush ImageSource="{Binding LocalPlayerIdentity.BusinessCard.BackgroundImage}" Stretch="None"/>
                </Border.Background>
            </Border>

            <!-- This overlay ensures that the Player Name and Title will be readable regardless of the background image the player uses -->
            <Border
                x:Name="BackgroundOverlay"
                CornerRadius="4"
                Background="{DynamicResource Color.Background.Overlay.Player.BusinessCard}"
                Opacity="0.4"/>

            <Border
                x:Name="BedazzleImage"
                CornerRadius="4"
                Opacity="0.5"
                Visibility="{Binding LocalPlayerIdentity.BusinessCard.IsBedazzled, Converter={StaticResource BoolToVisConverter}}">

                <Border.Background>
                    <ImageBrush ImageSource="../Textures/PlayerIdentity/foileffect02.png"/>
                </Border.Background>
            </Border>

            <!-- The ContentPresenter renders content inside of the business card -->
            <ContentPresenter
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Grid>
    </ControlTemplate>

    <!-- LOCAL PLAYER BUSINESS CARD STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.BusinessCard.Local" TargetType="ContentControl">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Focusable" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="Template" Value="{StaticResource Template.BusinessCard.Local}"/>
    </Style>
</ResourceDictionary>
