<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDataBinding.DataBindingModifierView"
             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:converters="clr-namespace:Artemis.UI.Converters"
             xmlns:utilities="clr-namespace:Artemis.UI.Utilities"
             xmlns:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDataBinding"
             xmlns:modifierTypes="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDataBinding.ModifierTypes"
             xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
             mc:Ignorable="d"
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
                <ResourceDictionary>
                    <shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
                    <utilities:BindingProxy x:Key="DataContextProxy" Data="{Binding}" />
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Button Grid.Column="0"
                ToolTip="Delete the modifier"
                Style="{StaticResource MaterialDesignIconForegroundButton}"
                HorizontalAlignment="Left"
                Foreground="#E74C4C"
                Width="25"
                Height="25"
                Command="{s:Action Delete}">
            <materialDesign:PackIcon Kind="Close" Width="18" Height="18" />
        </Button>
        
        <Button Grid.Column="1"
                Style="{StaticResource DataModelConditionButtonLeftClickMenu}"
                Background="#7B7B7B"
                BorderBrush="#7B7B7B"
                Click="PropertyButton_OnClick">
            <Button.ContextMenu>
                <ContextMenu ItemsSource="{Binding ModifierTypeViewModels.Children}">
                    <ContextMenu.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <StackPanel.Resources>
                                    <DataTemplate DataType="{x:Type modifierTypes:ModifierTypeCategoryViewModel}">
                                        <TextBlock Text="{Binding Category}" />
                                    </DataTemplate>
                                    <DataTemplate DataType="{x:Type modifierTypes:ModifierTypeViewModel}">
                                        <StackPanel Orientation="Horizontal">
                                            <materialDesign:PackIcon Kind="{Binding ModifierType.Icon}" 
                                                                     VerticalAlignment="Center" 
                                                                     Margin="0 0 15 0" 
                                                                     Visibility="{Binding ModifierType.Icon, Converter={StaticResource NullToVisibilityConverter}}"/>
                                            <TextBlock Text="{Binding ModifierType.Name}" 
                                                       VerticalAlignment="Center" 
                                                       ToolTip="{Binding ModifierType.Description}"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </StackPanel.Resources>
                                <ContentPresenter Content="{Binding}" />
                            </StackPanel>
                        </DataTemplate>
                    </ContextMenu.ItemTemplate>
                    <ContextMenu.ItemContainerStyle>
                        <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource MaterialDesignMenuItem}">
                            <Setter Property="ItemsSource" Value="{Binding Children}" />
                            <Setter Property="Command" Value="{Binding Data.SelectModifierTypeCommand, Source={StaticResource DataContextProxy}}" />
                            <Setter Property="CommandParameter" Value="{Binding}" />
                            <Setter Property="CommandTarget" Value="{Binding}" />
                        </Style>
                    </ContextMenu.ItemContainerStyle>
                </ContextMenu>
            </Button.ContextMenu>
            <Grid>
                <TextBlock Text="{Binding SelectedModifierType.Name}"
                           Visibility="{Binding SelectedModifierType, Converter={StaticResource NullToVisibilityConverter}}" />
                <TextBlock FontStyle="Italic"
                           Visibility="{Binding SelectedModifierType, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Inverted}">
                    « Select a modifier »
                </TextBlock>
            </Grid>

        </Button>

        <ContentControl Grid.Column="2" s:View.Model="{Binding DynamicSelectionViewModel}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
        <ContentControl Grid.Column="2" s:View.Model="{Binding StaticInputViewModel}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
    </Grid>
</UserControl>