mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Layer brushes - Make enable-disable process consistent with plugins
This commit is contained in:
parent
a1c2e4ad5a
commit
ee37c3b836
@ -408,6 +408,23 @@ namespace Artemis.Core.Models.Profile
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
internal void Deactivate()
|
||||
{
|
||||
DeactivateLayerBrush();
|
||||
}
|
||||
|
||||
internal void DeactivateLayerBrush()
|
||||
{
|
||||
if (LayerBrush == null)
|
||||
return;
|
||||
|
||||
var brush = LayerBrush;
|
||||
LayerBrush = null;
|
||||
brush.Dispose();
|
||||
|
||||
LayerEntity.PropertyEntities.RemoveAll(p => p.PluginGuid == brush.PluginInfo.Guid);
|
||||
}
|
||||
|
||||
internal void PopulateLeds(ArtemisSurface surface)
|
||||
{
|
||||
var leds = new List<ArtemisLed>();
|
||||
|
||||
@ -129,7 +129,11 @@ namespace Artemis.Core.Models.Profile
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if (!IsActivated) return;
|
||||
if (!IsActivated)
|
||||
return;
|
||||
|
||||
foreach (var layer in GetAllLayers())
|
||||
layer.Deactivate();
|
||||
|
||||
IsActivated = false;
|
||||
OnDeactivated();
|
||||
|
||||
@ -43,7 +43,7 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisablePlugin()
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
// Does not happen with device providers, they require Artemis to restart
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
28
src/Artemis.Core/Plugins/Abstract/LayerEffectProvider.cs
Normal file
28
src/Artemis.Core/Plugins/Abstract/LayerEffectProvider.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Allows you to create one or more <see cref="LayerEffect" />s usable by profile layers.
|
||||
/// </summary>
|
||||
public class LayerEffectProvider : Plugin
|
||||
{
|
||||
public LayerEffectProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -30,19 +30,18 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
DisablePlugin();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the plugin is activated
|
||||
/// </summary>
|
||||
protected abstract void EnablePlugin();
|
||||
public abstract void EnablePlugin();
|
||||
|
||||
/// <summary>
|
||||
/// Called when the plugin is deactivated
|
||||
/// Called when the plugin is deactivated or when Artemis shuts down
|
||||
/// </summary>
|
||||
protected abstract void DisablePlugin();
|
||||
public abstract void DisablePlugin();
|
||||
|
||||
/// <summary>
|
||||
/// Called when the plugins configuration window is opened from the UI. The UI will only attempt to open if
|
||||
@ -54,17 +53,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when Artemis shuts down
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetEnabled(bool enable)
|
||||
{
|
||||
if (enable && !Enabled)
|
||||
|
||||
@ -46,9 +46,14 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
public virtual LayerPropertyGroup BaseProperties => null;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the brush is being removed from the layer
|
||||
/// Called when the layer brush is activated
|
||||
/// </summary>
|
||||
public abstract void Dispose();
|
||||
public abstract void EnableLayerBrush();
|
||||
|
||||
/// <summary>
|
||||
/// Called when the layer brush is deactivated
|
||||
/// </summary>
|
||||
public abstract void DisableLayerBrush();
|
||||
|
||||
/// <summary>
|
||||
/// Called before rendering every frame, write your update logic here
|
||||
@ -67,6 +72,11 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
/// </summary>
|
||||
/// <returns>Your RGB.NET brush</returns>
|
||||
internal abstract IBrush InternalGetBrush();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DisableLayerBrush();
|
||||
}
|
||||
}
|
||||
|
||||
public enum LayerBrushType
|
||||
|
||||
@ -43,15 +43,5 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
InitializeProperties(layerService);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
|
||||
@ -39,18 +39,11 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
internal set => _properties = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when all layer properties in this brush have been initialized
|
||||
/// </summary>
|
||||
protected virtual void OnPropertiesInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
internal void InitializeProperties(ILayerService layerService)
|
||||
{
|
||||
Properties = Activator.CreateInstance<T>();
|
||||
Properties.InitializeProperties(layerService, Layer, "LayerBrush.");
|
||||
OnPropertiesInitialized();
|
||||
EnableLayerBrush();
|
||||
PropertiesInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
64
src/Artemis.Core/Plugins/LayerEffect/BaseLayerEffect.cs
Normal file
64
src/Artemis.Core/Plugins/LayerEffect/BaseLayerEffect.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// For internal use only, please use <see cref="LayerEffect" /> instead
|
||||
/// </summary>
|
||||
public abstract class BaseLayerEffect : IDisposable
|
||||
{
|
||||
protected BaseLayerEffect(Layer layer, LayerEffectDescriptor descriptor)
|
||||
{
|
||||
Layer = layer;
|
||||
Descriptor = descriptor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the layer this brush is applied to
|
||||
/// </summary>
|
||||
public Layer Layer { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the descriptor of this brush
|
||||
/// </summary>
|
||||
public LayerEffectDescriptor Descriptor { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin info that defined this brush
|
||||
/// </summary>
|
||||
public PluginInfo PluginInfo => Descriptor.LayerEffectProvider.PluginInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a reference to the layer property group without knowing it's type
|
||||
/// </summary>
|
||||
public virtual LayerPropertyGroup BaseProperties => null;
|
||||
|
||||
/// <summary>
|
||||
/// Called when the brush is being removed from the layer
|
||||
/// </summary>
|
||||
public abstract void Dispose();
|
||||
|
||||
/// <summary>
|
||||
/// Called before rendering every frame, write your update logic here
|
||||
/// </summary>
|
||||
/// <param name="deltaTime"></param>
|
||||
public abstract void Update(double deltaTime);
|
||||
|
||||
// Not only is this needed to initialize properties on the layer brushes, it also prevents implementing anything
|
||||
// but LayerEffect<T> and RgbNetLayerEffect<T> outside the core
|
||||
internal abstract void Initialize(ILayerService layerService);
|
||||
|
||||
internal abstract void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
|
||||
|
||||
/// <summary>
|
||||
/// Called when Artemis needs an instance of the RGB.NET brush you are implementing
|
||||
/// </summary>
|
||||
/// <returns>Your RGB.NET brush</returns>
|
||||
internal abstract IBrush InternalGetBrush();
|
||||
}
|
||||
}
|
||||
95
src/Artemis.Core/Plugins/LayerEffect/LayerEffect.cs
Normal file
95
src/Artemis.Core/Plugins/LayerEffect/LayerEffect.cs
Normal file
@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// For internal use only, please use <see cref="LayerEffect" /> instead
|
||||
/// </summary>
|
||||
public abstract class LayerEffect<T> : BaseLayerEffect where T : LayerPropertyGroup
|
||||
{
|
||||
private T _properties;
|
||||
|
||||
protected LayerEffect(Layer layer, LayerEffectDescriptor descriptor) : base(layer, descriptor)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether all properties on this brush are initialized
|
||||
/// </summary>
|
||||
public bool PropertiesInitialized { get; internal set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override LayerPropertyGroup BaseProperties => Properties;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the properties of this brush.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when all layer properties in this brush have been initialized
|
||||
/// </summary>
|
||||
protected virtual void OnPropertiesInitialized()
|
||||
{
|
||||
}
|
||||
|
||||
internal void InitializeProperties(ILayerService layerService)
|
||||
{
|
||||
Properties = Activator.CreateInstance<T>();
|
||||
Properties.InitializeProperties(layerService, Layer, "LayerEffect.");
|
||||
OnPropertiesInitialized();
|
||||
PropertiesInitialized = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main method of rendering anything to the layer. The provided <see cref="SKCanvas" /> is specific to the layer
|
||||
/// and matches it's width and height.
|
||||
/// <para>Called during rendering or layer preview, in the order configured on the layer</para>
|
||||
/// </summary>
|
||||
/// <param name="canvas">The layer canvas</param>
|
||||
/// <param name="canvasInfo"></param>
|
||||
/// <param name="path">The path to be filled, represents the shape</param>
|
||||
/// <param name="paint">The paint to be used to fill the shape</param>
|
||||
public abstract void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
|
||||
|
||||
internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
{
|
||||
// Move the canvas to the top-left of the render path
|
||||
canvas.Translate(path.Bounds.Left, path.Bounds.Top);
|
||||
// Pass the render path to the layer brush positioned at 0,0
|
||||
path.Transform(SKMatrix.MakeTranslation(path.Bounds.Left * -1, path.Bounds.Top * -1));
|
||||
|
||||
Render(canvas, canvasInfo, path, paint);
|
||||
}
|
||||
|
||||
internal override void Initialize(ILayerService layerService)
|
||||
{
|
||||
InitializeProperties(layerService);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerEffect
|
||||
{
|
||||
public class LayerEffectDescriptor
|
||||
{
|
||||
internal LayerEffectDescriptor(string displayName, string description, string icon, Type layerEffectType, LayerEffectProvider layerEffectProvider)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
Description = description;
|
||||
Icon = icon;
|
||||
LayerEffectType = layerEffectType;
|
||||
LayerEffectProvider = layerEffectProvider;
|
||||
}
|
||||
|
||||
public string DisplayName { get; }
|
||||
public string Description { get; }
|
||||
public string Icon { get; }
|
||||
public Type LayerEffectType { get; }
|
||||
public LayerEffectProvider LayerEffectProvider { get; }
|
||||
}
|
||||
}
|
||||
@ -22,11 +22,5 @@ namespace Artemis.Core.Services.Interfaces
|
||||
/// <param name="layer">The layer to instantiate the brush for</param>
|
||||
/// <returns></returns>
|
||||
BaseLayerBrush InstantiateLayerBrush(Layer layer);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the layer brush from the provided layer and disposes it
|
||||
/// </summary>
|
||||
/// <param name="layer"></param>
|
||||
void RemoveLayerBrush(Layer layer);
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Ninject;
|
||||
@ -40,7 +41,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
public BaseLayerBrush InstantiateLayerBrush(Layer layer)
|
||||
{
|
||||
RemoveLayerBrush(layer);
|
||||
layer.DeactivateLayerBrush();
|
||||
|
||||
var descriptorReference = layer.General.BrushReference?.CurrentValue;
|
||||
if (descriptorReference == null)
|
||||
@ -66,17 +67,5 @@ namespace Artemis.Core.Services
|
||||
layer.OnLayerBrushUpdated();
|
||||
return layer.LayerBrush;
|
||||
}
|
||||
|
||||
public void RemoveLayerBrush(Layer layer)
|
||||
{
|
||||
if (layer.LayerBrush == null)
|
||||
return;
|
||||
|
||||
var brush = layer.LayerBrush;
|
||||
layer.LayerBrush = null;
|
||||
brush.Dispose();
|
||||
|
||||
layer.LayerEntity.PropertyEntities.RemoveAll(p => p.PluginGuid == brush.PluginInfo.Guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using System.Linq;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Shared.PropertyInput;
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Artemis.Plugins.Devices.Asus
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(AsusRGBDevice<>), sender, args);
|
||||
_rgbService.AddDeviceProvider(RgbDeviceProvider);
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Artemis.Plugins.Devices.CoolerMaster
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CoolerMasterRGBDevice<>), sender, args);
|
||||
RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CMSDK.dll"));
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Artemis.Plugins.Devices.Corsair
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CorsairRGBDevice<>), sender, args);
|
||||
RGB.NET.Devices.Corsair.CorsairDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CUESDK.x64_2017.dll"));
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Artemis.Plugins.Devices.DMX
|
||||
HasConfigurationViewModel = true;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
// TODO: Load from configuration
|
||||
// RGB.NET.Devices.DMX.DMXDeviceProvider.Instance.AddDeviceDefinition();
|
||||
|
||||
@ -25,7 +25,7 @@ namespace Artemis.Plugins.Devices.Logitech
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(LogitechRGBDevice<>), sender, args);
|
||||
RGB.NET.Devices.Logitech.LogitechDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "LogitechLedEnginesWrapper.dll"));
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Artemis.Plugins.Devices.Msi
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(MsiRGBDevice<>), sender, args);
|
||||
RGB.NET.Devices.Msi.MsiDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "MysticLight_SDK.dll"));
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Artemis.Plugins.Devices.Novation
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(NovationRGBDevice<>), sender, args);
|
||||
_rgbService.AddDeviceProvider(RgbDeviceProvider);
|
||||
|
||||
@ -18,7 +18,7 @@ namespace Artemis.Plugins.Devices.Razer
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(RazerRGBDevice<>), sender, args);
|
||||
RGB.NET.Devices.Razer.RazerDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "RzChromaSDK.dll"));
|
||||
|
||||
@ -15,7 +15,7 @@ namespace Artemis.Plugins.Devices.Roccat
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
// TODO: Find out why this is missing, Roccat seems unimplemented
|
||||
// PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(RoccatRGBDevice<>), sender, args);
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Artemis.Plugins.Devices.SteelSeries
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
// TODO Check to see if this works, it's usually a generic type after all
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(SteelSeriesRGBDevice), sender, args);
|
||||
|
||||
@ -25,7 +25,7 @@ namespace Artemis.Plugins.Devices.WS281X
|
||||
|
||||
public PluginSettings Settings { get; }
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
var definitions = Settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
|
||||
if (definitions.Value == null)
|
||||
@ -49,7 +49,7 @@ namespace Artemis.Plugins.Devices.WS281X
|
||||
_rgbService.AddDeviceProvider(RgbDeviceProvider);
|
||||
}
|
||||
|
||||
protected override void DisablePlugin()
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
// TODO: Remove the device provider from the surface
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Artemis.Plugins.Devices.Wooting
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(WootingRGBDevice<>), sender, args);
|
||||
RGB.NET.Devices.Wooting.WootingDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "wooting-rgb-sdk64.dll"));
|
||||
@ -25,7 +25,7 @@ namespace Artemis.Plugins.Devices.Wooting
|
||||
_rgbService.AddDeviceProvider(RgbDeviceProvider);
|
||||
}
|
||||
|
||||
protected override void DisablePlugin()
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
// TODO: Remove the device provider from the surface
|
||||
}
|
||||
|
||||
@ -17,6 +17,21 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
||||
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
|
||||
}
|
||||
|
||||
public override void EnableLayerBrush()
|
||||
{
|
||||
Properties.GradientType.BaseValueChanged += (sender, args) => CreateShader();
|
||||
Properties.Color.BaseValueChanged += (sender, args) => CreateShader();
|
||||
Properties.Gradient.BaseValue.PropertyChanged += (sender, args) => CreateShader();
|
||||
}
|
||||
|
||||
public override void DisableLayerBrush()
|
||||
{
|
||||
_paint?.Dispose();
|
||||
_shader?.Dispose();
|
||||
_paint = null;
|
||||
_shader = null;
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
// Only check if a solid is being drawn, because that can be changed by keyframes
|
||||
@ -40,24 +55,6 @@ 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();
|
||||
Properties.Color.BaseValueChanged += (sender, args) => CreateShader();
|
||||
Properties.Gradient.BaseValue.PropertyChanged += (sender, args) => CreateShader();
|
||||
}
|
||||
|
||||
private void CreateShader()
|
||||
{
|
||||
var center = new SKPoint(_shaderBounds.MidX, _shaderBounds.MidY);
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Color
|
||||
@ -10,11 +11,11 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
||||
AddLayerBrushDescriptor<ColorBrush>("Color", "A color with an (optional) gradient", "Brush");
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DisablePlugin()
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using RGB.NET.Brushes;
|
||||
@ -16,6 +15,14 @@ namespace Artemis.Plugins.LayerBrushes.ColorRgbNet
|
||||
_solidBrush = new SolidColorBrush(Color.Transparent);
|
||||
}
|
||||
|
||||
public override void EnableLayerBrush()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DisableLayerBrush()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
_solidBrush.Color = Properties.Color.CurrentValue.ToRgbColor();
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Plugins.LayerBrushes.ColorRgbNet.PropertyInput;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
@ -15,12 +15,12 @@ namespace Artemis.Plugins.LayerBrushes.ColorRgbNet
|
||||
AddLayerBrushDescriptor<RgbNetColorBrush>("RGB.NET Color", "A RGB.NET based color", "Brush");
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
_profileEditorService.RegisterPropertyInput(PluginInfo, typeof(StringPropertyInputViewModel));
|
||||
}
|
||||
|
||||
protected override void DisablePlugin()
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,6 +32,18 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
DetermineRenderScale();
|
||||
}
|
||||
|
||||
public override void EnableLayerBrush()
|
||||
{
|
||||
Properties.GradientColor.BaseValue.PropertyChanged += GradientColorChanged;
|
||||
CreateColorMap();
|
||||
}
|
||||
|
||||
public override void DisableLayerBrush()
|
||||
{
|
||||
_bitmap?.Dispose();
|
||||
_bitmap = null;
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
_x += Properties.ScrollSpeed.CurrentValue.X / 500f / (float) deltaTime;
|
||||
@ -104,22 +116,6 @@ 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;
|
||||
CreateColorMap();
|
||||
}
|
||||
|
||||
private void GradientColorChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
CreateColorMap();
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.Colors;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Types;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
@ -10,11 +11,11 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
AddLayerBrushDescriptor<NoiseBrush>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DisablePlugin()
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,11 +27,11 @@ namespace Artemis.Plugins.Modules.General
|
||||
return new List<ModuleViewModel> {new GeneralViewModel(this)};
|
||||
}
|
||||
|
||||
protected override void EnablePlugin()
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DisablePlugin()
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user