<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:system="clr-namespace:System;assembly=mscorlib">

    <!-- REQUIREMENT SLOT TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <ControlTemplate x:Key="Template.RequirementItem" TargetType="{x:Type ListBoxItem}">
        <Grid>
            <!-- The ContentPresenter renders content inside of the item -->
            <ContentPresenter
                HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Grid>
    </ControlTemplate>

    <!-- REQUIREMENT SLOT DATA TEMPLATE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <DataTemplate x:Key="Content.RequirementItem">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="72"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!-- Displays the item slot with the requirement item -->
            <Border x:Name="SlotItemBase" Style="{DynamicResource SlotBaseStyle}">
                <Border x:Name="SlotItemBorder" Style="{DynamicResource SlotBorderStyle}">
                    <Image
                        x:Name="Requirement.Icon"
                        Style="{DynamicResource SlotItemIconStyle}"
                        Source="{Binding Icon}"/>
                </Border>
            </Border>

            <!-- The Requirement.Check displays a checkmark or a cross based on whether the player meets the requirement or not -->
            <Border
                x:Name="Requirement.Check"
                Width="24"
                Height="24"
                BorderThickness="2"
                BorderBrush="{DynamicResource Color.Border.Selected}"
                Background="{DynamicResource Color.Background.Control.Check}"
                HorizontalAlignment="Right"
                VerticalAlignment="Bottom">

                <Image
                    x:Name="Requirement.Check.Icon"
                    Source="../Textures/Icons/IconCheckGreen.png"
                    Stretch="UniformToFill"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"/>
            </Border>

            <TextBlock
                x:Name="Requirement.Name"
                Grid.Column="1"
                Text="{Binding Name}"
                FontFamily="{DynamicResource Font.CoreSans}"
                FontSize="{DynamicResource Font.Size.Body}"
                Foreground="{DynamicResource Color.Text}"
                TextAlignment="Left"
                HorizontalAlignment="Left"
                VerticalAlignment="Center"
                Margin="12,0,0,0"/>
        </Grid>

        <!-- These triggers toggle the visibility of the checkmark and cross icons in Requirement.Check -->
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding HasEnough}" Value="True">
                <Setter Property="Source" Value="../Textures/Icons/IconCheckGreen.png" TargetName="Requirement.Check.Icon"/>
            </DataTrigger>

            <DataTrigger Binding="{Binding HasEnough}" Value="False">
                <Setter Property="Source" Value="../Textures/Icons/IconCrossRed.png" TargetName="Requirement.Check.Icon"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Color.Border.Error}" TargetName="Requirement.Check"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>

    <!-- REQUIREMENT SLOT STYLE -->
    <!--////////////////////////////////////////////////////////////////////-->
    <Style x:Key="Style.RequirementItem" TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ContentControl}}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template" Value="{StaticResource Template.RequirementItem}" />
    </Style>
</ResourceDictionary>
