Plugins - Implemented features

Core - Removed Stylet dependency for #500
This commit is contained in:
SpoinkyNL committed 2020-11-11 23:53:52 +01:00
1 parent b56966c585
commit e812929215
139 files changed
+1635 -1106

No files matched your search

@@ -1,34 +0,0 @@
using Stylet;
namespace Artemis.Core.LayerBrushes
{
/// <summary>
/// Represents a view model for a brush configuration window
/// </summary>
public abstract class BrushConfigurationViewModel : Screen
{
/// <summary>
/// Creates a new instance of the <see cref="BrushConfigurationViewModel" /> class
/// </summary>
/// <param name="layerBrush"></param>
protected BrushConfigurationViewModel(BaseLayerBrush layerBrush)
{
LayerBrush = layerBrush;
}
/// <summary>
/// Creates a new instance of the <see cref="BrushConfigurationViewModel" /> class with a validator
/// </summary>
/// <param name="layerBrush"></param>
/// <param name="validator"></param>
protected BrushConfigurationViewModel(BaseLayerBrush layerBrush, IModelValidator validator) : base(validator)
{
LayerBrush = layerBrush;
}
/// <summary>
/// Gets the layer brush this view model is associated with
/// </summary>
public BaseLayerBrush LayerBrush { get; }
}
}
@@ -0,0 +1,9 @@
namespace Artemis.Core.LayerBrushes
{
/// <summary>
/// Represents the configuration dialog of a layer brush
/// </summary>
public interface ILayerBrushConfigurationDialog
{
}
}
@@ -1,17 +1,15 @@
using System;
using Artemis.Core.Services;
using SkiaSharp;
using Stylet;
namespace Artemis.Core.LayerBrushes
{
/// <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
public abstract class BaseLayerBrush : CorePropertyChanged, IDisposable
{
private LayerBrushType _brushType;
private LayerBrushConfigurationDialog _configurationDialog;
private ILayerBrushConfigurationDialog _configurationDialog;
private LayerBrushDescriptor _descriptor;
private Layer _layer;
private bool _supportsTransformation = true;
@@ -37,7 +35,7 @@ namespace Artemis.Core.LayerBrushes
/// <summary>
/// Gets or sets a configuration dialog complementing the regular properties
/// </summary>
public LayerBrushConfigurationDialog ConfigurationDialog
public ILayerBrushConfigurationDialog ConfigurationDialog
{
get => _configurationDialog;
protected set => SetAndNotify(ref _configurationDialog, value);
@@ -53,9 +51,9 @@ namespace Artemis.Core.LayerBrushes
}
/// <summary>
/// Gets the plugin info that defined this brush
/// Gets the ID of the <see cref="LayerBrushProvider" /> that provided this effect
/// </summary>
public PluginInfo PluginInfo => Descriptor.LayerBrushProvider.PluginInfo;
public string ProviderId => Descriptor?.Provider?.Id;
/// <summary>
/// Gets a reference to the layer property group without knowing it's type
@@ -72,21 +70,11 @@ namespace Artemis.Core.LayerBrushes
protected set
{
if (value && BrushType == LayerBrushType.RgbNet)
throw new ArtemisPluginException(PluginInfo, "An RGB.NET brush cannot support transformation");
throw new ArtemisPluginFeatureException(Descriptor.Provider, "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>
@@ -112,6 +100,16 @@ namespace Artemis.Core.LayerBrushes
internal virtual void Dispose(bool disposing)
{
}
/// <inheritdoc />
public void Dispose()
{
DisableLayerBrush();
BaseProperties.Dispose();
Dispose(true);
GC.SuppressFinalize(this);
}
}
/// <summary>
@@ -37,7 +37,7 @@ namespace Artemis.Core.LayerBrushes
Properties = Activator.CreateInstance<T>();
Properties.GroupDescription ??= new PropertyGroupDescriptionAttribute {Name = Descriptor.DisplayName, Description = Descriptor.Description};
Properties.LayerBrush = this;
Properties.Initialize(Layer, "LayerBrush.", PluginInfo);
Properties.Initialize(Layer, "LayerBrush.", Descriptor.Provider);
PropertiesInitialized = true;
EnableLayerBrush();
@@ -1,27 +0,0 @@
using System;
namespace Artemis.Core.LayerBrushes
{
/// <inheritdoc />
public class LayerBrushConfigurationDialog<T> : LayerBrushConfigurationDialog where T : BrushConfigurationViewModel
{
/// <inheritdoc />
public override Type Type => typeof(T);
}
/// <summary>
/// Describes a UI tab for a layer brush
/// </summary>
public abstract class LayerBrushConfigurationDialog
{
/// <summary>
/// The layer brush this dialog belongs to
/// </summary>
internal BaseLayerBrush LayerBrush { get; set; }
/// <summary>
/// The type of view model the tab contains
/// </summary>
public abstract Type Type { get; }
}
}
@@ -1,5 +1,4 @@
using System;
using Artemis.Core.Services;
using Ninject;
namespace Artemis.Core.LayerBrushes
@@ -9,13 +8,13 @@ namespace Artemis.Core.LayerBrushes
/// </summary>
public class LayerBrushDescriptor
{
internal LayerBrushDescriptor(string displayName, string description, string icon, Type layerBrushType, LayerBrushProvider layerBrushProvider)
internal LayerBrushDescriptor(string displayName, string description, string icon, Type layerBrushType, LayerBrushProvider provider)
{
DisplayName = displayName;
Description = description;
Icon = icon;
LayerBrushType = layerBrushType;
LayerBrushProvider = layerBrushProvider;
Provider = provider;
}
/// <summary>
@@ -42,7 +41,7 @@ namespace Artemis.Core.LayerBrushes
/// <summary>
/// The plugin that provided this <see cref="LayerBrushDescriptor" />
/// </summary>
public LayerBrushProvider LayerBrushProvider { get; }
public LayerBrushProvider Provider { get; }
/// <summary>
/// Determines whether the provided <paramref name="reference" /> references to a brush provided by this descriptor
@@ -51,7 +50,8 @@ namespace Artemis.Core.LayerBrushes
{
if (reference == null)
return false;
return LayerBrushProvider.PluginInfo.Guid == reference.BrushPluginGuid && LayerBrushType.Name == reference.BrushType;
return Provider.Id == reference.LayerBrushProviderId && LayerBrushType.Name == reference.BrushType;
}
/// <summary>
@@ -62,7 +62,7 @@ namespace Artemis.Core.LayerBrushes
if (layer.LayerBrush != null)
throw new ArtemisCoreException("Layer already has an instantiated layer brush");
BaseLayerBrush brush = (BaseLayerBrush) LayerBrushProvider.PluginInfo.Kernel.Get(LayerBrushType);
BaseLayerBrush brush = (BaseLayerBrush) Provider.Plugin.Kernel!.Get(LayerBrushType);
brush.Layer = layer;
brush.Descriptor = this;
brush.Initialize();
@@ -7,7 +7,7 @@ namespace Artemis.Core.LayerBrushes
/// <summary>
/// Allows you to create one or more <see cref="LayerBrush{T}" />s usable by profile layers.
/// </summary>
public abstract class LayerBrushProvider : PluginImplementation
public abstract class LayerBrushProvider : PluginFeature
{
private readonly List<LayerBrushDescriptor> _layerBrushDescriptors;
@@ -39,7 +39,7 @@ namespace Artemis.Core.LayerBrushes
protected void RegisterLayerBrushDescriptor<T>(string displayName, string description, string icon) where T : BaseLayerBrush
{
if (!IsEnabled)
throw new ArtemisPluginException(PluginInfo, "Can only add a layer brush descriptor when the plugin is enabled");
throw new ArtemisPluginException(Plugin, "Can only add a layer brush descriptor when the plugin is enabled");
LayerBrushDescriptor descriptor = new LayerBrushDescriptor(displayName, description, icon, typeof(T), this);
_layerBrushDescriptors.Add(descriptor);