mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
Color gradients - Tweaked default rainbow
Events - Hide some properties that shouldn't be visible Events - Added time since last trigger property
This commit is contained in:
parent
f4b42e2cf2
commit
a74c81ba9d
@ -10,6 +10,19 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ColorGradient : CorePropertyChanged
|
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
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="ColorGradient" /> class
|
/// Creates a new instance of the <see cref="ColorGradient" /> class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,9 +44,9 @@ namespace Artemis.Core
|
|||||||
public SKColor[] GetColorsArray(int timesToRepeat = 0)
|
public SKColor[] GetColorsArray(int timesToRepeat = 0)
|
||||||
{
|
{
|
||||||
if (timesToRepeat == 0)
|
if (timesToRepeat == 0)
|
||||||
return Stops.OrderBy(c => c.Position).Select(c => c.Color).ToArray();
|
return Stops.Select(c => c.Color).ToArray();
|
||||||
|
|
||||||
List<SKColor> colors = Stops.OrderBy(c => c.Position).Select(c => c.Color).ToList();
|
List<SKColor> colors = Stops.Select(c => c.Color).ToList();
|
||||||
List<SKColor> result = new();
|
List<SKColor> result = new();
|
||||||
|
|
||||||
for (int i = 0; i <= timesToRepeat; i++)
|
for (int i = 0; i <= timesToRepeat; i++)
|
||||||
@ -53,10 +66,10 @@ namespace Artemis.Core
|
|||||||
public float[] GetPositionsArray(int timesToRepeat = 0)
|
public float[] GetPositionsArray(int timesToRepeat = 0)
|
||||||
{
|
{
|
||||||
if (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
|
// Create stops and a list of divided stops
|
||||||
List<float> stops = Stops.OrderBy(c => c.Position).Select(c => c.Position / (timesToRepeat + 1)).ToList();
|
List<float> stops = Stops.Select(c => c.Position / (timesToRepeat + 1)).ToList();
|
||||||
List<float> result = new();
|
List<float> result = new();
|
||||||
|
|
||||||
// For each repeat cycle, add the base stops to the end result
|
// For each repeat cycle, add the base stops to the end result
|
||||||
@ -74,6 +87,7 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnColorValuesUpdated()
|
public void OnColorValuesUpdated()
|
||||||
{
|
{
|
||||||
|
Stops.Sort((a, b) => a.Position.CompareTo(b.Position));
|
||||||
OnPropertyChanged(nameof(Stops));
|
OnPropertyChanged(nameof(Stops));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +100,7 @@ namespace Artemis.Core
|
|||||||
if (!Stops.Any())
|
if (!Stops.Any())
|
||||||
return SKColor.Empty;
|
return SKColor.Empty;
|
||||||
|
|
||||||
ColorGradientStop[] stops = Stops.OrderBy(x => x.Position).ToArray();
|
ColorGradientStop[] stops = Stops.ToArray();
|
||||||
if (position <= 0) return stops[0].Color;
|
if (position <= 0) return stops[0].Color;
|
||||||
if (position >= 1) return stops[^1].Color;
|
if (position >= 1) return stops[^1].Color;
|
||||||
ColorGradientStop left = stops[0];
|
ColorGradientStop left = stops[0];
|
||||||
@ -119,13 +133,12 @@ namespace Artemis.Core
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static ColorGradient GetUnicornBarf()
|
public static ColorGradient GetUnicornBarf()
|
||||||
{
|
{
|
||||||
const int amount = 8;
|
|
||||||
ColorGradient gradient = new();
|
ColorGradient gradient = new();
|
||||||
|
for (int index = 0; index < FastLedRainbow.Length; index++)
|
||||||
for (int i = 0; i <= amount; i++)
|
|
||||||
{
|
{
|
||||||
float percent = i / (float)amount;
|
SKColor skColor = FastLedRainbow[index];
|
||||||
gradient.Stops.Add(new ColorGradientStop(SKColor.FromHsv(360f * percent, 100, 100), percent));
|
float position = 1f / (FastLedRainbow.Length - 1f) * index;
|
||||||
|
gradient.Stops.Add(new ColorGradientStop(skColor, position));
|
||||||
}
|
}
|
||||||
|
|
||||||
return gradient;
|
return gradient;
|
||||||
|
|||||||
@ -29,9 +29,13 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[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; }
|
public DateTime LastTrigger { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")]
|
||||||
|
public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the event arguments of the last time the event was triggered
|
/// Gets the event arguments of the last time the event was triggered
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -85,6 +89,7 @@ namespace Artemis.Core
|
|||||||
public Type ArgumentsType => typeof(T);
|
public Type ArgumentsType => typeof(T);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
[DataModelIgnore]
|
||||||
public string TriggerPastParticiple => "triggered";
|
public string TriggerPastParticiple => "triggered";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -147,14 +152,18 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[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; }
|
public DateTime LastTrigger { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
[DataModelProperty(Name = "Time since trigger", Description = "The time that has passed since the last trigger")]
|
||||||
|
public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the event arguments of the last time the event was triggered
|
/// Gets the event arguments of the last time the event was triggered
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
|
[DataModelProperty(Description = "The arguments of the last time this event triggered")]
|
||||||
public DataModelEventArgs? LastEventArguments { get; private set; }
|
public DataModelEventArgs? LastTriggerArguments { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[DataModelProperty(Description = "The total amount of times this event has triggered since the module was activated")]
|
[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};
|
DataModelEventArgs eventArgs = new() {TriggerTime = DateTime.Now};
|
||||||
|
|
||||||
LastEventArguments = eventArgs;
|
LastTriggerArguments = eventArgs;
|
||||||
LastTrigger = DateTime.Now;
|
LastTrigger = DateTime.Now;
|
||||||
TriggerCount++;
|
TriggerCount++;
|
||||||
|
|
||||||
@ -201,6 +210,7 @@ namespace Artemis.Core
|
|||||||
public Type ArgumentsType => typeof(DataModelEventArgs);
|
public Type ArgumentsType => typeof(DataModelEventArgs);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
[DataModelIgnore]
|
||||||
public string TriggerPastParticiple => "triggered";
|
public string TriggerPastParticiple => "triggered";
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -217,7 +227,7 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[DataModelIgnore]
|
[DataModelIgnore]
|
||||||
public DataModelEventArgs? LastEventArgumentsUntyped => LastEventArguments;
|
public DataModelEventArgs? LastEventArgumentsUntyped => LastTriggerArguments;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
[DataModelIgnore]
|
[DataModelIgnore]
|
||||||
|
|||||||
@ -13,6 +13,11 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
DateTime LastTrigger { get; }
|
DateTime LastTrigger { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the time that has passed since the last trigger
|
||||||
|
/// </summary>
|
||||||
|
TimeSpan TimeSinceLastTrigger { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the amount of times the event was triggered
|
/// Gets the amount of times the event was triggered
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -14,6 +14,7 @@ namespace Artemis.Core
|
|||||||
public T? LastValue { get; private set; }
|
public T? LastValue { get; private set; }
|
||||||
public T? CurrentValue { get; private set; }
|
public T? CurrentValue { get; private set; }
|
||||||
public DateTime LastTrigger { get; private set; }
|
public DateTime LastTrigger { get; private set; }
|
||||||
|
public TimeSpan TimeSinceLastTrigger => DateTime.Now - LastTrigger;
|
||||||
public int TriggerCount { get; private set; }
|
public int TriggerCount { get; private set; }
|
||||||
public Type ArgumentsType { get; } = typeof(DataModelValueChangedEventArgs<T>);
|
public Type ArgumentsType { get; } = typeof(DataModelValueChangedEventArgs<T>);
|
||||||
public string TriggerPastParticiple => "changed";
|
public string TriggerPastParticiple => "changed";
|
||||||
|
|||||||
@ -42,12 +42,12 @@
|
|||||||
Margin="-10 0 -10 -5">
|
Margin="-10 0 -10 -5">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
<ListBox.ItemsPanel>
|
<ListBox.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<VirtualizingStackPanel />
|
<VirtualizingStackPanel/>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ListBox.ItemsPanel>
|
</ListBox.ItemsPanel>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
|||||||
@ -44,6 +44,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
|||||||
_profileEditorService.UpdateSelectedProfileElement();
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RemoveCondition(DataBindingCondition<TLayerProperty, TProperty> dataBindingCondition)
|
||||||
|
{
|
||||||
|
ConditionalDataBinding.RemoveCondition(dataBindingCondition);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnInitialActivate()
|
protected override void OnInitialActivate()
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
|
|||||||
@ -4,9 +4,45 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
<Border BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" Margin="0 0 0 -4" Padding="0 4">
|
<Border BorderThickness="0 0 0 1"
|
||||||
|
BorderBrush="{DynamicResource MaterialDesignDivider}"
|
||||||
|
Margin="0 0 0 -4"
|
||||||
|
Padding="0 4"
|
||||||
|
Background="Transparent">
|
||||||
|
<Border.ContextMenu>
|
||||||
|
<ContextMenu>
|
||||||
|
<MenuItem Header="Add new condition" Command="{s:Action AddCondition}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="CodeNotEqual" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<Separator />
|
||||||
|
<MenuItem Header="Duplicate" Command="{s:Action DuplicateCondition}" InputGestureText="Ctrl+D" IsEnabled="False">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentDuplicate" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Copy" Command="{s:Action CopyCondition}" InputGestureText="Ctrl+C" IsEnabled="False">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentCopy" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Paste" Command="{s:Action PasteCondition}" InputGestureText="Ctrl+V" IsEnabled="False">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="ContentPaste" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<Separator />
|
||||||
|
<MenuItem Header="Delete" Command="{s:Action RemoveCondition}" InputGestureText="Del">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="TrashCan" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
</ContextMenu>
|
||||||
|
</Border.ContextMenu>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
|||||||
@ -61,6 +61,17 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
|||||||
ActiveItem?.Evaluate();
|
ActiveItem?.Evaluate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddCondition()
|
||||||
|
{
|
||||||
|
((ConditionalDataBindingModeViewModel<TLayerProperty, TProperty>) Parent).AddCondition();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveCondition()
|
||||||
|
{
|
||||||
|
((ConditionalDataBindingModeViewModel<TLayerProperty, TProperty>)Parent).RemoveCondition(DataBindingCondition);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#region IDisposable
|
#region IDisposable
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -251,6 +251,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
|||||||
if (Registration.DataBinding == null)
|
if (Registration.DataBinding == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ActiveItem = null;
|
||||||
Registration.LayerProperty.DisableDataBinding(Registration.DataBinding);
|
Registration.LayerProperty.DisableDataBinding(Registration.DataBinding);
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user