From cdb91021a2bd2721ccb47f3424377e5d56daf3f3 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sun, 31 May 2020 21:58:06 +0200 Subject: [PATCH] Layer brushes - Added RGB.NET-based layer brushes Layer brushes - Added sample RGB.NET-based color brush Layer properties - Save on gradient edit dialog close Layer properties - Fix layer brush keyframes not working after changing layer brush --- src/Artemis.Core/Models/Profile/Layer.cs | 14 ++- .../Models/Profile/LayerPropertyGroup.cs | 3 + .../Plugins/LayerBrush/BaseLayerBrush.cs | 57 +++++++----- .../Plugins/LayerBrush/LayerBrush.cs | 89 +++++++------------ .../LayerBrush/PropertiesLayerBrush.cs | 57 ++++++++++++ .../Plugins/LayerBrush/RgbNetLayerBrush.cs | 80 +++++++++++++++++ src/Artemis.Core/Services/LayerService.cs | 4 +- .../Controls/GradientPicker.xaml.cs | 22 ++++- .../Services/GradientPickerService.cs | 8 +- .../Interfaces/IGradientPickerService.cs | 5 +- .../Abstract/LayerPropertyBaseViewModel.cs | 2 +- .../LayerPropertiesViewModel.cs | 29 +++--- .../LayerPropertyGroupViewModel.cs | 10 +-- .../LayerProperties/LayerPropertyViewModel.cs | 10 ++- .../Timeline/TimelinePropertyGroupView.xaml | 3 +- .../TimelinePropertyGroupViewModel.cs | 2 +- .../Timeline/TimelinePropertyViewModel.cs | 2 +- .../Abstract/PropertyInputViewModel.cs | 2 +- .../ColorGradientPropertyInputView.xaml | 10 ++- .../ColorGradientPropertyInputViewModel.cs | 8 +- .../Visualization/ProfileViewModel.cs | 60 ++++++++----- src/Artemis.sln | 12 +++ .../ColorBrush.cs | 13 ++- ...is.Plugins.LayerBrushes.ColorRgbNet.csproj | 53 +++++++++++ .../Properties/AssemblyInfo.cs | 9 ++ .../RgbNetColorBrush.cs | 28 ++++++ .../RgbNetColorBrushProperties.cs | 22 +++++ .../RgbNetColorBrushProvider.cs | 25 ++++++ .../app.config | 39 ++++++++ .../plugin.json | 7 ++ .../NoiseBrush.cs | 11 ++- 31 files changed, 550 insertions(+), 146 deletions(-) create mode 100644 src/Artemis.Core/Plugins/LayerBrush/PropertiesLayerBrush.cs create mode 100644 src/Artemis.Core/Plugins/LayerBrush/RgbNetLayerBrush.cs create mode 100644 src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/Artemis.Plugins.LayerBrushes.ColorRgbNet.csproj create mode 100644 src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/Properties/AssemblyInfo.cs create mode 100644 src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrush.cs create mode 100644 src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrushProperties.cs create mode 100644 src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrushProvider.cs create mode 100644 src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/app.config create mode 100644 src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/plugin.json diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index e9f74c2d9..55f18200f 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -204,7 +204,7 @@ namespace Artemis.Core.Models.Profile /// public override void Update(double deltaTime) { - if (LayerBrush == null || !LayerBrush.BaseProperties.PropertiesInitialized) + if (LayerBrush?.BaseProperties == null || !LayerBrush.BaseProperties.PropertiesInitialized) return; var properties = new List(General.GetAllLayerProperties().Where(p => p.BaseKeyframes.Any())); @@ -269,6 +269,9 @@ namespace Artemis.Core.Models.Profile private void StretchRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint) { + if (LayerBrush == null || !LayerBrush.BaseProperties.PropertiesInitialized || LayerBrush.BrushType != LayerBrushType.Regular) + return; + // Apply transformations var sizeProperty = Transform.Scale.CurrentValue; var rotationProperty = Transform.Rotation.CurrentValue; @@ -285,12 +288,14 @@ namespace Artemis.Core.Models.Profile canvas.Scale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y); canvas.Translate(x, y); - if (LayerBrush != null && LayerBrush.BaseProperties.PropertiesInitialized) - LayerBrush.Render(canvas, canvasInfo, new SKPath(LayerShape.Path), paint); + LayerBrush.InternalRender(canvas, canvasInfo, new SKPath(LayerShape.Path), paint); } private void ClipRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint) { + if (LayerBrush == null || !LayerBrush.BaseProperties.PropertiesInitialized || LayerBrush.BrushType != LayerBrushType.Regular) + return; + // Apply transformations var sizeProperty = Transform.Scale.CurrentValue; var rotationProperty = Transform.Rotation.CurrentValue; @@ -321,7 +326,8 @@ namespace Artemis.Core.Models.Profile ); var renderPath = new SKPath(); renderPath.AddRect(boundsRect); - LayerBrush?.Render(canvas, canvasInfo, renderPath, paint); + + LayerBrush.InternalRender(canvas, canvasInfo, renderPath, paint); } internal void CalculateRenderProperties() diff --git a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs index 5b0dc8a60..68d4bf8ae 100644 --- a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs +++ b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs @@ -165,6 +165,9 @@ namespace Artemis.Core.Models.Profile internal void ApplyToEntity() { + if (!PropertiesInitialized) + return; + // Get all properties with a PropertyDescriptionAttribute foreach (var propertyInfo in GetType().GetProperties()) { diff --git a/src/Artemis.Core/Plugins/LayerBrush/BaseLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrush/BaseLayerBrush.cs index 5a06297f8..7c3c41514 100644 --- a/src/Artemis.Core/Plugins/LayerBrush/BaseLayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrush/BaseLayerBrush.cs @@ -1,17 +1,25 @@ using System; +using System.Linq; using Artemis.Core.Models.Profile; using Artemis.Core.Plugins.Models; using Artemis.Core.Services.Interfaces; +using RGB.NET.Core; +using RGB.NET.Groups; using SkiaSharp; namespace Artemis.Core.Plugins.LayerBrush { /// - /// A basic layer brush that does not implement any layer property, to use properties with persistent storage, - /// implement instead + /// For internal use only, please use or or instead /// public abstract class BaseLayerBrush : IDisposable { + protected BaseLayerBrush(Layer layer, LayerBrushDescriptor descriptor) + { + Layer = layer; + Descriptor = descriptor; + } + /// /// Gets the layer this brush is applied to /// @@ -27,38 +35,43 @@ namespace Artemis.Core.Plugins.LayerBrush /// public PluginInfo PluginInfo => Descriptor.LayerBrushProvider.PluginInfo; - public virtual LayerPropertyGroup BaseProperties => null; + /// + /// Gets the type of layer brush + /// + public LayerBrushType BrushType { get; internal set; } + /// + /// Gets a reference to the layer property group without knowing it's type + /// + public virtual LayerPropertyGroup BaseProperties => null; + /// /// Called when the brush is being removed from the layer /// - public virtual void Dispose() - { - } + public abstract void Dispose(); /// /// Called before rendering every frame, write your update logic here /// /// - public virtual void Update(double deltaTime) - { - } + public abstract void Update(double deltaTime); + + // Not only is this needed to initialize properties on the layer brushes, it also prevents implementing anything + // but LayerBrush and RgbNetLayerBrush outside the core + internal abstract void Initialize(ILayerService layerService); + + internal abstract void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint); /// - /// The main method of rendering anything to the layer. The provided is specific to the layer - /// and matches it's width and height. - /// Called during rendering or layer preview, in the order configured on the layer + /// Called when Artemis needs an instance of the RGB.NET brush you are implementing /// - /// The layer canvas - /// - /// The path to be filled, represents the shape - /// The paint to be used to fill the shape - public virtual void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint) - { - } + /// Your RGB.NET brush + internal abstract IBrush InternalGetBrush(); + } - internal virtual void InitializeProperties(ILayerService layerService, string path) - { - } + public enum LayerBrushType + { + Regular, + RgbNet } } \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs index 6c518d3c4..a466492ff 100644 --- a/src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs @@ -1,77 +1,52 @@ using System; -using System.Collections.Generic; using Artemis.Core.Models.Profile; -using Artemis.Core.Models.Profile.LayerProperties; -using Artemis.Core.Plugins.Exceptions; using Artemis.Core.Services.Interfaces; +using RGB.NET.Core; +using SkiaSharp; namespace Artemis.Core.Plugins.LayerBrush { - public abstract class LayerBrush : BaseLayerBrush where T : LayerPropertyGroup + public abstract class LayerBrush : PropertiesLayerBrush where T : LayerPropertyGroup { - private T _properties; - - protected LayerBrush(Layer layer, LayerBrushDescriptor descriptor) + protected LayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor) { - Layer = layer; - Descriptor = descriptor; - } - - #region Properties - - /// - /// Gets the properties of this brush. - /// - public T Properties - { - get - { - // I imagine a null reference here can be confusing, so lets throw an exception explaining what to do - if (_properties == null) - throw new ArtemisPluginException("Cannot access brush properties until OnPropertiesInitialized has been called"); - return _properties; - } - internal set => _properties = value; + BrushType = LayerBrushType.Regular; } /// - /// Gets whether all properties on this brush are initialized + /// The main method of rendering anything to the layer. The provided is specific to the layer + /// and matches it's width and height. + /// Called during rendering or layer preview, in the order configured on the layer /// - public bool PropertiesInitialized { get; private set; } + /// The layer canvas + /// + /// The path to be filled, represents the shape + /// The paint to be used to fill the shape + public abstract void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint); + + internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint) + { + Render(canvas, canvasInfo, path, paint); + } - /// - /// Called when all layer properties in this brush have been initialized - /// - protected virtual void OnPropertiesInitialized() + internal override IBrush InternalGetBrush() + { + throw new NotImplementedException("Regular layer brushes do not implement InternalGetBrush"); + } + + internal override void Initialize(ILayerService layerService) + { + InitializeProperties(layerService); + } + + protected virtual void Dispose(bool disposing) { } - /// - public override LayerPropertyGroup BaseProperties => Properties; - - internal override void InitializeProperties(ILayerService layerService, string path) + public sealed override void Dispose() { - Properties = Activator.CreateInstance(); - Properties.InitializeProperties(layerService, Layer, path); - OnPropertiesInitialized(); - PropertiesInitialized = true; + Dispose(true); + GC.SuppressFinalize(this); } - - internal virtual void ApplyToEntity() - { - Properties.ApplyToEntity(); - } - - internal virtual void OverrideProperties(TimeSpan overrideTime) - { - Properties.Override(overrideTime); - } - - internal virtual IReadOnlyCollection GetAllLayerProperties() - { - return Properties.GetAllLayerProperties(); - } - - #endregion } } \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerBrush/PropertiesLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrush/PropertiesLayerBrush.cs new file mode 100644 index 000000000..ee7010c3c --- /dev/null +++ b/src/Artemis.Core/Plugins/LayerBrush/PropertiesLayerBrush.cs @@ -0,0 +1,57 @@ +using System; +using Artemis.Core.Models.Profile; +using Artemis.Core.Plugins.Exceptions; +using Artemis.Core.Services.Interfaces; + +namespace Artemis.Core.Plugins.LayerBrush +{ + /// + /// For internal use only, please use or or instead + /// + public abstract class PropertiesLayerBrush : BaseLayerBrush where T : LayerPropertyGroup + { + private T _properties; + + protected PropertiesLayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor) + { + } + + /// + /// Gets whether all properties on this brush are initialized + /// + public bool PropertiesInitialized { get; internal set; } + + /// + public override LayerPropertyGroup BaseProperties => Properties; + + /// + /// Gets the properties of this brush. + /// + public T Properties + { + get + { + // I imagine a null reference here can be confusing, so lets throw an exception explaining what to do + if (_properties == null) + throw new ArtemisPluginException("Cannot access brush properties until OnPropertiesInitialized has been called"); + return _properties; + } + internal set => _properties = value; + } + + /// + /// Called when all layer properties in this brush have been initialized + /// + protected virtual void OnPropertiesInitialized() + { + } + + internal void InitializeProperties(ILayerService layerService) + { + Properties = Activator.CreateInstance(); + Properties.InitializeProperties(layerService, Layer, "LayerBrush."); + OnPropertiesInitialized(); + PropertiesInitialized = true; + } + } +} \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerBrush/RgbNetLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrush/RgbNetLayerBrush.cs new file mode 100644 index 000000000..3cbf70fe3 --- /dev/null +++ b/src/Artemis.Core/Plugins/LayerBrush/RgbNetLayerBrush.cs @@ -0,0 +1,80 @@ +using System; +using System.Linq; +using Artemis.Core.Models.Profile; +using Artemis.Core.Services.Interfaces; +using RGB.NET.Core; +using RGB.NET.Groups; +using SkiaSharp; + +namespace Artemis.Core.Plugins.LayerBrush +{ + public abstract class RgbNetLayerBrush : PropertiesLayerBrush where T : LayerPropertyGroup + { + protected RgbNetLayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor) + { + BrushType = LayerBrushType.RgbNet; + LedGroup = new ListLedGroup(); + + Layer = layer; + Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated; + UpdateLedGroup(); + } + + /// + /// The LED group this layer brush is applied to + /// + public ListLedGroup LedGroup { get; internal set; } + + /// + /// Called when Artemis needs an instance of the RGB.NET brush you are implementing + /// + /// Your RGB.NET brush + public abstract IBrush GetBrush(); + + public sealed override void Dispose() + { + Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated; + LedGroup.Detach(); + + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + } + + internal void UpdateLedGroup() + { + // TODO: This simply renders it on top of the rest, get a ZIndex based on layer position + LedGroup.ZIndex = 1; + + var missingLeds = Layer.Leds.Where(l => !LedGroup.ContainsLed(l.RgbLed)).Select(l => l.RgbLed).ToList(); + var extraLeds = LedGroup.GetLeds().Where(l => Layer.Leds.All(layerLed => layerLed.RgbLed != l)).ToList(); + LedGroup.AddLeds(missingLeds); + LedGroup.RemoveLeds(extraLeds); + LedGroup.Brush = GetBrush(); + } + + internal override void Initialize(ILayerService layerService) + { + InitializeProperties(layerService); + } + + // Not used in this brush type + internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint) + { + throw new NotImplementedException("RGB.NET layer brushes do not implement InternalRender"); + } + + internal override IBrush InternalGetBrush() + { + return GetBrush(); + } + + private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e) + { + UpdateLedGroup(); + } + } +} \ No newline at end of file diff --git a/src/Artemis.Core/Services/LayerService.cs b/src/Artemis.Core/Services/LayerService.cs index b080b8b5a..42e8e33e3 100644 --- a/src/Artemis.Core/Services/LayerService.cs +++ b/src/Artemis.Core/Services/LayerService.cs @@ -58,8 +58,8 @@ namespace Artemis.Core.Services new ConstructorArgument("layer", layer), new ConstructorArgument("descriptor", descriptor) }; - layer.LayerBrush = (BaseLayerBrush)_kernel.Get(descriptor.LayerBrushType, arguments); ; - layer.LayerBrush.InitializeProperties(this, "LayerBrush."); + layer.LayerBrush = (BaseLayerBrush) _kernel.Get(descriptor.LayerBrushType, arguments); + layer.LayerBrush.Initialize(this); layer.OnLayerBrushUpdated(); return layer.LayerBrush; } diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs b/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs index a001c5c9d..198c77110 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs +++ b/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs @@ -1,6 +1,7 @@ using System; using System.ComponentModel; using System.Runtime.CompilerServices; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -8,6 +9,7 @@ using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile.Colors; using Artemis.UI.Shared.Annotations; using Artemis.UI.Shared.Services.Interfaces; +using Stylet; namespace Artemis.UI.Shared.Controls { @@ -19,6 +21,9 @@ namespace Artemis.UI.Shared.Controls private static IGradientPickerService _gradientPickerService; private bool _inCallback; + public event EventHandler DialogOpened; + public event EventHandler DialogClosed; + public GradientPicker() { InitializeComponent(); @@ -77,7 +82,12 @@ namespace Artemis.UI.Shared.Controls private void UIElement_OnMouseUp(object sender, MouseButtonEventArgs e) { - GradientPickerService.ShowGradientPicker(ColorGradient, DialogHost); + Execute.OnUIThread(async () => + { + OnDialogOpened(); + await GradientPickerService.ShowGradientPicker(ColorGradient, DialogHost); + OnDialogClosed(); + }); } #region Static WPF fields @@ -92,5 +102,15 @@ namespace Artemis.UI.Shared.Controls EventManager.RegisterRoutedEvent(nameof(ColorGradient), RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler), typeof(GradientPicker)); #endregion + + protected virtual void OnDialogOpened() + { + DialogOpened?.Invoke(this, EventArgs.Empty); + } + + protected virtual void OnDialogClosed() + { + DialogClosed?.Invoke(this, EventArgs.Empty); + } } } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Services/GradientPickerService.cs b/src/Artemis.UI.Shared/Services/GradientPickerService.cs index f246c5dd4..608ea0401 100644 --- a/src/Artemis.UI.Shared/Services/GradientPickerService.cs +++ b/src/Artemis.UI.Shared/Services/GradientPickerService.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Threading.Tasks; using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile.Colors; using Artemis.UI.Shared.Screens.GradientEditor; @@ -15,12 +16,11 @@ namespace Artemis.UI.Shared.Services _dialogService = dialogService; } - public void ShowGradientPicker(ColorGradient colorGradient, string dialogHost) + public Task ShowGradientPicker(ColorGradient colorGradient, string dialogHost) { if (!string.IsNullOrWhiteSpace(dialogHost)) - _dialogService.ShowDialogAt(dialogHost, new Dictionary {{"colorGradient", colorGradient}}); - else - _dialogService.ShowDialog(new Dictionary {{"colorGradient", colorGradient}}); + return _dialogService.ShowDialogAt(dialogHost, new Dictionary {{"colorGradient", colorGradient}}); + return _dialogService.ShowDialog(new Dictionary {{"colorGradient", colorGradient}}); } } } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Services/Interfaces/IGradientPickerService.cs b/src/Artemis.UI.Shared/Services/Interfaces/IGradientPickerService.cs index 6ce388682..b28bf378d 100644 --- a/src/Artemis.UI.Shared/Services/Interfaces/IGradientPickerService.cs +++ b/src/Artemis.UI.Shared/Services/Interfaces/IGradientPickerService.cs @@ -1,10 +1,11 @@ -using Artemis.Core.Models.Profile; +using System.Threading.Tasks; +using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile.Colors; namespace Artemis.UI.Shared.Services.Interfaces { public interface IGradientPickerService : IArtemisSharedUIService { - void ShowGradientPicker(ColorGradient colorGradient, string dialogHost); + Task ShowGradientPicker(ColorGradient colorGradient, string dialogHost); } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Abstract/LayerPropertyBaseViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Abstract/LayerPropertyBaseViewModel.cs index b5d81d425..e3f0ac4d4 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Abstract/LayerPropertyBaseViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Abstract/LayerPropertyBaseViewModel.cs @@ -17,7 +17,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract public List Children { get; set; } - public abstract List GetKeyframes(bool visibleOnly); + public abstract List GetKeyframes(bool expandedOnly); public abstract void Dispose(); } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs index a26b72885..174f7fdec 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs @@ -2,12 +2,14 @@ using System.Collections.Generic; using System.Linq; using System.Windows; +using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using Artemis.Core.Events; using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties.Attributes; +using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Services; using Artemis.Core.Services.Interfaces; using Artemis.UI.Events; @@ -85,7 +87,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties NotifyOfPropertyChange(() => TimeCaretPosition); } - private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e) + private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e) { NotifyOfPropertyChange(nameof(TimeCaretPosition)); } @@ -128,17 +130,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, layer.General, (PropertyGroupDescriptionAttribute) generalAttribute)); LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, layer.Transform, (PropertyGroupDescriptionAttribute) transformAttribute)); - if (layer.LayerBrush != null) - { - // Add the rout group of the brush - // The root group of the brush has no attribute so let's pull one out of our sleeve - var brushDescription = new PropertyGroupDescriptionAttribute - { - Name = layer.LayerBrush.Descriptor.DisplayName, - Description = layer.LayerBrush.Descriptor.Description - }; - LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, layer.LayerBrush.BaseProperties, brushDescription)); - } + ApplyLayerBrush(); } else SelectedLayer = null; @@ -149,6 +141,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties private void SelectedLayerOnLayerBrushUpdated(object sender, EventArgs e) { + ApplyLayerBrush(); + } + + public void ApplyLayerBrush() + { + var hideRenderRelatedProperties = SelectedLayer.LayerBrush != null && SelectedLayer.LayerBrush.BrushType == LayerBrushType.RgbNet; + SelectedLayer.General.ShapeType.IsHidden = hideRenderRelatedProperties; + SelectedLayer.General.FillType.IsHidden = hideRenderRelatedProperties; + SelectedLayer.General.BlendMode.IsHidden = hideRenderRelatedProperties; + SelectedLayer.Transform.IsHidden = hideRenderRelatedProperties; + // Get rid of the old layer properties group if (LayerPropertyGroups.Count == 3) { @@ -167,6 +170,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties }; LayerPropertyGroups.Add(new LayerPropertyGroupViewModel(ProfileEditorService, SelectedLayer.LayerBrush.BaseProperties, brushDescription)); } + + TimelineViewModel.UpdateKeyframes(); } #endregion diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs index 831e18d62..44d33dfa0 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs @@ -67,14 +67,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties } } - public override List GetKeyframes(bool visibleOnly) + public override List GetKeyframes(bool expandedOnly) { var result = new List(); - if (visibleOnly && !IsExpanded) + if (expandedOnly && !IsExpanded || LayerPropertyGroup.IsHidden) return result; - + foreach (var layerPropertyBaseViewModel in Children) - result.AddRange(layerPropertyBaseViewModel.GetKeyframes(visibleOnly)); + result.AddRange(layerPropertyBaseViewModel.GetKeyframes(expandedOnly)); return result; } @@ -101,7 +101,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties return result; } - private void LayerPropertyGroupOnVisibilityChanged(object? sender, EventArgs e) + private void LayerPropertyGroupOnVisibilityChanged(object sender, EventArgs e) { NotifyOfPropertyChange(nameof(IsVisible)); } diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyViewModel.cs index 31980c093..ae4a6fbf7 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyViewModel.cs @@ -45,9 +45,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties public TreePropertyViewModel TreePropertyViewModel { get; set; } public TimelinePropertyViewModel TimelinePropertyViewModel { get; set; } - public override List GetKeyframes(bool visibleOnly) + public override List GetKeyframes(bool expandedOnly) { - return LayerProperty.BaseKeyframes.ToList(); + if (LayerProperty.KeyframesEnabled && !LayerProperty.IsHidden) + return LayerProperty.BaseKeyframes.ToList(); + return new List(); } public override void Dispose() @@ -67,9 +69,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties ProfileEditorService.UpdateProfilePreview(); } - private void LayerPropertyOnVisibilityChanged(object? sender, EventArgs e) + private void LayerPropertyOnVisibilityChanged(object sender, EventArgs e) { - NotifyOfPropertyChange(nameof(IsVisible)); + NotifyOfPropertyChange(nameof(IsVisible)); } } diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupView.xaml index f9458962b..b02d17c76 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupView.xaml @@ -9,7 +9,8 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" - d:DataContext="{d:DesignInstance local:TimelinePropertyGroupViewModel}"> + d:DataContext="{d:DesignInstance local:TimelinePropertyGroupViewModel}" + Visibility="{Binding LayerPropertyGroupViewModel.IsVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"> diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupViewModel.cs index 6ddd85e30..69e8c5bc9 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupViewModel.cs @@ -42,7 +42,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline UpdateKeyframes(); } - private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e) + private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e) { UpdateKeyframes(); } diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyViewModel.cs index fe0e3abff..79aa4be1d 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyViewModel.cs @@ -27,7 +27,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline UpdateKeyframes(); } - private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e) + private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e) { foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels) timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond); diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/Abstract/PropertyInputViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/Abstract/PropertyInputViewModel.cs index 093cd05a4..fcbc47752 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/Abstract/PropertyInputViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/Abstract/PropertyInputViewModel.cs @@ -71,7 +71,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyI Validate(); } - private void ApplyInputValue() + protected void ApplyInputValue() { // Force the validator to run if (Validator != null) diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/ColorGradientPropertyInputView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/ColorGradientPropertyInputView.xaml index 981433336..36b05107a 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/ColorGradientPropertyInputView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/ColorGradientPropertyInputView.xaml @@ -5,16 +5,18 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared" xmlns:propertyInput="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyInput" + xmlns:s="https://github.com/canton7/Stylet" mc:Ignorable="d" d:DesignHeight="25" d:DesignWidth="800" d:DataContext="{d:DesignInstance propertyInput:ColorGradientPropertyInputViewModel}"> + Margin="0 2" + Padding="0 -1" + ColorGradient="{Binding InputValue}" + DialogClosed="{s:Action DialogClosed}" + DialogHost="PropertyTreeDialogHost" /> \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/ColorGradientPropertyInputViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/ColorGradientPropertyInputViewModel.cs index e20bbd7b2..222a8d690 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/ColorGradientPropertyInputViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Tree/PropertyInput/ColorGradientPropertyInputViewModel.cs @@ -1,4 +1,5 @@ -using Artemis.Core.Models.Profile.Colors; +using System; +using Artemis.Core.Models.Profile.Colors; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyInput.Abstract; namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyInput @@ -8,5 +9,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree.PropertyI public ColorGradientPropertyInputViewModel(LayerPropertyViewModel layerPropertyViewModel) : base(layerPropertyViewModel) { } + + public void DialogClosed(object sender, EventArgs e) + { + ApplyInputValue(); + } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs index f61881edb..f338700ad 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Linq; using System.Windows; using System.Windows.Input; using Artemis.Core.Events; using Artemis.Core.Models.Profile; using Artemis.Core.Models.Surface; +using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.Models; using Artemis.Core.Services; using Artemis.Core.Services.Storage.Interfaces; @@ -16,7 +16,6 @@ using Artemis.UI.Ninject.Factories; using Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools; using Artemis.UI.Screens.Shared; using Artemis.UI.Services.Interfaces; -using RGB.NET.Core; using Stylet; namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization @@ -30,6 +29,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization private readonly ISurfaceService _surfaceService; private int _activeToolIndex; private VisualizationToolViewModel _activeToolViewModel; + private Layer _previousSelectedLayer; private int _previousTool; public ProfileViewModel(IProfileEditorService profileEditorService, @@ -119,6 +119,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization } } + public List GetLedsInRectangle(Rect selectedRect) + { + return Devices.SelectMany(d => d.Leds) + .Where(led => led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1).IntersectsWith(selectedRect)) + .ToList(); + } + protected override void OnInitialActivate() { OnlyShowSelectedShape = _settingsService.GetSetting("ProfileEditor.OnlyShowSelectedShape", true); @@ -132,7 +139,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization base.OnInitialActivate(); } - + protected override void OnClose() { HighlightSelectedLayer.SettingChanged -= HighlightSelectedLayerOnSettingChanged; @@ -189,6 +196,23 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization HighlightedLeds.AddRange(layer.Leds); } + private void UpdateCanSelectEditTool() + { + if (_profileEditorService.SelectedProfileElement is Layer layer) + { + CanApplyToLayer = true; + CanSelectEditTool = (layer.LayerBrush == null || layer.LayerBrush.BrushType == LayerBrushType.Regular) && layer.Leds.Any(); + } + else + { + CanApplyToLayer = false; + CanSelectEditTool = false; + } + + if (CanSelectEditTool == false && ActiveToolIndex == 1) + ActivateToolByIndex(2); + } + #region Buttons private void ActivateToolByIndex(int value) @@ -300,22 +324,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization private void OnProfileElementSelected(object sender, EventArgs e) { - UpdateLedsDimStatus(); + if (_previousSelectedLayer != null) + _previousSelectedLayer.LayerBrushUpdated -= SelectedLayerOnLayerBrushUpdated; if (_profileEditorService.SelectedProfileElement is Layer layer) { - CanApplyToLayer = true; - CanSelectEditTool = layer.Leds.Any(); + _previousSelectedLayer = layer; + _previousSelectedLayer.LayerBrushUpdated += SelectedLayerOnLayerBrushUpdated; } else - { - CanApplyToLayer = false; - CanSelectEditTool = false; - } - if (CanSelectEditTool == false && ActiveToolIndex == 1) - ActivateToolByIndex(2); + _previousSelectedLayer = null; + + UpdateLedsDimStatus(); + UpdateCanSelectEditTool(); } - + private void SelectedLayerOnLayerBrushUpdated(object? sender, EventArgs e) + { + UpdateCanSelectEditTool(); + } private void OnSelectedProfileElementUpdated(object sender, EventArgs e) { @@ -331,6 +357,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization CanApplyToLayer = false; CanSelectEditTool = false; } + if (CanSelectEditTool == false && ActiveToolIndex == 1) ActivateToolByIndex(2); } @@ -376,12 +403,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization } #endregion - - public List GetLedsInRectangle(Rect selectedRect) - { - return Devices.SelectMany(d => d.Leds) - .Where(led => led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1).IntersectsWith(selectedRect)) - .ToList(); - } } } \ No newline at end of file diff --git a/src/Artemis.sln b/src/Artemis.sln index cc15ae5e9..e540c5a59 100644 --- a/src/Artemis.sln +++ b/src/Artemis.sln @@ -14,6 +14,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Artemis.UI", "Artemis.UI\Ar {0F288A66-6EB0-4589-8595-E33A3A3EAEA2} = {0F288A66-6EB0-4589-8595-E33A3A3EAEA2} {A46F278A-FC2C-4342-8455-994D957DDA03} = {A46F278A-FC2C-4342-8455-994D957DDA03} {26902C94-3EBC-4132-B7F0-FFCAB8E150DA} = {26902C94-3EBC-4132-B7F0-FFCAB8E150DA} + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1} = {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1} {7F4C7AB0-4C9B-452D-AFED-34544C903DEF} = {7F4C7AB0-4C9B-452D-AFED-34544C903DEF} {235A45C7-24AD-4F47-B9D4-CD67E610A04D} = {235A45C7-24AD-4F47-B9D4-CD67E610A04D} {D004FEC9-0CF8-4828-B620-95DBA73201A3} = {D004FEC9-0CF8-4828-B620-95DBA73201A3} @@ -66,6 +67,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LayerBrushes", "LayerBrushe EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{B258A061-FA19-4835-8DC4-E9C3AE3664A0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Artemis.Plugins.LayerBrushes.ColorRgbNet", "Plugins\Artemis.Plugins.LayerBrushes.ColorRgbNet\Artemis.Plugins.LayerBrushes.ColorRgbNet.csproj", "{301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -226,6 +229,14 @@ Global {A46F278A-FC2C-4342-8455-994D957DDA03}.Release|Any CPU.Build.0 = Release|Any CPU {A46F278A-FC2C-4342-8455-994D957DDA03}.Release|x64.ActiveCfg = Release|Any CPU {A46F278A-FC2C-4342-8455-994D957DDA03}.Release|x64.Build.0 = Release|Any CPU + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}.Debug|x64.ActiveCfg = Debug|Any CPU + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}.Debug|x64.Build.0 = Debug|Any CPU + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}.Release|Any CPU.Build.0 = Release|Any CPU + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}.Release|x64.ActiveCfg = Release|Any CPU + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -249,6 +260,7 @@ Global {88792A7E-F037-4280-81D3-B131508EF1D8} = {E830A02B-A7E5-4A6B-943F-76B0A542630C} {A311DC47-42A2-4DD4-B921-50FBF7A33F41} = {E830A02B-A7E5-4A6B-943F-76B0A542630C} {B258A061-FA19-4835-8DC4-E9C3AE3664A0} = {E830A02B-A7E5-4A6B-943F-76B0A542630C} + {301C3AAA-9F79-46A5-9B9D-86F076C5BDD1} = {A311DC47-42A2-4DD4-B921-50FBF7A33F41} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {C203080A-4473-4CC2-844B-F552EA43D66A} diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs index 033143871..f3f9685a3 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs @@ -26,8 +26,6 @@ namespace Artemis.Plugins.LayerBrushes.Color _color = Properties.Color.CurrentValue; CreateShader(); } - - base.Update(deltaTime); } public override void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint) @@ -42,6 +40,17 @@ namespace Artemis.Plugins.LayerBrushes.Color canvas.DrawPath(path, paint); } + protected override void Dispose(bool disposing) + { + if (disposing) + { + _paint?.Dispose(); + _shader?.Dispose(); + } + + base.Dispose(disposing); + } + protected override void OnPropertiesInitialized() { Properties.GradientType.BaseValueChanged += (sender, args) => CreateShader(); diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/Artemis.Plugins.LayerBrushes.ColorRgbNet.csproj b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/Artemis.Plugins.LayerBrushes.ColorRgbNet.csproj new file mode 100644 index 000000000..f4ea5ac8d --- /dev/null +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/Artemis.Plugins.LayerBrushes.ColorRgbNet.csproj @@ -0,0 +1,53 @@ + + + netcoreapp3.1 + false + Artemis.Plugins.LayerBrushes.ColorRgbNet + Artemis + Copyright © Robert Beekman - 2019 + MinimumRecommendedRules.ruleset + bin\$(Platform)\$(Configuration)\ + true + + + full + 7 + + + pdbonly + 7.3 + + + + PreserveNewest + + + + + + + + + + + + + + false + + + + + ..\..\..\..\RGB.NET\bin\netstandard2.0\RGB.NET.Brushes.dll + + + ..\..\..\..\RGB.NET\bin\netstandard2.0\RGB.NET.Core.dll + + + ..\..\..\..\RGB.NET\bin\netstandard2.0\RGB.NET.Groups.dll + + + + + + \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/Properties/AssemblyInfo.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..87d3be987 --- /dev/null +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +using System.Runtime.InteropServices; + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0f288a66-6eb0-4589-8595-e33a3a3eaea2")] \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrush.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrush.cs new file mode 100644 index 000000000..7cf6a9e86 --- /dev/null +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrush.cs @@ -0,0 +1,28 @@ +using Artemis.Core.Extensions; +using Artemis.Core.Models.Profile; +using Artemis.Core.Plugins.LayerBrush; +using RGB.NET.Brushes; +using RGB.NET.Core; + +namespace Artemis.Plugins.LayerBrushes.ColorRgbNet +{ + public class RgbNetColorBrush : RgbNetLayerBrush + { + private readonly SolidColorBrush _solidBrush; + + public RgbNetColorBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor) + { + _solidBrush = new SolidColorBrush(Color.Transparent); + } + + public override void Update(double deltaTime) + { + _solidBrush.Color = Properties.Color.CurrentValue.ToRgbColor(); + } + + public override IBrush GetBrush() + { + return _solidBrush; + } + } +} \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrushProperties.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrushProperties.cs new file mode 100644 index 000000000..5364e5d32 --- /dev/null +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrushProperties.cs @@ -0,0 +1,22 @@ +using Artemis.Core.Models.Profile; +using Artemis.Core.Models.Profile.LayerProperties.Attributes; +using Artemis.Core.Models.Profile.LayerProperties.Types; +using SkiaSharp; + +namespace Artemis.Plugins.LayerBrushes.ColorRgbNet +{ + public class RgbNetColorBrushProperties : LayerPropertyGroup + { + [PropertyDescription(Description = "The color of the brush")] + public SKColorLayerProperty Color { get; set; } + + protected override void PopulateDefaults() + { + Color.DefaultValue = new SKColor(255, 0, 0); + } + + protected override void OnPropertiesInitialized() + { + } + } +} \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrushProvider.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrushProvider.cs new file mode 100644 index 000000000..ec6116510 --- /dev/null +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/RgbNetColorBrushProvider.cs @@ -0,0 +1,25 @@ +using Artemis.Core.Plugins.LayerBrush; +using Artemis.Core.Plugins.Models; + +namespace Artemis.Plugins.LayerBrushes.ColorRgbNet +{ + public class RgbNetColorBrushProvider : LayerBrushProvider + { + public RgbNetColorBrushProvider(PluginInfo pluginInfo) : base(pluginInfo) + { + AddLayerBrushDescriptor("RGB.NET Color", "A RGB.NET based color", "Brush"); + } + + public override void EnablePlugin() + { + } + + public override void DisablePlugin() + { + } + + public override void Dispose() + { + } + } +} \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/app.config b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/app.config new file mode 100644 index 000000000..9d3293c49 --- /dev/null +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/app.config @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/plugin.json b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/plugin.json new file mode 100644 index 000000000..3551dab18 --- /dev/null +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.ColorRgbNet/plugin.json @@ -0,0 +1,7 @@ +{ + "Guid": "0bbf931b-87ad-4809-9cd9-bda33f4d4695", + "Name": "RGB.NET Color layer brush", + "Description": "A basic RGB.NET-based color layer-brush providing solid colors and several types of gradients.", + "Version": "1.0.0.0", + "Main": "Artemis.Plugins.LayerBrushes.ColorRgbNet.dll" +} \ No newline at end of file diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs index e70611f69..3b4633e22 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs @@ -47,7 +47,6 @@ namespace Artemis.Plugins.LayerBrushes.Noise _z = 0; DetermineRenderScale(); - base.Update(deltaTime); } public override void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint) @@ -105,6 +104,16 @@ namespace Artemis.Plugins.LayerBrushes.Noise canvas.DrawRect(path.Bounds, paint); } + protected override void Dispose(bool disposing) + { + if (disposing) + { + _bitmap?.Dispose(); + } + + base.Dispose(disposing); + } + protected override void OnPropertiesInitialized() { Properties.GradientColor.BaseValue.PropertyChanged += GradientColorChanged;