Plugins - Adjusted namespaces

This commit is contained in:
SpoinkyNL committed 2020-08-21 22:32:46 +02:00
1 parent c71faba2c9
commit f68d2629b7
144 files changed
+267 -252

No files matched your search

@@ -0,0 +1,134 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Services.Interfaces;
using SkiaSharp;
using Stylet;
namespace Artemis.Core.Plugins.LayerBrushes.Internal
{
/// <summary>
/// For internal use only, please use <see cref="LayerBrush{T}" /> or <see cref="RgbNetLayerBrush{T}" /> or instead
/// </summary>
public abstract class BaseLayerBrush : PropertyChangedBase, IDisposable
{
private LayerBrushType _brushType;
private LayerBrushConfigurationDialog _configurationDialog;
private LayerBrushDescriptor _descriptor;
private Layer _layer;
private bool _supportsTransformation = true;
/// <summary>
/// Gets the layer this brush is applied to
/// </summary>
public Layer Layer
{
get => _layer;
internal set => SetAndNotify(ref _layer, value);
}
/// <summary>
/// Gets the descriptor of this brush
/// </summary>
public LayerBrushDescriptor Descriptor
{
get => _descriptor;
internal set => SetAndNotify(ref _descriptor, value);
}
/// <summary>
/// Gets or sets a configuration dialog complementing the regular properties
/// </summary>
public LayerBrushConfigurationDialog ConfigurationDialog
{
get => _configurationDialog;
protected set => SetAndNotify(ref _configurationDialog, value);
}
/// <summary>
/// Gets the type of layer brush
/// </summary>
public LayerBrushType BrushType
{
get => _brushType;
internal set => SetAndNotify(ref _brushType, value);
}
/// <summary>
/// Gets the plugin info that defined this brush
/// </summary>
public PluginInfo PluginInfo => Descriptor.LayerBrushProvider.PluginInfo;
/// <summary>
/// Gets a reference to the layer property group without knowing it's type
/// </summary>
public virtual LayerPropertyGroup BaseProperties => null;
/// <summary>
/// Gets or sets whether the brush supports transformations
/// <para>Note: RGB.NET brushes can never be transformed and setting this to true will throw an exception</para>
/// </summary>
public bool SupportsTransformation
{
get => _supportsTransformation;
protected set
{
if (value && BrushType == LayerBrushType.RgbNet)
throw new ArtemisPluginException(PluginInfo, "An RGB.NET brush cannot support transformation");
_supportsTransformation = value;
}
}
/// <inheritdoc />
public void Dispose()
{
DisableLayerBrush();
BaseProperties.Dispose();
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Called when the layer brush is activated
/// </summary>
public abstract void EnableLayerBrush();
/// <summary>
/// Called when the layer brush is deactivated
/// </summary>
public abstract void DisableLayerBrush();
/// <summary>
/// Called before rendering every frame, write your update logic here
/// </summary>
/// <param name="deltaTime">Seconds passed since last update</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 LayerBrush<T> and RgbNetLayerBrush<T> outside the core
internal abstract void Initialize(IRenderElementService renderElementService);
internal abstract void InternalRender(SKCanvas canvas, SKImageInfo canvasInfo, SKPath path, SKPaint paint);
internal virtual void Dispose(bool disposing)
{
}
}
/// <summary>
/// Describes the type of a layer brush
/// </summary>
public enum LayerBrushType
{
/// <summary>
/// A regular brush that users Artemis' SkiaSharp-based rendering engine
/// </summary>
Regular,
/// <summary>
/// An RGB.NET brush that uses RGB.NET's per-LED rendering engine.
/// </summary>
RgbNet
}
}
@@ -0,0 +1,48 @@
using System;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Services.Interfaces;
namespace Artemis.Core.Plugins.LayerBrushes.Internal
{
/// <summary>
/// For internal use only, please use <see cref="LayerBrush{T}" /> or <see cref="RgbNetLayerBrush{T}" /> or instead
/// </summary>
public abstract class PropertiesLayerBrush<T> : BaseLayerBrush where T : LayerPropertyGroup
{
private T _properties;
/// <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;
}
internal void InitializeProperties(IRenderElementService renderElementService)
{
Properties = Activator.CreateInstance<T>();
Properties.LayerBrush = this;
Properties.InitializeProperties(renderElementService, Layer, "LayerBrush.");
PropertiesInitialized = true;
EnableLayerBrush();
}
}
}