mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Plugins - Removed plugin info from constructor
This commit is contained in:
parent
ee37c3b836
commit
4bc6f2f16b
@ -8,6 +8,7 @@ using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Models.Profile.LayerShapes;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
@ -412,7 +413,7 @@ namespace Artemis.Core.Models.Profile
|
||||
{
|
||||
DeactivateLayerBrush();
|
||||
}
|
||||
|
||||
|
||||
internal void DeactivateLayerBrush()
|
||||
{
|
||||
if (LayerBrush == null)
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
@ -8,10 +6,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public abstract class DataModelExpansion : Plugin
|
||||
{
|
||||
protected DataModelExpansion(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void Update(double deltaTime);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract.DataModels.Attributes
|
||||
{
|
||||
[AttributeUsage(System.AttributeTargets.Property)]
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class DataModelPropertyAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Ninject;
|
||||
using RGB.NET.Core;
|
||||
using Serilog;
|
||||
@ -14,7 +13,7 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public abstract class DeviceProvider : Plugin
|
||||
{
|
||||
protected DeviceProvider(PluginInfo pluginInfo, IRGBDeviceProvider rgbDeviceProvider) : base(pluginInfo)
|
||||
protected DeviceProvider(IRGBDeviceProvider rgbDeviceProvider)
|
||||
{
|
||||
RgbDeviceProvider = rgbDeviceProvider ?? throw new ArgumentNullException(nameof(rgbDeviceProvider));
|
||||
}
|
||||
@ -24,6 +23,11 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
[Inject]
|
||||
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)
|
||||
{
|
||||
if (sender.GetType().IsGenericType(type))
|
||||
@ -42,10 +46,5 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
// Does not happen with device providers, they require Artemis to restart
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
@ -13,15 +14,32 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
private readonly List<LayerBrushDescriptor> _layerBrushDescriptors;
|
||||
|
||||
protected LayerBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
@ -11,10 +8,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public class LayerEffectProvider : Plugin
|
||||
{
|
||||
public LayerEffectProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@ -25,4 +18,4 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
@ -13,10 +12,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public abstract class Module : Plugin
|
||||
{
|
||||
protected Module(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The modules display name that's shown in the menu
|
||||
/// </summary>
|
||||
|
||||
@ -10,11 +10,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public abstract class Plugin : IDisposable
|
||||
{
|
||||
internal Plugin(PluginInfo pluginInfo)
|
||||
{
|
||||
PluginInfo = pluginInfo ?? throw new ArgumentNullException(nameof(pluginInfo));
|
||||
}
|
||||
|
||||
public PluginInfo PluginInfo { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
@ -28,11 +23,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public bool HasConfigurationViewModel { get; protected set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DisablePlugin();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the plugin is activated
|
||||
/// </summary>
|
||||
@ -52,21 +42,26 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
internal void SetEnabled(bool enable)
|
||||
{
|
||||
if (enable && !Enabled)
|
||||
{
|
||||
Enabled = true;
|
||||
EnablePlugin();
|
||||
OnPluginEnabled();
|
||||
}
|
||||
else if (!enable && Enabled)
|
||||
{
|
||||
Enabled = false;
|
||||
DisablePlugin();
|
||||
OnPluginDisabled();
|
||||
}
|
||||
}
|
||||
|
||||
Enabled = enable;
|
||||
public void Dispose()
|
||||
{
|
||||
DisablePlugin();
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
@ -2,17 +2,12 @@
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
public abstract class ProfileModule : Module
|
||||
{
|
||||
protected ProfileModule(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
}
|
||||
|
||||
public Profile ActiveProfile { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -1,25 +1,16 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Groups;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// For internal use only, please use <see cref="LayerBrush{T}" /> or <see cref="RgbNetLayerBrush{T}" /> or instead
|
||||
/// </summary>
|
||||
public abstract class BaseLayerBrush : IDisposable
|
||||
{
|
||||
protected BaseLayerBrush(Layer layer, LayerBrushDescriptor descriptor)
|
||||
{
|
||||
Layer = layer;
|
||||
Descriptor = descriptor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the layer this brush is applied to
|
||||
/// </summary>
|
||||
@ -45,6 +36,14 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
/// </summary>
|
||||
public virtual LayerPropertyGroup BaseProperties => null;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
DisableLayerBrush();
|
||||
Dispose(true);
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the layer brush is activated
|
||||
/// </summary>
|
||||
@ -67,15 +66,8 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
|
||||
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();
|
||||
|
||||
public void Dispose()
|
||||
internal virtual void Dispose(bool disposing)
|
||||
{
|
||||
DisableLayerBrush();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
{
|
||||
public abstract class LayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup
|
||||
{
|
||||
protected LayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor)
|
||||
protected LayerBrush()
|
||||
{
|
||||
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="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
|
||||
@ -34,11 +32,6 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
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)
|
||||
{
|
||||
InitializeProperties(layerService);
|
||||
@ -3,7 +3,7 @@ using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// 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;
|
||||
|
||||
protected PropertiesLayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether all properties on this brush are initialized
|
||||
/// </summary>
|
||||
@ -43,8 +39,9 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
Properties = Activator.CreateInstance<T>();
|
||||
Properties.InitializeProperties(layerService, Layer, "LayerBrush.");
|
||||
EnableLayerBrush();
|
||||
PropertiesInitialized = true;
|
||||
|
||||
EnableLayerBrush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,43 +6,26 @@ using RGB.NET.Core;
|
||||
using RGB.NET.Groups;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
{
|
||||
public abstract class RgbNetLayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup
|
||||
{
|
||||
protected RgbNetLayerBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor)
|
||||
protected RgbNetLayerBrush()
|
||||
{
|
||||
BrushType = LayerBrushType.RgbNet;
|
||||
LedGroup = new ListLedGroup();
|
||||
|
||||
Layer = layer;
|
||||
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The LED group this layer brush is applied to
|
||||
/// The LED group this layer effect is applied to
|
||||
/// </summary>
|
||||
public ListLedGroup LedGroup { get; internal set; }
|
||||
|
||||
/// <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>
|
||||
/// <returns>Your RGB.NET brush</returns>
|
||||
/// <returns>Your RGB.NET effect</returns>
|
||||
public abstract IBrush GetBrush();
|
||||
|
||||
public sealed override void Dispose()
|
||||
{
|
||||
Layer.RenderPropertiesUpdated -= LayerOnRenderPropertiesUpdated;
|
||||
LedGroup.Detach();
|
||||
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
}
|
||||
|
||||
internal void UpdateLedGroup()
|
||||
{
|
||||
// TODO: This simply renders it on top of the rest, get a ZIndex based on layer position
|
||||
@ -57,19 +40,28 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
|
||||
internal override void Initialize(ILayerService layerService)
|
||||
{
|
||||
LedGroup = new ListLedGroup();
|
||||
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
|
||||
|
||||
InitializeProperties(layerService);
|
||||
UpdateLedGroup();
|
||||
}
|
||||
|
||||
// Not used in this brush type
|
||||
internal override void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint)
|
||||
internal override void Dispose(bool disposing)
|
||||
{
|
||||
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)
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
58
src/Artemis.Core/Plugins/LayerEffect/Abstract/LayerEffect.cs
Normal file
58
src/Artemis.Core/Plugins/LayerEffect/Abstract/LayerEffect.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,64 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -1,95 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,8 @@ namespace Artemis.Core.Plugins.Models
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <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
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
@ -84,7 +85,7 @@ namespace Artemis.Core.Plugins.Models
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
internal PluginEntity PluginEntity { get; set; }
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(Guid)}: {Guid}, {nameof(Name)}: {Name}, {nameof(Version)}: {Version}";
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
@ -10,8 +9,8 @@ namespace Artemis.Core.Plugins.Models
|
||||
{
|
||||
// ReSharper disable once NotAccessedField.Local
|
||||
private readonly PluginInfo _pluginInfo;
|
||||
private readonly PluginSettingEntity _pluginSettingEntity;
|
||||
private readonly IPluginRepository _pluginRepository;
|
||||
private readonly PluginSettingEntity _pluginSettingEntity;
|
||||
private T _value;
|
||||
|
||||
internal PluginSetting(PluginInfo pluginInfo, IPluginRepository pluginRepository, PluginSettingEntity pluginSettingEntity)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
|
||||
namespace Artemis.Core.Services.Interfaces
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@ using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
@ -42,7 +43,7 @@ namespace Artemis.Core.Services
|
||||
public BaseLayerBrush InstantiateLayerBrush(Layer layer)
|
||||
{
|
||||
layer.DeactivateLayerBrush();
|
||||
|
||||
|
||||
var descriptorReference = layer.General.BrushReference?.CurrentValue;
|
||||
if (descriptorReference == null)
|
||||
return null;
|
||||
@ -56,16 +57,16 @@ namespace Artemis.Core.Services
|
||||
if (descriptor == null)
|
||||
return null;
|
||||
|
||||
var arguments = new IParameter[]
|
||||
{
|
||||
new ConstructorArgument("layer", layer),
|
||||
new ConstructorArgument("descriptor", descriptor)
|
||||
};
|
||||
layer.LayerBrush = (BaseLayerBrush) _kernel.Get(descriptor.LayerBrushType, arguments);
|
||||
layer.LayerBrush.Initialize(this);
|
||||
layer.LayerBrush.Update(0);
|
||||
var brush = (BaseLayerBrush) _kernel.Get(descriptor.LayerBrushType);
|
||||
brush.Layer = layer;
|
||||
brush.Descriptor = descriptor;
|
||||
layer.LayerBrush = brush;
|
||||
|
||||
brush.Initialize(this);
|
||||
brush.Update(0);
|
||||
layer.OnLayerBrushUpdated();
|
||||
return layer.LayerBrush;
|
||||
|
||||
return brush;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -267,10 +267,10 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
var parameters = new IParameter[]
|
||||
{
|
||||
new ConstructorArgument("pluginInfo", pluginInfo),
|
||||
new Parameter("PluginInfo", pluginInfo, false)
|
||||
};
|
||||
pluginInfo.Instance = (Plugin) _childKernel.Get(pluginType, constraint: null, parameters: parameters);
|
||||
pluginInfo.Instance.PluginInfo = pluginInfo;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -353,7 +353,7 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
|
||||
plugin.SetEnabled(false);
|
||||
|
||||
|
||||
OnPluginDisabled(new PluginEventArgs(plugin.PluginInfo));
|
||||
}
|
||||
|
||||
|
||||
@ -21,12 +21,12 @@
|
||||
<Rectangle x:Name="BorderVisual"
|
||||
StrokeDashArray="2 2" Stroke="{DynamicResource SecondaryAccentBrush}" StrokeThickness="1"
|
||||
Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}">
|
||||
</Rectangle>
|
||||
Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" />
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Border.BorderBrush>
|
||||
<TextBlock Width="60"
|
||||
<TextBlock Style="{x:Null}"
|
||||
Width="60"
|
||||
Height="17"
|
||||
Padding="1 0"
|
||||
Margin="0 4 0 0"
|
||||
|
||||
@ -2,20 +2,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Events;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Stylet;
|
||||
|
||||
@ -7,6 +7,7 @@ using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
|
||||
@ -306,6 +306,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
var device = Devices.LastOrDefault(d => PanZoomViewModel.TransformContainingRect(d.DeviceRectangle).Contains(position));
|
||||
if (device != null)
|
||||
{
|
||||
_rgbService.UpdateTrigger.Stop();
|
||||
_mouseDragStatus = MouseDragStatus.Dragging;
|
||||
// If the device is not selected, deselect others and select only this one (if shift not held)
|
||||
if (device.SelectionStatus != SelectionStatus.Selected)
|
||||
@ -350,6 +351,7 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
|
||||
|
||||
_mouseDragStatus = MouseDragStatus.None;
|
||||
_rgbService.UpdateTrigger.Start();
|
||||
}
|
||||
|
||||
private void UpdateSelection(Point position)
|
||||
@ -415,18 +417,6 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
_rgbService.UpdateTrigger.Stop();
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
_rgbService.UpdateTrigger.Start();
|
||||
base.OnDeactivate();
|
||||
}
|
||||
}
|
||||
|
||||
internal enum MouseDragStatus
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Asus;
|
||||
@ -11,7 +10,7 @@ namespace Artemis.Plugins.Devices.Asus
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
{
|
||||
"Guid": "c20e876f-7cb0-4fa1-b0cc-ae1afb5865d1",
|
||||
"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",
|
||||
"Main": "Artemis.Plugins.Devices.Asus.dll"
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
using System.IO;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.CoolerMaster;
|
||||
@ -12,7 +11,7 @@ namespace Artemis.Plugins.Devices.CoolerMaster
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System.IO;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Corsair;
|
||||
@ -12,7 +11,7 @@ namespace Artemis.Plugins.Devices.Corsair
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Plugins.Devices.DMX.ViewModels;
|
||||
|
||||
@ -11,7 +10,7 @@ namespace Artemis.Plugins.Devices.DMX
|
||||
{
|
||||
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;
|
||||
HasConfigurationViewModel = true;
|
||||
|
||||
@ -3,7 +3,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using HidSharp;
|
||||
using RGB.NET.Core;
|
||||
@ -19,7 +18,7 @@ namespace Artemis.Plugins.Devices.Logitech
|
||||
private readonly ILogger _logger;
|
||||
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;
|
||||
_logger = logger;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System.IO;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Msi;
|
||||
@ -12,7 +11,7 @@ namespace Artemis.Plugins.Devices.Msi
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Novation;
|
||||
@ -11,7 +10,7 @@ namespace Artemis.Plugins.Devices.Novation
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System.IO;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Razer;
|
||||
@ -13,7 +12,7 @@ namespace Artemis.Plugins.Devices.Razer
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System.IO;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
|
||||
namespace Artemis.Plugins.Devices.Roccat
|
||||
@ -10,7 +9,7 @@ namespace Artemis.Plugins.Devices.Roccat
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.SteelSeries;
|
||||
@ -11,7 +10,7 @@ namespace Artemis.Plugins.Devices.SteelSeries
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -15,19 +15,20 @@ namespace Artemis.Plugins.Devices.WS281X
|
||||
public class WS281XDeviceProvider : DeviceProvider
|
||||
{
|
||||
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;
|
||||
HasConfigurationViewModel = true;
|
||||
}
|
||||
|
||||
public PluginSettings Settings { get; }
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
var definitions = Settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
|
||||
HasConfigurationViewModel = true;
|
||||
|
||||
var definitions = _settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
|
||||
if (definitions.Value == null)
|
||||
definitions.Value = new List<DeviceDefinition>();
|
||||
|
||||
@ -53,10 +54,10 @@ namespace Artemis.Plugins.Devices.WS281X
|
||||
{
|
||||
// TODO: Remove the device provider from the surface
|
||||
}
|
||||
|
||||
|
||||
public override PluginConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return new WS281XConfigurationViewModel(this, Settings);
|
||||
return new WS281XConfigurationViewModel(this, _settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
using System.IO;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using RGB.NET.Devices.Wooting.Generic;
|
||||
@ -12,7 +11,7 @@ namespace Artemis.Plugins.Devices.Wooting
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
{
|
||||
"Guid": "e70fd5ba-9881-480a-8ff6-078ed5f747fa",
|
||||
"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",
|
||||
"Main": "Artemis.Plugins.Devices.Wooting.dll"
|
||||
}
|
||||
@ -37,6 +37,7 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
|
||||
<Exec Command="echo Copying resources to plugin output directory
XCOPY "$(ProjectDir)Images" "$(TargetDir)Images" /s /q /i /y
XCOPY "$(ProjectDir)Layouts" "$(TargetDir)Layouts" /s /q /i /y
echo Copying plugin to Artemis.UI output directory
XCOPY "$(TargetDir.TrimEnd('\'))" "$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)" /s /q /i /y" />
|
||||
<Exec
|
||||
Command="echo Copying resources to plugin output directory
XCOPY "$(ProjectDir)Images" "$(TargetDir)Images" /s /q /i /y
XCOPY "$(ProjectDir)Layouts" "$(TargetDir)Layouts" /s /q /i /y
echo Copying plugin to Artemis.UI output directory
XCOPY "$(TargetDir.TrimEnd('\'))" "$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)" /s /q /i /y" />
|
||||
</Target>
|
||||
</Project>
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Color
|
||||
@ -12,13 +11,9 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
||||
private SKShader _shader;
|
||||
private SKRect _shaderBounds;
|
||||
|
||||
public ColorBrush(Layer layer, LayerBrushDescriptor descriptor) : base(layer, descriptor)
|
||||
{
|
||||
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
|
||||
}
|
||||
|
||||
public override void EnableLayerBrush()
|
||||
{
|
||||
Layer.RenderPropertiesUpdated += (sender, args) => CreateShader();
|
||||
Properties.GradientType.BaseValueChanged += (sender, args) => CreateShader();
|
||||
Properties.Color.BaseValueChanged += (sender, args) => CreateShader();
|
||||
Properties.Gradient.BaseValue.PropertyChanged += (sender, args) => CreateShader();
|
||||
@ -66,13 +61,13 @@ namespace Artemis.Plugins.LayerBrushes.Color
|
||||
new SKPoint(_shaderBounds.Right, _shaderBounds.Top),
|
||||
Properties.Gradient.BaseValue.GetColorsArray(),
|
||||
Properties.Gradient.BaseValue.GetPositionsArray(),
|
||||
SKShaderTileMode.Repeat),
|
||||
SKShaderTileMode.Clamp),
|
||||
GradientType.RadialGradient => SKShader.CreateRadialGradient(
|
||||
center,
|
||||
Math.Min(_shaderBounds.Width, _shaderBounds.Height),
|
||||
Math.Max(_shaderBounds.Width, _shaderBounds.Height) / 2f,
|
||||
Properties.Gradient.BaseValue.GetColorsArray(),
|
||||
Properties.Gradient.BaseValue.GetPositionsArray(),
|
||||
SKShaderTileMode.Repeat),
|
||||
SKShaderTileMode.Clamp),
|
||||
GradientType.SweepGradient => SKShader.CreateSweepGradient(
|
||||
center,
|
||||
Properties.Gradient.BaseValue.GetColorsArray(),
|
||||
|
||||
@ -1,18 +1,12 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Color
|
||||
{
|
||||
public class ColorBrushProvider : LayerBrushProvider
|
||||
{
|
||||
public ColorBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
AddLayerBrushDescriptor<ColorBrush>("Color", "A color with an (optional) gradient", "Brush");
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
AddLayerBrushDescriptor<ColorBrush>("Color", "A color with an (optional) gradient", "Brush");
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
using RGB.NET.Brushes;
|
||||
using RGB.NET.Core;
|
||||
|
||||
@ -8,19 +7,16 @@ namespace Artemis.Plugins.LayerBrushes.ColorRgbNet
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public override void EnableLayerBrush()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DisableLayerBrush()
|
||||
{
|
||||
_solidBrush = null;
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Plugins.LayerBrushes.ColorRgbNet.PropertyInput;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
@ -9,15 +8,15 @@ namespace Artemis.Plugins.LayerBrushes.ColorRgbNet
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
|
||||
public RgbNetColorBrushProvider(PluginInfo pluginInfo, IProfileEditorService profileEditorService) : base(pluginInfo)
|
||||
public RgbNetColorBrushProvider(IProfileEditorService profileEditorService)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
AddLayerBrushDescriptor<RgbNetColorBrush>("RGB.NET Color", "A RGB.NET based color", "Brush");
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
_profileEditorService.RegisterPropertyInput(PluginInfo, typeof(StringPropertyInputViewModel));
|
||||
AddLayerBrushDescriptor<RgbNetColorBrush>("RGB.NET Color", "A RGB.NET based color", "Brush");
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Plugins.LayerBrushes.Noise.Utilities;
|
||||
using SkiaSharp;
|
||||
@ -11,31 +10,30 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
public class NoiseBrush : LayerBrush<NoiseBrushProperties>
|
||||
{
|
||||
private static readonly Random Rand = new Random();
|
||||
private readonly OpenSimplexNoise _noise;
|
||||
private readonly IRgbService _rgbService;
|
||||
private SKBitmap _bitmap;
|
||||
private SKColor[] _colorMap;
|
||||
|
||||
private OpenSimplexNoise _noise;
|
||||
private float _renderScale;
|
||||
private float _x;
|
||||
private float _y;
|
||||
private float _z;
|
||||
|
||||
public NoiseBrush(Layer layer, LayerBrushDescriptor descriptor, IRgbService rgbService) : base(layer, descriptor)
|
||||
public NoiseBrush(IRgbService rgbService)
|
||||
{
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
public override void EnableLayerBrush()
|
||||
{
|
||||
_x = Rand.Next(0, 4096);
|
||||
_y = Rand.Next(0, 4096);
|
||||
_z = Rand.Next(0, 4096);
|
||||
_noise = new OpenSimplexNoise(Rand.Next(0, 4096));
|
||||
|
||||
DetermineRenderScale();
|
||||
}
|
||||
|
||||
public override void EnableLayerBrush()
|
||||
{
|
||||
Properties.GradientColor.BaseValue.PropertyChanged += GradientColorChanged;
|
||||
CreateColorMap();
|
||||
DetermineRenderScale();
|
||||
}
|
||||
|
||||
public override void DisableLayerBrush()
|
||||
@ -115,7 +113,7 @@ namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
paint.Shader = foregroundShader;
|
||||
canvas.DrawRect(path.Bounds, paint);
|
||||
}
|
||||
|
||||
|
||||
private void GradientColorChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
CreateColorMap();
|
||||
|
||||
@ -1,18 +1,12 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
{
|
||||
public class NoiseBrushProvider : LayerBrushProvider
|
||||
{
|
||||
public NoiseBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
AddLayerBrushDescriptor<NoiseBrush>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
AddLayerBrushDescriptor<NoiseBrush>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
|
||||
@ -11,15 +11,9 @@ namespace Artemis.Plugins.Modules.General
|
||||
{
|
||||
private readonly PluginSettings _settings;
|
||||
|
||||
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo)
|
||||
public GeneralModule(PluginSettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
DisplayName = "General";
|
||||
DisplayIcon = "AllInclusive";
|
||||
ExpandsMainDataModel = true;
|
||||
DataModel = new GeneralDataModel(this);
|
||||
|
||||
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
|
||||
}
|
||||
|
||||
public override IEnumerable<ModuleViewModel> GetViewModels()
|
||||
@ -29,6 +23,12 @@ namespace Artemis.Plugins.Modules.General
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
DisplayName = "General";
|
||||
DisplayIcon = "AllInclusive";
|
||||
ExpandsMainDataModel = true;
|
||||
DataModel = new GeneralDataModel(this);
|
||||
|
||||
var testSetting = _settings.GetSetting("TestSetting", DateTime.Now);
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user