<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.Conditions.DataModelConditionEventView"
             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:local="clr-namespace:Artemis.UI.Screens.ProfileEditor.Conditions"
             xmlns:s="https://github.com/canton7/Stylet"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             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.MergedDictionaries>
            <Storyboard x:Key="EventAnimation" x:Name="StartAnimation">
                <DoubleAnimation Duration="0:0:0.5" From="0.5" To="1.5" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" />
                <DoubleAnimation Duration="0:0:0.5" From="0.5" To="1.5" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" />
                <DoubleAnimation Duration="0:0:0.1" From="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" />
                <DoubleAnimation BeginTime="0:0:0.25" Duration="0:0:0.25" From="1" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" />
            </Storyboard>
        </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 event trigger"
                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" />

        <TextBlock Grid.Row="0"
                   Grid.Column="2"
                   VerticalAlignment="Center"
                   Margin="5 0 0 0" Text="{Binding TriggerPastParticiple}">
            
        </TextBlock>

        <Border Grid.Row="0"
                Grid.Column="3"
                Opacity="0"
                Background="#FFB9A40A"
                Width="22"
                Height="22"
                CornerRadius="11"
                HorizontalAlignment="Left"
                Margin="5 0 0 0"
                ToolTip="{Binding LastTrigger, NotifyOnTargetUpdated=True}"
                ToolTipService.IsEnabled="False">
            <Border.RenderTransform>
                <ScaleTransform ScaleX="1" ScaleY="1" CenterX="11" CenterY="11" />
            </Border.RenderTransform>
            <Border.Triggers>
                <!-- Ugly workaround to avoid the event animation showing on load -->
                <EventTrigger RoutedEvent="Border.Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation BeginTime="0:0:0.01" Duration="0:0:0" From="1" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
                <EventTrigger RoutedEvent="Binding.TargetUpdated">
                    <BeginStoryboard Storyboard="{StaticResource EventAnimation}" />
                </EventTrigger>
            </Border.Triggers>
            <materialDesign:PackIcon Kind="LightningBolt" VerticalAlignment="Center" HorizontalAlignment="Center" Width="16" Height="16" />
        </Border>

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