1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-31 17:53:32 +00:00

Merge branch 'bleh'

This commit is contained in:
SpoinkyNL 2020-06-07 21:58:31 +02:00
commit 728805301a
54 changed files with 461 additions and 349 deletions

View File

@ -8,6 +8,7 @@ using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Models.Profile.LayerShapes; using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
@ -408,6 +409,23 @@ namespace Artemis.Core.Models.Profile
CalculateRenderProperties(); 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) internal void PopulateLeds(ArtemisSurface surface)
{ {
var leds = new List<ArtemisLed>(); var leds = new List<ArtemisLed>();

View File

@ -129,7 +129,11 @@ namespace Artemis.Core.Models.Profile
{ {
lock (this) lock (this)
{ {
if (!IsActivated) return; if (!IsActivated)
return;
foreach (var layer in GetAllLayers())
layer.Deactivate();
IsActivated = false; IsActivated = false;
OnDeactivated(); OnDeactivated();

View File

@ -1,6 +1,4 @@
using Artemis.Core.Plugins.Models; namespace Artemis.Core.Plugins.Abstract
namespace Artemis.Core.Plugins.Abstract
{ {
/// <inheritdoc /> /// <inheritdoc />
/// <summary> /// <summary>
@ -8,10 +6,6 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary> /// </summary>
public abstract class DataModelExpansion : Plugin public abstract class DataModelExpansion : Plugin
{ {
protected DataModelExpansion(PluginInfo pluginInfo) : base(pluginInfo)
{
}
public abstract void Update(double deltaTime); public abstract void Update(double deltaTime);
} }
} }

View File

@ -2,7 +2,7 @@
namespace Artemis.Core.Plugins.Abstract.DataModels.Attributes namespace Artemis.Core.Plugins.Abstract.DataModels.Attributes
{ {
[AttributeUsage(System.AttributeTargets.Property)] [AttributeUsage(AttributeTargets.Property)]
public class DataModelPropertyAttribute : Attribute public class DataModelPropertyAttribute : Attribute
{ {
/// <summary> /// <summary>

View File

@ -1,7 +1,6 @@
using System; using System;
using System.IO; using System.IO;
using Artemis.Core.Extensions; using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Models;
using Ninject; using Ninject;
using RGB.NET.Core; using RGB.NET.Core;
using Serilog; using Serilog;
@ -14,7 +13,7 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary> /// </summary>
public abstract class DeviceProvider : Plugin public abstract class DeviceProvider : Plugin
{ {
protected DeviceProvider(PluginInfo pluginInfo, IRGBDeviceProvider rgbDeviceProvider) : base(pluginInfo) protected DeviceProvider(IRGBDeviceProvider rgbDeviceProvider)
{ {
RgbDeviceProvider = rgbDeviceProvider ?? throw new ArgumentNullException(nameof(rgbDeviceProvider)); RgbDeviceProvider = rgbDeviceProvider ?? throw new ArgumentNullException(nameof(rgbDeviceProvider));
} }
@ -24,6 +23,11 @@ namespace Artemis.Core.Plugins.Abstract
[Inject] [Inject]
public ILogger Logger { get; set; } public ILogger Logger { get; set; }
public override void DisablePlugin()
{
// Does not happen with device providers, they require Artemis to restart
}
protected void ResolveAbsolutePath(Type type, object sender, ResolvePathEventArgs e) protected void ResolveAbsolutePath(Type type, object sender, ResolvePathEventArgs e)
{ {
if (sender.GetType().IsGenericType(type)) if (sender.GetType().IsGenericType(type))
@ -42,10 +46,5 @@ namespace Artemis.Core.Plugins.Abstract
} }
} }
} }
protected override void DisablePlugin()
{
// Does not happen with device providers, they require Artemis to restart
}
} }
} }

View File

@ -0,0 +1,46 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract;
namespace Artemis.Core.Plugins.Abstract
{
/// <inheritdoc />
/// <summary>
/// Allows you to create one or more <see cref="LayerBrush" />s usable by profile layers.
/// </summary>
public abstract class LayerBrushProvider : Plugin
{
private readonly List<LayerBrushDescriptor> _layerBrushDescriptors;
protected LayerBrushProvider()
{
_layerBrushDescriptors = new List<LayerBrushDescriptor>();
}
/// <summary>
/// A read-only collection of all layer brushes added with <see cref="AddLayerBrushDescriptor{T}" />
/// </summary>
public ReadOnlyCollection<LayerBrushDescriptor> LayerBrushDescriptors => _layerBrushDescriptors.AsReadOnly();
/// <summary>
/// Adds a layer brush descriptor for a given layer brush, so that it appears in the UI.
/// <para>Note: You do not need to manually remove these on disable</para>
/// </summary>
/// <typeparam name="T">The type of the layer brush you wish to register</typeparam>
/// <param name="displayName">The name to display in the UI</param>
/// <param name="description">The description to display in the UI</param>
/// <param name="icon">
/// The Material icon to display in the UI, a full reference can be found
/// <see href="https://materialdesignicons.com">here</see>
/// </param>
protected void AddLayerBrushDescriptor<T>(string displayName, string description, string icon) where T : BaseLayerBrush
{
if (!Enabled)
throw new ArtemisPluginException(PluginInfo, "Can only add a layer brush descriptor when the plugin is enabled");
_layerBrushDescriptors.Add(new LayerBrushDescriptor(displayName, description, icon, typeof(T), this));
}
}
}

View File

@ -0,0 +1,21 @@
using System;
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 override void EnablePlugin()
{
throw new NotImplementedException();
}
public override void DisablePlugin()
{
throw new NotImplementedException();
}
}
}

View File

@ -2,7 +2,6 @@
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract.DataModels; using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.ViewModels; using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Models;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core.Plugins.Abstract namespace Artemis.Core.Plugins.Abstract
@ -13,10 +12,6 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary> /// </summary>
public abstract class Module : Plugin public abstract class Module : Plugin
{ {
protected Module(PluginInfo pluginInfo) : base(pluginInfo)
{
}
/// <summary> /// <summary>
/// The modules display name that's shown in the menu /// The modules display name that's shown in the menu
/// </summary> /// </summary>

View File

@ -10,11 +10,6 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary> /// </summary>
public abstract class Plugin : IDisposable public abstract class Plugin : IDisposable
{ {
internal Plugin(PluginInfo pluginInfo)
{
PluginInfo = pluginInfo ?? throw new ArgumentNullException(nameof(pluginInfo));
}
public PluginInfo PluginInfo { get; internal set; } public PluginInfo PluginInfo { get; internal set; }
/// <summary> /// <summary>
@ -28,21 +23,15 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary> /// </summary>
public bool HasConfigurationViewModel { get; protected set; } public bool HasConfigurationViewModel { get; protected set; }
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary> /// <summary>
/// Called when the plugin is activated /// Called when the plugin is activated
/// </summary> /// </summary>
protected abstract void EnablePlugin(); public abstract void EnablePlugin();
/// <summary> /// <summary>
/// Called when the plugin is deactivated /// Called when the plugin is deactivated or when Artemis shuts down
/// </summary> /// </summary>
protected abstract void DisablePlugin(); public abstract void DisablePlugin();
/// <summary> /// <summary>
/// Called when the plugins configuration window is opened from the UI. The UI will only attempt to open if /// Called when the plugins configuration window is opened from the UI. The UI will only attempt to open if
@ -54,31 +43,25 @@ namespace Artemis.Core.Plugins.Abstract
return null; 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) internal void SetEnabled(bool enable)
{ {
if (enable && !Enabled) if (enable && !Enabled)
{ {
Enabled = true;
EnablePlugin(); EnablePlugin();
OnPluginEnabled(); OnPluginEnabled();
} }
else if (!enable && Enabled) else if (!enable && Enabled)
{ {
Enabled = false;
DisablePlugin(); DisablePlugin();
OnPluginDisabled(); OnPluginDisabled();
} }
}
Enabled = enable; public void Dispose()
{
DisablePlugin();
} }
#region Events #region Events

View File

@ -2,17 +2,12 @@
using Artemis.Core.Exceptions; using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Models;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core.Plugins.Abstract namespace Artemis.Core.Plugins.Abstract
{ {
public abstract class ProfileModule : Module public abstract class ProfileModule : Module
{ {
protected ProfileModule(PluginInfo pluginInfo) : base(pluginInfo)
{
}
public Profile ActiveProfile { get; private set; } public Profile ActiveProfile { get; private set; }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,25 +1,16 @@
using System; using System;
using System.Linq;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core;
using RGB.NET.Groups;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core.Plugins.LayerBrush namespace Artemis.Core.Plugins.LayerBrush.Abstract
{ {
/// <summary> /// <summary>
/// For internal use only, please use <see cref="LayerBrush{T}" /> or <see cref="RgbNetLayerBrush{T}" /> or instead /// For internal use only, please use <see cref="LayerBrush{T}" /> or <see cref="RgbNetLayerBrush{T}" /> or instead
/// </summary> /// </summary>
public abstract class BaseLayerBrush : IDisposable public abstract class BaseLayerBrush : IDisposable
{ {
protected BaseLayerBrush(Layer layer, LayerBrushDescriptor descriptor)
{
Layer = layer;
Descriptor = descriptor;
}
/// <summary> /// <summary>
/// Gets the layer this brush is applied to /// Gets the layer this brush is applied to
/// </summary> /// </summary>
@ -44,11 +35,24 @@ namespace Artemis.Core.Plugins.LayerBrush
/// Gets a reference to the layer property group without knowing it's type /// Gets a reference to the layer property group without knowing it's type
/// </summary> /// </summary>
public virtual LayerPropertyGroup BaseProperties => null; public virtual LayerPropertyGroup BaseProperties => null;
public void Dispose()
{
DisableLayerBrush();
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary> /// <summary>
/// Called when the brush is being removed from the layer /// Called when the layer brush is activated
/// </summary> /// </summary>
public abstract void Dispose(); public abstract void EnableLayerBrush();
/// <summary>
/// Called when the layer brush is deactivated
/// </summary>
public abstract void DisableLayerBrush();
/// <summary> /// <summary>
/// Called before rendering every frame, write your update logic here /// Called before rendering every frame, write your update logic here
@ -62,11 +66,9 @@ namespace Artemis.Core.Plugins.LayerBrush
internal abstract void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint); internal abstract void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
/// <summary> internal virtual void Dispose(bool disposing)
/// 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();
} }
public enum LayerBrushType public enum LayerBrushType

View File

@ -1,14 +1,12 @@
using System; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core.Plugins.LayerBrush namespace Artemis.Core.Plugins.LayerBrush.Abstract
{ {
public abstract class LayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup public abstract class LayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup
{ {
protected LayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor) protected LayerBrush()
{ {
BrushType = LayerBrushType.Regular; BrushType = LayerBrushType.Regular;
} }
@ -23,7 +21,7 @@ namespace Artemis.Core.Plugins.LayerBrush
/// <param name="path">The path to be filled, represents the shape</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> /// <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); public abstract void Render(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
internal override void InternalRender(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 // Move the canvas to the top-left of the render path
@ -34,24 +32,9 @@ namespace Artemis.Core.Plugins.LayerBrush
Render(canvas, canvasInfo, path, paint); Render(canvas, canvasInfo, path, paint);
} }
internal override IBrush InternalGetBrush()
{
throw new NotImplementedException("Regular layer brushes do not implement InternalGetBrush");
}
internal override void Initialize(ILayerService layerService) internal override void Initialize(ILayerService layerService)
{ {
InitializeProperties(layerService); InitializeProperties(layerService);
} }
protected virtual void Dispose(bool disposing)
{
}
public sealed override void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
} }
} }

View File

@ -3,7 +3,7 @@ using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Exceptions; using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
namespace Artemis.Core.Plugins.LayerBrush namespace Artemis.Core.Plugins.LayerBrush.Abstract
{ {
/// <summary> /// <summary>
/// For internal use only, please use <see cref="LayerBrush{T}" /> or <see cref="RgbNetLayerBrush{T}" /> or instead /// For internal use only, please use <see cref="LayerBrush{T}" /> or <see cref="RgbNetLayerBrush{T}" /> or instead
@ -12,10 +12,6 @@ namespace Artemis.Core.Plugins.LayerBrush
{ {
private T _properties; private T _properties;
protected PropertiesLayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor)
{
}
/// <summary> /// <summary>
/// Gets whether all properties on this brush are initialized /// Gets whether all properties on this brush are initialized
/// </summary> /// </summary>
@ -39,19 +35,13 @@ namespace Artemis.Core.Plugins.LayerBrush
internal set => _properties = value; 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) internal void InitializeProperties(ILayerService layerService)
{ {
Properties = Activator.CreateInstance<T>(); Properties = Activator.CreateInstance<T>();
Properties.InitializeProperties(layerService, Layer, "LayerBrush."); Properties.InitializeProperties(layerService, Layer, "LayerBrush.");
OnPropertiesInitialized();
PropertiesInitialized = true; PropertiesInitialized = true;
EnableLayerBrush();
} }
} }
} }

View File

@ -6,43 +6,26 @@ using RGB.NET.Core;
using RGB.NET.Groups; using RGB.NET.Groups;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core.Plugins.LayerBrush namespace Artemis.Core.Plugins.LayerBrush.Abstract
{ {
public abstract class RgbNetLayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup public abstract class RgbNetLayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup
{ {
protected RgbNetLayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor) protected RgbNetLayerBrush()
{ {
BrushType = LayerBrushType.RgbNet; BrushType = LayerBrushType.RgbNet;
LedGroup = new ListLedGroup();
Layer = layer;
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
} }
/// <summary> /// <summary>
/// The LED group this layer brush is applied to /// The LED group this layer effect is applied to
/// </summary> /// </summary>
public ListLedGroup LedGroup { get; internal set; } public ListLedGroup LedGroup { get; internal set; }
/// <summary> /// <summary>
/// Called when Artemis needs an instance of the RGB.NET brush you are implementing /// Called when Artemis needs an instance of the RGB.NET effect you are implementing
/// </summary> /// </summary>
/// <returns>Your RGB.NET brush</returns> /// <returns>Your RGB.NET effect</returns>
public abstract IBrush GetBrush(); 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() internal void UpdateLedGroup()
{ {
// TODO: This simply renders it on top of the rest, get a ZIndex based on layer position // TODO: This simply renders it on top of the rest, get a ZIndex based on layer position
@ -57,19 +40,28 @@ namespace Artemis.Core.Plugins.LayerBrush
internal override void Initialize(ILayerService layerService) internal override void Initialize(ILayerService layerService)
{ {
LedGroup = new ListLedGroup();
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
InitializeProperties(layerService); InitializeProperties(layerService);
UpdateLedGroup(); UpdateLedGroup();
} }
// Not used in this brush type internal override void Dispose(bool disposing)
internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
{ {
throw new NotImplementedException("RGB.NET layer brushes do not implement InternalRender"); if (disposing)
{
Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated;
LedGroup.Detach();
}
base.Dispose(disposing);
} }
internal override IBrush InternalGetBrush() // Not used in this effect type
internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
{ {
return GetBrush(); throw new NotImplementedException("RGB.NET layer effectes do not implement InternalRender");
} }
private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e) private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e)

View File

@ -1,4 +1,5 @@
using System; using System;
using Artemis.Core.Plugins.Abstract;
namespace Artemis.Core.Plugins.LayerBrush namespace Artemis.Core.Plugins.LayerBrush
{ {

View File

@ -1,28 +0,0 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
namespace Artemis.Core.Plugins.LayerBrush
{
/// <inheritdoc />
/// <summary>
/// Allows you to create one or more <see cref="LayerBrush" />s usable by profile layers.
/// </summary>
public abstract class LayerBrushProvider : Plugin
{
private readonly List<LayerBrushDescriptor> _layerBrushDescriptors;
protected LayerBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
{
_layerBrushDescriptors = new List<LayerBrushDescriptor>();
}
public ReadOnlyCollection<LayerBrushDescriptor> LayerBrushDescriptors => _layerBrushDescriptors.AsReadOnly();
protected void AddLayerBrushDescriptor<T>(string displayName, string description, string icon) where T : BaseLayerBrush
{
_layerBrushDescriptors.Add(new LayerBrushDescriptor(displayName, description, icon, typeof(T), this));
}
}
}

View File

@ -0,0 +1,94 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using SkiaSharp;
namespace Artemis.Core.Plugins.LayerEffect.Abstract
{
/// <summary>
/// For internal use only, please use <see cref="LayerEffect" /> instead
/// </summary>
public abstract class BaseLayerEffect : IDisposable
{
/// <summary>
/// Gets the layer this effect is applied to
/// </summary>
public Layer Layer { get; internal set; }
/// <summary>
/// Gets the folder this effect is applied to
/// </summary>
public Folder Folder { get; internal set; }
/// <summary>
/// Gets the descriptor of this effect
/// </summary>
public LayerEffectDescriptor Descriptor { get; internal set; }
/// <summary>
/// Gets the plugin info that defined this effect
/// </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;
public void Dispose()
{
DisableLayerEffect();
}
/// <summary>
/// Called when the layer brush is activated
/// </summary>
public abstract void EnableLayerEffect();
/// <summary>
/// Called when the layer brush is deactivated
/// </summary>
public abstract void DisableLayerEffect();
/// <summary>
/// Called before rendering every frame, write your update logic here
/// </summary>
/// <param name="deltaTime"></param>
public abstract void Update(double deltaTime);
/// <summary>
/// Called before the layer or folder will be rendered
/// </summary>
public abstract void PreProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
/// <summary>
/// Called after the layer of folder has been rendered
/// </summary>
public abstract void PostProcess(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
internal void InternalPreProcess(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 effect positioned at 0,0
path.Transform(SKMatrix.MakeTranslation(path.Bounds.Left * -1, path.Bounds.Top * -1));
PreProcess(canvas, canvasInfo, path, paint);
}
internal void InternalPostProcess(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 effect positioned at 0,0
path.Transform(SKMatrix.MakeTranslation(path.Bounds.Left * -1, path.Bounds.Top * -1));
PostProcess(canvas, canvasInfo, path, paint);
}
// Not only is this needed to initialize properties on the layer effects, it also prevents implementing anything
// but LayerEffect<T> outside the core
internal abstract void Initialize(ILayerService layerService);
}
}

View File

@ -0,0 +1,58 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Services.Interfaces;
namespace Artemis.Core.Plugins.LayerEffect.Abstract
{
/// <summary>
/// For internal use only, please use <see cref="LayerEffect" /> instead
/// </summary>
public abstract class LayerEffect<T> : BaseLayerEffect where T : LayerPropertyGroup
{
private T _properties;
/// <summary>
/// Gets whether all properties on this effect are initialized
/// </summary>
public bool PropertiesInitialized { get; internal set; }
/// <inheritdoc />
public override LayerPropertyGroup BaseProperties => Properties;
/// <summary>
/// Gets the properties of this effect.
/// </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 effect properties until OnPropertiesInitialized has been called");
return _properties;
}
internal set => _properties = value;
}
/// <summary>
/// Called when all layer properties in this effect 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;
}
internal override void Initialize(ILayerService layerService)
{
InitializeProperties(layerService);
}
}
}

View File

@ -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; }
}
}

View File

@ -32,7 +32,8 @@ namespace Artemis.Core.Plugins.Models
public string Description { get; set; } public string Description { get; set; }
/// <summary> /// <summary>
/// The plugins display icon that's shown in the settings see <see href="https://materialdesignicons.com" /> for available /// The plugins display icon that's shown in the settings see <see href="https://materialdesignicons.com" /> for
/// available
/// icons /// icons
/// </summary> /// </summary>
public string Icon { get; set; } public string Icon { get; set; }
@ -84,7 +85,7 @@ namespace Artemis.Core.Plugins.Models
/// </summary> /// </summary>
[JsonIgnore] [JsonIgnore]
internal PluginEntity PluginEntity { get; set; } internal PluginEntity PluginEntity { get; set; }
public override string ToString() public override string ToString()
{ {
return $"{nameof(Guid)}: {Guid}, {nameof(Name)}: {Name}, {nameof(Version)}: {Version}"; return $"{nameof(Guid)}: {Guid}, {nameof(Name)}: {Name}, {nameof(Version)}: {Version}";

View File

@ -1,5 +1,4 @@
using System; using System;
using Artemis.Storage.Entities;
using Artemis.Storage.Entities.Plugins; using Artemis.Storage.Entities.Plugins;
using Artemis.Storage.Repositories.Interfaces; using Artemis.Storage.Repositories.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -10,8 +9,8 @@ namespace Artemis.Core.Plugins.Models
{ {
// ReSharper disable once NotAccessedField.Local // ReSharper disable once NotAccessedField.Local
private readonly PluginInfo _pluginInfo; private readonly PluginInfo _pluginInfo;
private readonly PluginSettingEntity _pluginSettingEntity;
private readonly IPluginRepository _pluginRepository; private readonly IPluginRepository _pluginRepository;
private readonly PluginSettingEntity _pluginSettingEntity;
private T _value; private T _value;
internal PluginSetting(PluginInfo pluginInfo, IPluginRepository pluginRepository, PluginSettingEntity pluginSettingEntity) internal PluginSetting(PluginInfo pluginInfo, IPluginRepository pluginRepository, PluginSettingEntity pluginSettingEntity)

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Artemis.Storage.Entities;
using Artemis.Storage.Entities.Plugins; using Artemis.Storage.Entities.Plugins;
using Artemis.Storage.Repositories.Interfaces; using Artemis.Storage.Repositories.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;

View File

@ -1,5 +1,6 @@
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract;
namespace Artemis.Core.Services.Interfaces namespace Artemis.Core.Services.Interfaces
{ {
@ -22,11 +23,5 @@ namespace Artemis.Core.Services.Interfaces
/// <param name="layer">The layer to instantiate the brush for</param> /// <param name="layer">The layer to instantiate the brush for</param>
/// <returns></returns> /// <returns></returns>
BaseLayerBrush InstantiateLayerBrush(Layer layer); 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);
} }
} }

View File

@ -2,7 +2,9 @@
using System.Linq; using System.Linq;
using Artemis.Core.Exceptions; using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Ninject; using Ninject;
using Ninject.Parameters; using Ninject.Parameters;
@ -40,7 +42,7 @@ namespace Artemis.Core.Services
public BaseLayerBrush InstantiateLayerBrush(Layer layer) public BaseLayerBrush InstantiateLayerBrush(Layer layer)
{ {
RemoveLayerBrush(layer); layer.DeactivateLayerBrush();
var descriptorReference = layer.General.BrushReference?.CurrentValue; var descriptorReference = layer.General.BrushReference?.CurrentValue;
if (descriptorReference == null) if (descriptorReference == null)
@ -55,28 +57,16 @@ namespace Artemis.Core.Services
if (descriptor == null) if (descriptor == null)
return null; return null;
var arguments = new IParameter[] var brush = (BaseLayerBrush) _kernel.Get(descriptor.LayerBrushType);
{ brush.Layer = layer;
new ConstructorArgument("layer", layer), brush.Descriptor = descriptor;
new ConstructorArgument("descriptor", descriptor) layer.LayerBrush = brush;
};
layer.LayerBrush = (BaseLayerBrush) _kernel.Get(descriptor.LayerBrushType, arguments); brush.Initialize(this);
layer.LayerBrush.Initialize(this); brush.Update(0);
layer.LayerBrush.Update(0);
layer.OnLayerBrushUpdated(); layer.OnLayerBrushUpdated();
return layer.LayerBrush;
}
public void RemoveLayerBrush(Layer layer) return brush;
{
if (layer.LayerBrush == null)
return;
var brush = layer.LayerBrush;
layer.LayerBrush = null;
brush.Dispose();
layer.LayerEntity.PropertyEntities.RemoveAll(p => p.PluginGuid == brush.PluginInfo.Guid);
} }
} }
} }

View File

@ -267,10 +267,10 @@ namespace Artemis.Core.Services
{ {
var parameters = new IParameter[] var parameters = new IParameter[]
{ {
new ConstructorArgument("pluginInfo", pluginInfo),
new Parameter("PluginInfo", pluginInfo, false) new Parameter("PluginInfo", pluginInfo, false)
}; };
pluginInfo.Instance = (Plugin) _childKernel.Get(pluginType, constraint: null, parameters: parameters); pluginInfo.Instance = (Plugin) _childKernel.Get(pluginType, constraint: null, parameters: parameters);
pluginInfo.Instance.PluginInfo = pluginInfo;
} }
catch (Exception e) catch (Exception e)
{ {
@ -353,7 +353,7 @@ namespace Artemis.Core.Services
} }
plugin.SetEnabled(false); plugin.SetEnabled(false);
OnPluginDisabled(new PluginEventArgs(plugin.PluginInfo)); OnPluginDisabled(new PluginEventArgs(plugin.PluginInfo));
} }

View File

@ -21,12 +21,12 @@
<Rectangle x:Name="BorderVisual" <Rectangle x:Name="BorderVisual"
StrokeDashArray="2 2" Stroke="{DynamicResource SecondaryAccentBrush}" StrokeThickness="1" StrokeDashArray="2 2" Stroke="{DynamicResource SecondaryAccentBrush}" StrokeThickness="1"
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}"> Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" />
</Rectangle>
</VisualBrush.Visual> </VisualBrush.Visual>
</VisualBrush> </VisualBrush>
</Border.BorderBrush> </Border.BorderBrush>
<TextBlock Width="60" <TextBlock Style="{x:Null}"
Width="60"
Height="17" Height="17"
Padding="1 0" Padding="1 0"
Margin="0 4 0 0" Margin="0 4 0 0"

View File

@ -3,6 +3,7 @@ using System.Linq;
using Artemis.Core.Events; using Artemis.Core.Events;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Shared.PropertyInput; using Artemis.UI.Shared.PropertyInput;

View File

@ -2,20 +2,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using Artemis.Core.Events; using Artemis.Core.Events;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Models.Profile.LayerProperties.Attributes; using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Events;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Events; using Artemis.UI.Shared.Events;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Stylet; using Stylet;

View File

@ -7,6 +7,7 @@ using Artemis.Core.Events;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;

View File

@ -306,6 +306,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
var device = Devices.LastOrDefault(d => PanZoomViewModel.TransformContainingRect(d.DeviceRectangle).Contains(position)); var device = Devices.LastOrDefault(d => PanZoomViewModel.TransformContainingRect(d.DeviceRectangle).Contains(position));
if (device != null) if (device != null)
{ {
_rgbService.UpdateTrigger.Stop();
_mouseDragStatus = MouseDragStatus.Dragging; _mouseDragStatus = MouseDragStatus.Dragging;
// If the device is not selected, deselect others and select only this one (if shift not held) // If the device is not selected, deselect others and select only this one (if shift not held)
if (device.SelectionStatus != SelectionStatus.Selected) if (device.SelectionStatus != SelectionStatus.Selected)
@ -350,6 +351,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true); _surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
_mouseDragStatus = MouseDragStatus.None; _mouseDragStatus = MouseDragStatus.None;
_rgbService.UpdateTrigger.Start();
} }
private void UpdateSelection(Point position) private void UpdateSelection(Point position)
@ -415,18 +417,6 @@ namespace Artemis.UI.Screens.SurfaceEditor
} }
#endregion #endregion
protected override void OnActivate()
{
_rgbService.UpdateTrigger.Stop();
base.OnActivate();
}
protected override void OnDeactivate()
{
_rgbService.UpdateTrigger.Start();
base.OnDeactivate();
}
} }
internal enum MouseDragStatus internal enum MouseDragStatus

View File

@ -1,5 +1,4 @@
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.Asus; using RGB.NET.Devices.Asus;
@ -11,12 +10,12 @@ namespace Artemis.Plugins.Devices.Asus
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public AsusDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Asus.AsusDeviceProvider.Instance) public AsusDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.Asus.AsusDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(AsusRGBDevice<>), sender, args); PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(AsusRGBDevice<>), sender, args);
_rgbService.AddDeviceProvider(RgbDeviceProvider); _rgbService.AddDeviceProvider(RgbDeviceProvider);

View File

@ -1,7 +1,8 @@
{ {
"Guid": "c20e876f-7cb0-4fa1-b0cc-ae1afb5865d1", "Guid": "c20e876f-7cb0-4fa1-b0cc-ae1afb5865d1",
"Name": "Asus Devices", "Name": "Asus Devices",
"Description": "Allows Artemis to control lighting on different ASUS devices such as motherboards, GPUs, headsets, RAM, keyboards and PC cases.", "Description":
"Allows Artemis to control lighting on different ASUS devices such as motherboards, GPUs, headsets, RAM, keyboards and PC cases.",
"Version": "1.0.0.0", "Version": "1.0.0.0",
"Main": "Artemis.Plugins.Devices.Asus.dll" "Main": "Artemis.Plugins.Devices.Asus.dll"
} }

View File

@ -1,6 +1,5 @@
using System.IO; using System.IO;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.CoolerMaster; using RGB.NET.Devices.CoolerMaster;
@ -12,12 +11,12 @@ namespace Artemis.Plugins.Devices.CoolerMaster
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public CoolerMasterDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance) public CoolerMasterDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CoolerMasterRGBDevice<>), sender, args); PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CoolerMasterRGBDevice<>), sender, args);
RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CMSDK.dll")); RGB.NET.Devices.CoolerMaster.CoolerMasterDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CMSDK.dll"));

View File

@ -1,6 +1,5 @@
using System.IO; using System.IO;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.Corsair; using RGB.NET.Devices.Corsair;
@ -12,12 +11,12 @@ namespace Artemis.Plugins.Devices.Corsair
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public CorsairDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance) public CorsairDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CorsairRGBDevice<>), sender, args); 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")); RGB.NET.Devices.Corsair.CorsairDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CUESDK.x64_2017.dll"));

View File

@ -1,6 +1,5 @@
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.ViewModels; using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Devices.DMX.ViewModels; using Artemis.Plugins.Devices.DMX.ViewModels;
@ -11,13 +10,13 @@ namespace Artemis.Plugins.Devices.DMX
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public DMXDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.DMX.DMXDeviceProvider.Instance) public DMXDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
HasConfigurationViewModel = true; HasConfigurationViewModel = true;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
// TODO: Load from configuration // TODO: Load from configuration
// RGB.NET.Devices.DMX.DMXDeviceProvider.Instance.AddDeviceDefinition(); // RGB.NET.Devices.DMX.DMXDeviceProvider.Instance.AddDeviceDefinition();

View File

@ -3,7 +3,6 @@ using System.IO;
using System.Linq; using System.Linq;
using Artemis.Core.Extensions; using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using HidSharp; using HidSharp;
using RGB.NET.Core; using RGB.NET.Core;
@ -19,13 +18,13 @@ namespace Artemis.Plugins.Devices.Logitech
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public LogitechDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService, ILogger logger) : base(pluginInfo, RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance) public LogitechDeviceProvider(IRgbService rgbService, ILogger logger) : base(RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
_logger = logger; _logger = logger;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(LogitechRGBDevice<>), sender, args); PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(LogitechRGBDevice<>), sender, args);
RGB.NET.Devices.Logitech.LogitechDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "LogitechLedEnginesWrapper.dll")); RGB.NET.Devices.Logitech.LogitechDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "LogitechLedEnginesWrapper.dll"));

View File

@ -1,6 +1,5 @@
using System.IO; using System.IO;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.Msi; using RGB.NET.Devices.Msi;
@ -12,12 +11,12 @@ namespace Artemis.Plugins.Devices.Msi
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public MsiDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Msi.MsiDeviceProvider.Instance) public MsiDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.Msi.MsiDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(MsiRGBDevice<>), sender, args); 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")); RGB.NET.Devices.Msi.MsiDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "MysticLight_SDK.dll"));

View File

@ -1,5 +1,4 @@
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.Novation; using RGB.NET.Devices.Novation;
@ -11,12 +10,12 @@ namespace Artemis.Plugins.Devices.Novation
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public NovationDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Novation.NovationDeviceProvider.Instance) public NovationDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.Novation.NovationDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(NovationRGBDevice<>), sender, args); PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(NovationRGBDevice<>), sender, args);
_rgbService.AddDeviceProvider(RgbDeviceProvider); _rgbService.AddDeviceProvider(RgbDeviceProvider);

View File

@ -1,7 +1,6 @@
using System.IO; using System.IO;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Exceptions; using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.Razer; using RGB.NET.Devices.Razer;
@ -13,12 +12,12 @@ namespace Artemis.Plugins.Devices.Razer
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public RazerDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Razer.RazerDeviceProvider.Instance) public RazerDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.Razer.RazerDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(RazerRGBDevice<>), sender, args); PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(RazerRGBDevice<>), sender, args);
RGB.NET.Devices.Razer.RazerDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "RzChromaSDK.dll")); RGB.NET.Devices.Razer.RazerDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "RzChromaSDK.dll"));

View File

@ -1,6 +1,5 @@
using System.IO; using System.IO;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
namespace Artemis.Plugins.Devices.Roccat namespace Artemis.Plugins.Devices.Roccat
@ -10,12 +9,12 @@ namespace Artemis.Plugins.Devices.Roccat
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public RoccatDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Roccat.RoccatDeviceProvider.Instance) public RoccatDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.Roccat.RoccatDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
// TODO: Find out why this is missing, Roccat seems unimplemented // TODO: Find out why this is missing, Roccat seems unimplemented
// PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(RoccatRGBDevice<>), sender, args); // PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(RoccatRGBDevice<>), sender, args);

View File

@ -1,5 +1,4 @@
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.SteelSeries; using RGB.NET.Devices.SteelSeries;
@ -11,12 +10,12 @@ namespace Artemis.Plugins.Devices.SteelSeries
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public SteelSeriesDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance) public SteelSeriesDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.SteelSeries.SteelSeriesDeviceProvider.Instance)
{ {
_rgbService = rgbService; _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 // TODO Check to see if this works, it's usually a generic type after all
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(SteelSeriesRGBDevice), sender, args); PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(SteelSeriesRGBDevice), sender, args);

View File

@ -15,19 +15,20 @@ namespace Artemis.Plugins.Devices.WS281X
public class WS281XDeviceProvider : DeviceProvider public class WS281XDeviceProvider : DeviceProvider
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
private readonly PluginSettings _settings;
public WS281XDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService, PluginSettings settings) : base(pluginInfo, RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance) public WS281XDeviceProvider(IRgbService rgbService, PluginSettings settings) : base(RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance)
{ {
Settings = settings; _settings = settings;
_rgbService = rgbService; _rgbService = rgbService;
HasConfigurationViewModel = true;
} }
public PluginSettings Settings { get; }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
var definitions = Settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions"); HasConfigurationViewModel = true;
var definitions = _settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
if (definitions.Value == null) if (definitions.Value == null)
definitions.Value = new List<DeviceDefinition>(); definitions.Value = new List<DeviceDefinition>();
@ -49,14 +50,14 @@ namespace Artemis.Plugins.Devices.WS281X
_rgbService.AddDeviceProvider(RgbDeviceProvider); _rgbService.AddDeviceProvider(RgbDeviceProvider);
} }
protected override void DisablePlugin() public override void DisablePlugin()
{ {
// TODO: Remove the device provider from the surface // TODO: Remove the device provider from the surface
} }
public override PluginConfigurationViewModel GetConfigurationViewModel() public override PluginConfigurationViewModel GetConfigurationViewModel()
{ {
return new WS281XConfigurationViewModel(this, Settings); return new WS281XConfigurationViewModel(this, _settings);
} }
} }
} }

View File

@ -1,6 +1,5 @@
using System.IO; using System.IO;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.Wooting.Generic; using RGB.NET.Devices.Wooting.Generic;
@ -12,12 +11,12 @@ namespace Artemis.Plugins.Devices.Wooting
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public WootingDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Wooting.WootingDeviceProvider.Instance) public WootingDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.Wooting.WootingDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
protected override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(WootingRGBDevice<>), sender, args); 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")); RGB.NET.Devices.Wooting.WootingDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "wooting-rgb-sdk64.dll"));
@ -25,7 +24,7 @@ namespace Artemis.Plugins.Devices.Wooting
_rgbService.AddDeviceProvider(RgbDeviceProvider); _rgbService.AddDeviceProvider(RgbDeviceProvider);
} }
protected override void DisablePlugin() public override void DisablePlugin()
{ {
// TODO: Remove the device provider from the surface // TODO: Remove the device provider from the surface
} }

View File

@ -1,7 +1,8 @@
{ {
"Guid": "e70fd5ba-9881-480a-8ff6-078ed5f747fa", "Guid": "e70fd5ba-9881-480a-8ff6-078ed5f747fa",
"Name": "Wooting Devices", "Name": "Wooting Devices",
"Description": "Allows Artemis to control lighting on Wooting keyboards. Will eventually also expose analog key data.", "Description":
"Allows Artemis to control lighting on Wooting keyboards. Will eventually also expose analog key data.",
"Version": "1.0.0.0", "Version": "1.0.0.0",
"Main": "Artemis.Plugins.Devices.Wooting.dll" "Main": "Artemis.Plugins.Devices.Wooting.dll"
} }

View File

@ -37,6 +37,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'"> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<Exec Command="echo Copying resources to plugin output directory&#xD;&#xA;XCOPY &quot;$(ProjectDir)Images&quot; &quot;$(TargetDir)Images&quot; /s /q /i /y&#xD;&#xA;XCOPY &quot;$(ProjectDir)Layouts&quot; &quot;$(TargetDir)Layouts&quot; /s /q /i /y&#xD;&#xA;echo Copying plugin to Artemis.UI output directory&#xD;&#xA;XCOPY &quot;$(TargetDir.TrimEnd('\'))&quot; &quot;$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)&quot; /s /q /i /y" /> <Exec
Command="echo Copying resources to plugin output directory&#xD;&#xA;XCOPY &quot;$(ProjectDir)Images&quot; &quot;$(TargetDir)Images&quot; /s /q /i /y&#xD;&#xA;XCOPY &quot;$(ProjectDir)Layouts&quot; &quot;$(TargetDir)Layouts&quot; /s /q /i /y&#xD;&#xA;echo Copying plugin to Artemis.UI output directory&#xD;&#xA;XCOPY &quot;$(TargetDir.TrimEnd('\'))&quot; &quot;$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)&quot; /s /q /i /y" />
</Target> </Target>
</Project> </Project>

View File

@ -1,6 +1,5 @@
using System; using System;
using Artemis.Core.Models.Profile; using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Plugins.LayerBrush;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Plugins.LayerBrushes.Color namespace Artemis.Plugins.LayerBrushes.Color
@ -12,9 +11,20 @@ namespace Artemis.Plugins.LayerBrushes.Color
private SKShader _shader; private SKShader _shader;
private SKRect _shaderBounds; private SKRect _shaderBounds;
public ColorBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor) public override void EnableLayerBrush()
{ {
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader(); Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
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) public override void Update(double deltaTime)
@ -40,24 +50,6 @@ namespace Artemis.Plugins.LayerBrushes.Color
canvas.DrawPath(path, paint); 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() private void CreateShader()
{ {
var center = new SKPoint(_shaderBounds.MidX, _shaderBounds.MidY); var center = new SKPoint(_shaderBounds.MidX, _shaderBounds.MidY);
@ -69,13 +61,13 @@ namespace Artemis.Plugins.LayerBrushes.Color
new SKPoint(_shaderBounds.Right, _shaderBounds.Top), new SKPoint(_shaderBounds.Right, _shaderBounds.Top),
Properties.Gradient.BaseValue.GetColorsArray(), Properties.Gradient.BaseValue.GetColorsArray(),
Properties.Gradient.BaseValue.GetPositionsArray(), Properties.Gradient.BaseValue.GetPositionsArray(),
SKShaderTileMode.Repeat), SKShaderTileMode.Clamp),
GradientType.RadialGradient => SKShader.CreateRadialGradient( GradientType.RadialGradient => SKShader.CreateRadialGradient(
center, center,
Math.Min(_shaderBounds.Width, _shaderBounds.Height), Math.Max(_shaderBounds.Width, _shaderBounds.Height) / 2f,
Properties.Gradient.BaseValue.GetColorsArray(), Properties.Gradient.BaseValue.GetColorsArray(),
Properties.Gradient.BaseValue.GetPositionsArray(), Properties.Gradient.BaseValue.GetPositionsArray(),
SKShaderTileMode.Repeat), SKShaderTileMode.Clamp),
GradientType.SweepGradient => SKShader.CreateSweepGradient( GradientType.SweepGradient => SKShader.CreateSweepGradient(
center, center,
Properties.Gradient.BaseValue.GetColorsArray(), Properties.Gradient.BaseValue.GetColorsArray(),

View File

@ -1,5 +1,4 @@
using System; using System.ComponentModel;
using System.ComponentModel;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors; using Artemis.Core.Models.Profile.Colors;
using Artemis.Core.Models.Profile.LayerProperties.Attributes; using Artemis.Core.Models.Profile.LayerProperties.Attributes;

View File

@ -1,20 +1,15 @@
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
namespace Artemis.Plugins.LayerBrushes.Color namespace Artemis.Plugins.LayerBrushes.Color
{ {
public class ColorBrushProvider : LayerBrushProvider public class ColorBrushProvider : LayerBrushProvider
{ {
public ColorBrushProvider(PluginInfo pluginInfo) : base(pluginInfo) public override void EnablePlugin()
{ {
AddLayerBrushDescriptor<ColorBrush>("Color", "A color with an (optional) gradient", "Brush"); AddLayerBrushDescriptor<ColorBrush>("Color", "A color with an (optional) gradient", "Brush");
} }
protected override void EnablePlugin() public override void DisablePlugin()
{
}
protected override void DisablePlugin()
{ {
} }
} }

View File

@ -1,7 +1,5 @@
using System; using Artemis.Core.Extensions;
using Artemis.Core.Extensions; using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.LayerBrush;
using RGB.NET.Brushes; using RGB.NET.Brushes;
using RGB.NET.Core; using RGB.NET.Core;
@ -9,13 +7,18 @@ namespace Artemis.Plugins.LayerBrushes.ColorRgbNet
{ {
public class RgbNetColorBrush : RgbNetLayerBrush<RgbNetColorBrushProperties> public class RgbNetColorBrush : RgbNetLayerBrush<RgbNetColorBrushProperties>
{ {
private readonly SolidColorBrush _solidBrush; private SolidColorBrush _solidBrush;
public RgbNetColorBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor) public override void EnableLayerBrush()
{ {
_solidBrush = new SolidColorBrush(Color.Transparent); _solidBrush = new SolidColorBrush(Color.Transparent);
} }
public override void DisableLayerBrush()
{
_solidBrush = null;
}
public override void Update(double deltaTime) public override void Update(double deltaTime)
{ {
_solidBrush.Color = Properties.Color.CurrentValue.ToRgbColor(); _solidBrush.Color = Properties.Color.CurrentValue.ToRgbColor();

View File

@ -1,5 +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.Plugins.LayerBrushes.ColorRgbNet.PropertyInput;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
@ -9,18 +8,18 @@ namespace Artemis.Plugins.LayerBrushes.ColorRgbNet
{ {
private readonly IProfileEditorService _profileEditorService; private readonly IProfileEditorService _profileEditorService;
public RgbNetColorBrushProvider(PluginInfo pluginInfo, IProfileEditorService profileEditorService) : base(pluginInfo) public RgbNetColorBrushProvider(IProfileEditorService profileEditorService)
{ {
_profileEditorService = profileEditorService; _profileEditorService = profileEditorService;
}
public override void EnablePlugin()
{
_profileEditorService.RegisterPropertyInput(PluginInfo, typeof(StringPropertyInputViewModel));
AddLayerBrushDescriptor<RgbNetColorBrush>("RGB.NET Color", "A RGB.NET based color", "Brush"); AddLayerBrushDescriptor<RgbNetColorBrush>("RGB.NET Color", "A RGB.NET based color", "Brush");
} }
protected override void EnablePlugin() public override void DisablePlugin()
{
_profileEditorService.RegisterPropertyInput(PluginInfo, typeof(StringPropertyInputViewModel));
}
protected override void DisablePlugin()
{ {
} }
} }

View File

@ -1,7 +1,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using Artemis.Core.Models.Profile; using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.LayerBrushes.Noise.Utilities; using Artemis.Plugins.LayerBrushes.Noise.Utilities;
using SkiaSharp; using SkiaSharp;
@ -11,27 +10,38 @@ namespace Artemis.Plugins.LayerBrushes.Noise
public class NoiseBrush : LayerBrush<NoiseBrushProperties> public class NoiseBrush : LayerBrush<NoiseBrushProperties>
{ {
private static readonly Random Rand = new Random(); private static readonly Random Rand = new Random();
private readonly OpenSimplexNoise _noise;
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
private SKBitmap _bitmap; private SKBitmap _bitmap;
private SKColor[] _colorMap; private SKColor[] _colorMap;
private OpenSimplexNoise _noise;
private float _renderScale; private float _renderScale;
private float _x; private float _x;
private float _y; private float _y;
private float _z; private float _z;
public NoiseBrush(Layer layer, LayerBrushDescriptor descriptor, IRgbService rgbService) : base(layer, descriptor) public NoiseBrush(IRgbService rgbService)
{ {
_rgbService = rgbService; _rgbService = rgbService;
}
public override void EnableLayerBrush()
{
_x = Rand.Next(0, 4096); _x = Rand.Next(0, 4096);
_y = Rand.Next(0, 4096); _y = Rand.Next(0, 4096);
_z = Rand.Next(0, 4096); _z = Rand.Next(0, 4096);
_noise = new OpenSimplexNoise(Rand.Next(0, 4096)); _noise = new OpenSimplexNoise(Rand.Next(0, 4096));
Properties.GradientColor.BaseValue.PropertyChanged += GradientColorChanged;
CreateColorMap();
DetermineRenderScale(); DetermineRenderScale();
} }
public override void DisableLayerBrush()
{
_bitmap?.Dispose();
_bitmap = null;
}
public override void Update(double deltaTime) public override void Update(double deltaTime)
{ {
_x += Properties.ScrollSpeed.CurrentValue.X / 500f / (float) deltaTime; _x += Properties.ScrollSpeed.CurrentValue.X / 500f / (float) deltaTime;
@ -104,22 +114,6 @@ namespace Artemis.Plugins.LayerBrushes.Noise
canvas.DrawRect(path.Bounds, paint); 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) private void GradientColorChanged(object sender, PropertyChangedEventArgs e)
{ {
CreateColorMap(); CreateColorMap();

View File

@ -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.Colors;
using Artemis.Core.Models.Profile.LayerProperties.Attributes; using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Models.Profile.LayerProperties.Types; using Artemis.Core.Models.Profile.LayerProperties.Types;

View File

@ -1,20 +1,15 @@
using Artemis.Core.Plugins.LayerBrush; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
namespace Artemis.Plugins.LayerBrushes.Noise namespace Artemis.Plugins.LayerBrushes.Noise
{ {
public class NoiseBrushProvider : LayerBrushProvider public class NoiseBrushProvider : LayerBrushProvider
{ {
public NoiseBrushProvider(PluginInfo pluginInfo) : base(pluginInfo) public override void EnablePlugin()
{ {
AddLayerBrushDescriptor<NoiseBrush>("Noise", "A brush of that shows an animated random noise", "ScatterPlot"); AddLayerBrushDescriptor<NoiseBrush>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
} }
protected override void EnablePlugin() public override void DisablePlugin()
{
}
protected override void DisablePlugin()
{ {
} }
} }

View File

@ -11,9 +11,18 @@ namespace Artemis.Plugins.Modules.General
{ {
private readonly PluginSettings _settings; private readonly PluginSettings _settings;
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo) public GeneralModule(PluginSettings settings)
{ {
_settings = settings; _settings = settings;
}
public override IEnumerable<ModuleViewModel> GetViewModels()
{
return new List<ModuleViewModel> {new GeneralViewModel(this)};
}
public override void EnablePlugin()
{
DisplayName = "General"; DisplayName = "General";
DisplayIcon = "AllInclusive"; DisplayIcon = "AllInclusive";
ExpandsMainDataModel = true; ExpandsMainDataModel = true;
@ -22,16 +31,7 @@ namespace Artemis.Plugins.Modules.General
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now); var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
} }
public override IEnumerable<ModuleViewModel> GetViewModels() public override void DisablePlugin()
{
return new List<ModuleViewModel> {new GeneralViewModel(this)};
}
protected override void EnablePlugin()
{
}
protected override void DisablePlugin()
{ {
} }
} }