<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.Conditions.DataModelConditionListView"
             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:s="https://github.com/canton7/Stylet"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.Conditions"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800"
             d:DataContext="{d:DesignInstance Type=local:DataModelConditionListViewModel, IsDesignTimeCreatable=False}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Button Grid.Row="0"
                Grid.Column="0"
                ToolTip="Delete the list predicate and all its children"
                Style="{StaticResource MaterialDesignIconForegroundButton}"
                HorizontalAlignment="Left"
                Foreground="#E74C4C"
                Width="25"
                Height="25"
                Command="{s:Action Delete}">
            <materialDesign:PackIcon Kind="Close" Width="18" Height="18" />
        </Button>

        <!-- Left side, the list this predicate is targeting -->
        <ContentControl Grid.Row="0"
                        Grid.Column="1"
                        s:View.Model="{Binding LeftSideSelectionViewModel}"
                        VerticalContentAlignment="Stretch"
                        HorizontalContentAlignment="Stretch"
                        IsTabStop="False" />

        <!-- Operator -->
        <Button Grid.Row="0"
                Grid.Column="2"
                Style="{StaticResource DataModelConditionButtonLeftClickMenu}"
                Background="#7B7B7B"
                BorderBrush="#7B7B7B"
                Content="{Binding SelectedListOperator}"
                Click="PropertyButton_OnClick"
                HorizontalAlignment="Left"
                ToolTip="Change the list operator, determining how the list contents should match">
            <Button.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Any"
                              Command="{s:Action SelectListOperator}"
                              CommandParameter="Any"
                              ToolTip="Any of the list items should evaluate to true" />
                    <MenuItem Header="All"
                              Command="{s:Action SelectListOperator}"
                              CommandParameter="All"
                              ToolTip="All of the list items should evaluate to true" />
                    <MenuItem Header="None"
                              Command="{s:Action SelectListOperator}"
                              CommandParameter="None"
                              ToolTip="None of the list items should evaluate to true" />
                    <MenuItem Header="Count (NYI)"
                              Command="{s:Action SelectListOperator}"
                              CommandParameter="Count"
                              IsEnabled="False"
                              ToolTip="A specific amount of the list items should evaluate to true" />
                </ContextMenu>
            </Button.ContextMenu>
        </Button>

        <ToggleButton Grid.Row="0"
                      Grid.Column="3"
                      Style="{StaticResource MaterialDesignActionToggleButton}"
                      Focusable="False"
                      IsHitTestVisible="False"
                      IsChecked="{Binding IsConditionMet}"
                      Width="22"
                      Height="22"
                      HorizontalAlignment="Left">
            <ToggleButton.Content>
                <Border Background="#E74C4C" Width="22" Height="22">
                    <materialDesign:PackIcon Kind="Close" VerticalAlignment="Center" HorizontalAlignment="Center" Width="16" Height="16"/>
                </Border>
            </ToggleButton.Content>
            <materialDesign:ToggleButtonAssist.OnContent>
                <materialDesign:PackIcon Kind="Check" Width="16" Height="16"/>
            </materialDesign:ToggleButtonAssist.OnContent>
        </ToggleButton>

        <ItemsControl Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="3" ItemsSource="{Binding Items}" Margin="0 4 0 0">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Grid>
</UserControl>