diff --git a/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs b/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs index 9f18fa243..06cdab520 100644 --- a/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs +++ b/src/Artemis.Core/Models/Profile/Colors/ColorGradient.cs @@ -10,6 +10,19 @@ namespace Artemis.Core /// public class ColorGradient : CorePropertyChanged { + private static readonly SKColor[] FastLedRainbow = + { + new(0xFFFF0000), // Red + new(0xFFFF9900), // Orange + new(0xFFFFFF00), // Yellow + new(0xFF00FF00), // Green + new(0xFF00FF7E), // Aqua + new(0xFF0078FF), // Blue + new(0xFF9E22FF), // Purple + new(0xFFFF34AE), // Pink + new(0xFFFF0000) // and back to Red + }; + /// /// Creates a new instance of the class /// @@ -31,9 +44,9 @@ namespace Artemis.Core public SKColor[] GetColorsArray(int timesToRepeat = 0) { if (timesToRepeat == 0) - return Stops.OrderBy(c => c.Position).Select(c => c.Color).ToArray(); + return Stops.Select(c => c.Color).ToArray(); - List colors = Stops.OrderBy(c => c.Position).Select(c => c.Color).ToList(); + List colors = Stops.Select(c => c.Color).ToList(); List result = new(); for (int i = 0; i <= timesToRepeat; i++) @@ -53,10 +66,10 @@ namespace Artemis.Core public float[] GetPositionsArray(int timesToRepeat = 0) { if (timesToRepeat == 0) - return Stops.OrderBy(c => c.Position).Select(c => c.Position).ToArray(); + return Stops.Select(c => c.Position).ToArray(); // Create stops and a list of divided stops - List stops = Stops.OrderBy(c => c.Position).Select(c => c.Position / (timesToRepeat + 1)).ToList(); + List stops = Stops.Select(c => c.Position / (timesToRepeat + 1)).ToList(); List result = new(); // For each repeat cycle, add the base stops to the end result @@ -74,6 +87,7 @@ namespace Artemis.Core /// public void OnColorValuesUpdated() { + Stops.Sort((a, b) => a.Position.CompareTo(b.Position)); OnPropertyChanged(nameof(Stops)); } @@ -86,7 +100,7 @@ namespace Artemis.Core if (!Stops.Any()) return SKColor.Empty; - ColorGradientStop[] stops = Stops.OrderBy(x => x.Position).ToArray(); + ColorGradientStop[] stops = Stops.ToArray(); if (position <= 0) return stops[0].Color; if (position >= 1) return stops[^1].Color; ColorGradientStop left = stops[0]; @@ -119,15 +133,14 @@ namespace Artemis.Core /// public static ColorGradient GetUnicornBarf() { - const int amount = 8; ColorGradient gradient = new(); - - for (int i = 0; i <= amount; i++) + for (int index = 0; index < FastLedRainbow.Length; index++) { - float percent = i / (float)amount; - gradient.Stops.Add(new ColorGradientStop(SKColor.FromHsv(360f * percent, 100, 100), percent)); + SKColor skColor = FastLedRainbow[index]; + float position = 1f / (FastLedRainbow.Length - 1f) * index; + gradient.Stops.Add(new ColorGradientStop(skColor, position)); } - + return gradient; } } diff --git a/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs b/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs index aeca78a60..cd56a38b2 100644 --- a/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs +++ b/src/Artemis.Core/Models/Profile/DataModel/DataModelEvent.cs @@ -29,9 +29,13 @@ namespace Artemis.Core } /// - [DataModelProperty(Name = "Last event trigger", Description = "The time at which the event last triggered")] + [DataModelProperty(Name = "Last trigger", Description = "The time at which the event last triggered")] public DateTime LastTrigger { get; private set; } + /// + [DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")] + public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger; + /// /// Gets the event arguments of the last time the event was triggered /// @@ -85,6 +89,7 @@ namespace Artemis.Core public Type ArgumentsType => typeof(T); /// + [DataModelIgnore] public string TriggerPastParticiple => "triggered"; /// @@ -147,14 +152,18 @@ namespace Artemis.Core } /// - [DataModelProperty(Name = "Last event trigger", Description = "The time at which the event last triggered")] + [DataModelProperty(Name = "Last trigger", Description = "The time at which the event last triggered")] public DateTime LastTrigger { get; private set; } + /// + [DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")] + public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger; + /// /// Gets the event arguments of the last time the event was triggered /// [DataModelProperty(Description = "The arguments of the last time this event triggered")] - public DataModelEventArgs? LastEventArguments { get; private set; } + public DataModelEventArgs? LastTriggerArguments { get; private set; } /// [DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")] @@ -174,7 +183,7 @@ namespace Artemis.Core { DataModelEventArgs eventArgs = new() {TriggerTime = DateTime.Now}; - LastEventArguments = eventArgs; + LastTriggerArguments = eventArgs; LastTrigger = DateTime.Now; TriggerCount++; @@ -201,6 +210,7 @@ namespace Artemis.Core public Type ArgumentsType => typeof(DataModelEventArgs); /// + [DataModelIgnore] public string TriggerPastParticiple => "triggered"; /// @@ -217,7 +227,7 @@ namespace Artemis.Core /// [DataModelIgnore] - public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments; + public DataModelEventArgs? LastEventArgumentsUntyped => LastTriggerArguments; /// [DataModelIgnore] diff --git a/src/Artemis.Core/Models/Profile/DataModel/IDataModelEvent.cs b/src/Artemis.Core/Models/Profile/DataModel/IDataModelEvent.cs index 954c2b7a6..4357dc3c6 100644 --- a/src/Artemis.Core/Models/Profile/DataModel/IDataModelEvent.cs +++ b/src/Artemis.Core/Models/Profile/DataModel/IDataModelEvent.cs @@ -13,6 +13,11 @@ namespace Artemis.Core /// DateTime LastTrigger { get; } + /// + /// Gets the time that has passed since the last trigger + /// + TimeSpan TimeSinceLastTrigger { get; } + /// /// Gets the amount of times the event was triggered /// diff --git a/src/Artemis.Core/Models/Profile/DataModel/ValueChangedEvent/DataModelValueChangedEvent.cs b/src/Artemis.Core/Models/Profile/DataModel/ValueChangedEvent/DataModelValueChangedEvent.cs index 3a2ee7de8..fcf52f32b 100644 --- a/src/Artemis.Core/Models/Profile/DataModel/ValueChangedEvent/DataModelValueChangedEvent.cs +++ b/src/Artemis.Core/Models/Profile/DataModel/ValueChangedEvent/DataModelValueChangedEvent.cs @@ -14,6 +14,7 @@ namespace Artemis.Core public T? LastValue { get; private set; } public T? CurrentValue { get; private set; } public DateTime LastTrigger { get; private set; } + public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger; public int TriggerCount { get; private set; } public Type ArgumentsType { get; } = typeof(DataModelValueChangedEventArgs); public string TriggerPastParticiple => "changed"; diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeView.xaml index 493b65c76..7fded19b2 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeView.xaml @@ -42,12 +42,12 @@ Margin="-10 0 -10 -5"> - + - + diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeViewModel.cs index b45c7728b..f7cfd0071 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/ConditionalDataBindingModeViewModel.cs @@ -44,6 +44,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio _profileEditorService.UpdateSelectedProfileElement(); } + public void RemoveCondition(DataBindingCondition dataBindingCondition) + { + ConditionalDataBinding.RemoveCondition(dataBindingCondition); + } + protected override void OnInitialActivate() { Initialize(); diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionView.xaml index 42e982f8d..6ae8e1eeb 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionView.xaml @@ -4,9 +4,45 @@ 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" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionViewModel.cs index 81d9dfe6a..4361be98d 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionViewModel.cs @@ -61,6 +61,17 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio ActiveItem?.Evaluate(); } + public void AddCondition() + { + ((ConditionalDataBindingModeViewModel) Parent).AddCondition(); + } + + public void RemoveCondition() + { + ((ConditionalDataBindingModeViewModel)Parent).RemoveCondition(DataBindingCondition); + + } + #region IDisposable /// diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs index 593c7144d..2127e82c8 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs @@ -251,6 +251,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings if (Registration.DataBinding == null) return; + ActiveItem = null; Registration.LayerProperty.DisableDataBinding(Registration.DataBinding); Update();