mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +00:00
Plugins - Simplified and streamlined the way plugins provide VMs
Plugins - Added dependency injection to all plugin VMs Plugin settings - Allow injecting plugin settings into any class defined in the plugin assembly
This commit is contained in:
parent
a06ad8f011
commit
625fcbafdd
@ -2,6 +2,7 @@
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using Ninject.Activation;
|
||||
|
||||
@ -10,20 +11,28 @@ namespace Artemis.Core.Ninject
|
||||
internal class PluginSettingsProvider : Provider<PluginSettings>
|
||||
{
|
||||
private readonly IPluginRepository _pluginRepository;
|
||||
private readonly IPluginService _pluginService;
|
||||
|
||||
internal PluginSettingsProvider(IPluginRepository pluginRepository)
|
||||
internal PluginSettingsProvider(IPluginRepository pluginRepository, IPluginService pluginService)
|
||||
{
|
||||
_pluginRepository = pluginRepository;
|
||||
_pluginService = pluginService;
|
||||
}
|
||||
|
||||
protected override PluginSettings CreateInstance(IContext context)
|
||||
{
|
||||
var parentRequest = context.Request.ParentRequest;
|
||||
if (parentRequest == null || !typeof(Plugin).IsAssignableFrom(parentRequest.Service))
|
||||
throw new ArtemisCoreException("PluginSettings can only be injected into a plugin");
|
||||
if (parentRequest == null)
|
||||
throw new ArtemisCoreException("PluginSettings couldn't be injected, failed to get the injection parent request");
|
||||
|
||||
// First try by PluginInfo parameter
|
||||
var pluginInfo = parentRequest.Parameters.FirstOrDefault(p => p.Name == "PluginInfo")?.GetValue(context, null) as PluginInfo;
|
||||
if (pluginInfo == null)
|
||||
throw new ArtemisCoreException("A plugin needs to be initialized with PluginInfo as a parameter");
|
||||
pluginInfo = _pluginService.GetPluginByAssembly(parentRequest.Service.Assembly)?.PluginInfo;
|
||||
// Fall back to assembly based detection
|
||||
if (pluginInfo == null)
|
||||
throw new ArtemisCoreException("PluginSettings can only be injected with the PluginInfo parameter provided " +
|
||||
"or into a class defined in a plugin assembly");
|
||||
|
||||
return new PluginSettings(pluginInfo, _pluginRepository);
|
||||
}
|
||||
|
||||
@ -13,21 +13,38 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public abstract class DeviceProvider : Plugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="DeviceProvider" /> class
|
||||
/// </summary>
|
||||
/// <param name="rgbDeviceProvider"></param>
|
||||
protected DeviceProvider(IRGBDeviceProvider rgbDeviceProvider)
|
||||
{
|
||||
RgbDeviceProvider = rgbDeviceProvider ?? throw new ArgumentNullException(nameof(rgbDeviceProvider));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The RGB.NET device provider backing this Artemis device provider
|
||||
/// </summary>
|
||||
public IRGBDeviceProvider RgbDeviceProvider { get; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO: Make internal while still injecting.
|
||||
/// A logger used by the device provider internally, ignore this
|
||||
/// </summary>
|
||||
[Inject]
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
// Does not happen with device providers, they require Artemis to restart
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void ResolveAbsolutePath(Type type, object sender, ResolvePathEventArgs e)
|
||||
{
|
||||
if (sender.GetType() == type || sender.GetType().IsGenericType(type))
|
||||
|
||||
@ -7,14 +7,16 @@ 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.
|
||||
/// Allows you to create one or more <see cref="LayerBrush{T}" />s usable by profile layers.
|
||||
/// </summary>
|
||||
public abstract class LayerBrushProvider : Plugin
|
||||
{
|
||||
private readonly List<LayerBrushDescriptor> _layerBrushDescriptors;
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to register one or more <see cref="LayerBrush{T}" />s usable by profile layers.
|
||||
/// </summary>
|
||||
protected LayerBrushProvider()
|
||||
{
|
||||
_layerBrushDescriptors = new List<LayerBrushDescriptor>();
|
||||
|
||||
@ -7,14 +7,16 @@ using Artemis.Core.Plugins.LayerEffect.Abstract;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Allows you to create one or more <see cref="LayerEffect" />s usable by profile layers.
|
||||
/// Allows you to register one or more <see cref="LayerEffect{T}" />s usable by profile layers.
|
||||
/// </summary>
|
||||
public abstract class LayerEffectProvider : Plugin
|
||||
{
|
||||
private readonly List<LayerEffectDescriptor> _layerEffectDescriptors;
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to register one or more <see cref="LayerEffect{T}" />s usable by profile layers.
|
||||
/// </summary>
|
||||
protected LayerEffectProvider()
|
||||
{
|
||||
_layerEffectDescriptors = new List<LayerEffectDescriptor>();
|
||||
|
||||
@ -4,7 +4,6 @@ using System.Linq;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels;
|
||||
using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.Storage.Entities.Module;
|
||||
using SkiaSharp;
|
||||
@ -104,20 +103,25 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
public ModulePriorityCategory DefaultPriorityCategory { get; set; } = ModulePriorityCategory.Normal;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current priority category of this module
|
||||
/// Gets the current priority category of this module
|
||||
/// </summary>
|
||||
public ModulePriorityCategory PriorityCategory { get; set; }
|
||||
public ModulePriorityCategory PriorityCategory { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current priority of this module within its priority category
|
||||
/// Gets the current priority of this module within its priority category
|
||||
/// </summary>
|
||||
public int Priority { get; set; }
|
||||
public int Priority { get; internal set; }
|
||||
|
||||
internal DataModel InternalDataModel { get; set; }
|
||||
|
||||
internal bool InternalExpandsMainDataModel { get; set; }
|
||||
internal ModuleSettingsEntity Entity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A list of custom module tabs that show in the UI
|
||||
/// </summary>
|
||||
public IEnumerable<ModuleTab> ModuleTabs { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called each frame when the module must update
|
||||
/// </summary>
|
||||
@ -133,12 +137,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// <param name="canvasInfo"></param>
|
||||
public abstract void Render(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the module's view model is being show, return a list of module tabs here if you want them to show up in the UI
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract IEnumerable<ModuleTab> GetModuleTabs();
|
||||
|
||||
/// <summary>
|
||||
/// Called when the <see cref="ActivationRequirements" /> are met
|
||||
/// </summary>
|
||||
@ -194,6 +192,9 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes in what way the activation requirements of a module must be met
|
||||
/// </summary>
|
||||
public enum ActivationRequirementType
|
||||
{
|
||||
/// <summary>
|
||||
@ -207,6 +208,9 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
All
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes the priority category of a module
|
||||
/// </summary>
|
||||
public enum ModulePriorityCategory
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@ -3,7 +3,6 @@ using System.Threading.Tasks;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Castle.Core.Internal;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
@ -12,6 +11,9 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public abstract class Plugin : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the plugin info related to this plugin
|
||||
/// </summary>
|
||||
public PluginInfo PluginInfo { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
@ -20,11 +22,11 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
public bool Enabled { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this plugin has a configuration view model.
|
||||
/// If set to true, <see cref="GetConfigurationViewModel" /> will be called when the plugin is configured from the UI.
|
||||
/// Gets or sets a configuration dialog for this plugin that is accessible in the UI under Settings > Plugins
|
||||
/// </summary>
|
||||
public bool HasConfigurationViewModel { get; protected set; }
|
||||
public PluginConfigurationDialog ConfigurationDialog { get; protected set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
DisablePlugin();
|
||||
@ -40,16 +42,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// </summary>
|
||||
public abstract void DisablePlugin();
|
||||
|
||||
/// <summary>
|
||||
/// Called when the plugins configuration window is opened from the UI. The UI will only attempt to open if
|
||||
/// <see cref="HasConfigurationViewModel" /> is set to True.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual PluginConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
internal void SetEnabled(bool enable, bool isAutoEnable = false)
|
||||
{
|
||||
if (enable && !Enabled)
|
||||
@ -116,14 +108,27 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the plugin is enabled
|
||||
/// </summary>
|
||||
public event EventHandler PluginEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the plugin is disabled
|
||||
/// </summary>
|
||||
public event EventHandler PluginDisabled;
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the PluginEnabled event
|
||||
/// </summary>
|
||||
protected virtual void OnPluginEnabled()
|
||||
{
|
||||
PluginEnabled?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggers the PluginDisabled event
|
||||
/// </summary>
|
||||
protected virtual void OnPluginDisabled()
|
||||
{
|
||||
PluginDisabled?.Invoke(this, EventArgs.Empty);
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class PluginConfigurationDialog<T> : PluginConfigurationDialog where T : PluginConfigurationViewModel
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override Type Type => typeof(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a configuration dialog for a specific plugin
|
||||
/// </summary>
|
||||
public abstract class PluginConfigurationDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// The layer brush this dialog belongs to
|
||||
/// </summary>
|
||||
internal Plugin Plugin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of view model the tab contains
|
||||
/// </summary>
|
||||
public abstract Type Type { get; }
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
@ -15,6 +14,7 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
public abstract class BaseLayerBrush : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private LayerBrushType _brushType;
|
||||
private LayerBrushConfigurationDialog _configurationDialog;
|
||||
private LayerBrushDescriptor _descriptor;
|
||||
private Layer _layer;
|
||||
private bool _supportsTransformation = true;
|
||||
@ -37,6 +37,15 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
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>
|
||||
@ -71,12 +80,7 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this plugin has a configuration view model.
|
||||
/// If set to true, <see cref="GetConfigurationViewModel" /> will be called when the plugin is configured from the UI.
|
||||
/// </summary>
|
||||
public bool HasConfigurationViewModel { get; protected set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
DisableLayerBrush();
|
||||
@ -102,16 +106,6 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public abstract void Update(double deltaTime);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the brush configuration window is opened from the UI. The UI will only attempt to open if
|
||||
/// <see cref="HasConfigurationViewModel" /> is set to True.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual BrushConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// 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);
|
||||
@ -123,9 +117,19 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
}
|
||||
}
|
||||
|
||||
/// <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
|
||||
}
|
||||
}
|
||||
@ -8,8 +8,16 @@ using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
||||
{
|
||||
/// <summary>
|
||||
/// An RGB.NET brush that uses RGB.NET's per-LED rendering engine.
|
||||
/// <para>Note: This brush type always renders on top of regular brushes</para>
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public abstract class RgbNetLayerBrush<T> : PropertiesLayerBrush<T> where T : LayerPropertyGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="RgbNetLayerBrush{T}" /> class
|
||||
/// </summary>
|
||||
protected RgbNetLayerBrush()
|
||||
{
|
||||
BrushType = LayerBrushType.RgbNet;
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.LayerBrush.Abstract;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
/// <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; }
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,9 @@ using Artemis.Core.Plugins.Abstract;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that describes a layer brush
|
||||
/// </summary>
|
||||
public class LayerBrushDescriptor
|
||||
{
|
||||
internal LayerBrushDescriptor(string displayName, string description, string icon, Type layerBrushType, LayerBrushProvider layerBrushProvider)
|
||||
@ -14,10 +17,30 @@ namespace Artemis.Core.Plugins.LayerBrush
|
||||
LayerBrushProvider = layerBrushProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name that is displayed in the UI
|
||||
/// </summary>
|
||||
public string DisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The description that is displayed in the UI
|
||||
/// </summary>
|
||||
public string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Material icon to display in the UI, a full reference can be found
|
||||
/// <see href="https://materialdesignicons.com">here</see>
|
||||
/// </summary>
|
||||
public string Icon { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of the layer brush
|
||||
/// </summary>
|
||||
public Type LayerBrushType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The plugin that provided this <see cref="LayerBrushDescriptor" />
|
||||
/// </summary>
|
||||
public LayerBrushProvider LayerBrushProvider { get; }
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using SkiaSharp;
|
||||
@ -13,13 +12,14 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
/// </summary>
|
||||
public abstract class BaseLayerEffect : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private Guid _entityId;
|
||||
private RenderProfileElement _profileElement;
|
||||
private string _name;
|
||||
private bool _enabled;
|
||||
private bool _hasBeenRenamed;
|
||||
private int _order;
|
||||
private LayerEffectDescriptor _descriptor;
|
||||
private bool _enabled;
|
||||
private Guid _entityId;
|
||||
private bool _hasBeenRenamed;
|
||||
private string _name;
|
||||
private int _order;
|
||||
private RenderProfileElement _profileElement;
|
||||
private LayerEffectConfigurationDialog _configurationDialog;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique ID of this effect
|
||||
@ -77,7 +77,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the descriptor of this effect
|
||||
/// Gets the <see cref="LayerEffectDescriptor"/> that registered this effect
|
||||
/// </summary>
|
||||
public LayerEffectDescriptor Descriptor
|
||||
{
|
||||
@ -85,6 +85,15 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
internal set => SetAndNotify(ref _descriptor, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a configuration dialog complementing the regular properties
|
||||
/// </summary>
|
||||
public LayerEffectConfigurationDialog ConfigurationDialog
|
||||
{
|
||||
get => _configurationDialog;
|
||||
protected set => SetAndNotify(ref _configurationDialog, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin info that defined this effect
|
||||
/// </summary>
|
||||
@ -97,12 +106,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
|
||||
internal string PropertyRootPath => $"LayerEffect.{EntityId}.{GetType().Name}.";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this plugin has a configuration view model.
|
||||
/// If set to true, <see cref="GetConfigurationViewModel" /> will be called when the plugin is configured from the UI.
|
||||
/// </summary>
|
||||
public bool HasConfigurationViewModel { get; protected set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
DisableLayerEffect();
|
||||
@ -146,16 +150,5 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
||||
// 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(IRenderElementService renderElementService);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called when the effect configuration window is opened from the UI. The UI will only attempt to open if
|
||||
/// <see cref="HasConfigurationViewModel" /> is set to True.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual EffectConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.LayerEffect.Abstract;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerEffect
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public class LayerEffectConfigurationDialog<T> : LayerEffectConfigurationDialog where T : EffectConfigurationViewModel
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override Type Type => typeof(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a UI tab for a specific layer effect
|
||||
/// </summary>
|
||||
public abstract class LayerEffectConfigurationDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// The layer effect this dialog belongs to
|
||||
/// </summary>
|
||||
internal BaseLayerEffect LayerEffect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of view model the tab contains
|
||||
/// </summary>
|
||||
public abstract Type Type { get; }
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,9 @@ using Artemis.Core.Plugins.Abstract;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// A class that describes a layer effect
|
||||
/// </summary>
|
||||
public class LayerEffectDescriptor
|
||||
{
|
||||
internal LayerEffectDescriptor(string displayName, string description, string icon, Type layerEffectType, LayerEffectProvider layerEffectProvider)
|
||||
@ -14,10 +17,30 @@ namespace Artemis.Core.Plugins.LayerEffect
|
||||
LayerEffectProvider = layerEffectProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name that is displayed in the UI
|
||||
/// </summary>
|
||||
public string DisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The description that is displayed in the UI
|
||||
/// </summary>
|
||||
public string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Material icon to display in the UI, a full reference can be found
|
||||
/// <see href="https://materialdesignicons.com">here</see>
|
||||
/// </summary>
|
||||
public string Icon { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of the layer effect
|
||||
/// </summary>
|
||||
public Type LayerEffectType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The plugin that provided this <see cref="LayerEffectDescriptor" />
|
||||
/// </summary>
|
||||
public LayerEffectProvider LayerEffectProvider { get; }
|
||||
}
|
||||
}
|
||||
@ -46,6 +46,12 @@ namespace Artemis.Core.Plugins.Models
|
||||
}
|
||||
|
||||
var pluginSetting = new PluginSetting<T>(_pluginInfo, _pluginRepository, settingEntity);
|
||||
|
||||
// This overrides null with the default value, I'm not sure if that's desirable because you
|
||||
// might expect something to go null and you might not
|
||||
// if (pluginSetting.Value == null && defaultValue != null)
|
||||
// pluginSetting.Value = defaultValue;
|
||||
|
||||
_settingEntities.Add(name, pluginSetting);
|
||||
return pluginSetting;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
@ -75,7 +76,19 @@ namespace Artemis.Core.Services.Interfaces
|
||||
/// <returns>Returns a list of plug instances of type <see cref="T" /></returns>
|
||||
List<T> GetPluginsOfType<T>() where T : Plugin;
|
||||
|
||||
Plugin GetDevicePlugin(IRGBDevice device);
|
||||
/// <summary>
|
||||
/// Gets the plugin that provided the specified assembly
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
/// <returns></returns>
|
||||
Plugin GetPluginByAssembly(Assembly assembly);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the plugin that defined the specified device
|
||||
/// </summary>
|
||||
/// <param name="device"></param>
|
||||
/// <returns></returns>
|
||||
Plugin GetPluginByDevice(IRGBDevice device);
|
||||
|
||||
#region Events
|
||||
|
||||
|
||||
@ -46,10 +46,8 @@ namespace Artemis.Core.Services
|
||||
Directory.CreateDirectory(Constants.DataFolder + "plugins");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool LoadingPlugins { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public void CopyBuiltInPlugins()
|
||||
{
|
||||
OnCopyingBuildInPlugins();
|
||||
@ -161,7 +159,6 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void UnloadPlugins()
|
||||
{
|
||||
lock (_plugins)
|
||||
@ -181,7 +178,6 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void LoadPlugin(PluginInfo pluginInfo)
|
||||
{
|
||||
lock (_plugins)
|
||||
@ -256,7 +252,6 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void UnloadPlugin(PluginInfo pluginInfo)
|
||||
{
|
||||
lock (_plugins)
|
||||
@ -347,25 +342,27 @@ namespace Artemis.Core.Services
|
||||
OnPluginDisabled(new PluginEventArgs(plugin.PluginInfo));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public PluginInfo GetPluginInfo(Plugin plugin)
|
||||
{
|
||||
return _plugins.FirstOrDefault(p => p.Instance == plugin);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<PluginInfo> GetAllPluginInfo()
|
||||
{
|
||||
return new List<PluginInfo>(_plugins);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<T> GetPluginsOfType<T>() where T : Plugin
|
||||
{
|
||||
return _plugins.Where(p => p.Enabled && p.Instance is T).Select(p => (T) p.Instance).ToList();
|
||||
}
|
||||
|
||||
public Plugin GetDevicePlugin(IRGBDevice rgbDevice)
|
||||
public Plugin GetPluginByAssembly(Assembly assembly)
|
||||
{
|
||||
return _plugins.FirstOrDefault(p => p.Assembly == assembly)?.Instance;
|
||||
}
|
||||
|
||||
public Plugin GetPluginByDevice(IRGBDevice rgbDevice)
|
||||
{
|
||||
return GetPluginsOfType<DeviceProvider>().First(d => d.RgbDeviceProvider.Devices != null && d.RgbDeviceProvider.Devices.Contains(rgbDevice));
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ namespace Artemis.Core.Services.Storage
|
||||
// Add all current devices
|
||||
foreach (var rgbDevice in _rgbService.LoadedDevices)
|
||||
{
|
||||
var plugin = _pluginService.GetDevicePlugin(rgbDevice);
|
||||
var plugin = _pluginService.GetPluginByDevice(rgbDevice);
|
||||
configuration.Devices.Add(new ArtemisDevice(rgbDevice, plugin, configuration));
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ namespace Artemis.Core.Services.Storage
|
||||
var device = _rgbService.Surface.Devices.FirstOrDefault(d => d.GetDeviceIdentifier() == position.DeviceIdentifier);
|
||||
if (device != null)
|
||||
{
|
||||
var plugin = _pluginService.GetDevicePlugin(device);
|
||||
var plugin = _pluginService.GetPluginByDevice(device);
|
||||
surfaceConfiguration.Devices.Add(new ArtemisDevice(device, plugin, surfaceConfiguration, position));
|
||||
}
|
||||
}
|
||||
@ -184,7 +184,7 @@ namespace Artemis.Core.Services.Storage
|
||||
var existingDeviceConfig = surface.SurfaceEntity.DeviceEntities.FirstOrDefault(d => d.DeviceIdentifier == deviceIdentifier);
|
||||
if (existingDeviceConfig != null)
|
||||
{
|
||||
var plugin = _pluginService.GetDevicePlugin(rgbDevice);
|
||||
var plugin = _pluginService.GetPluginByDevice(rgbDevice);
|
||||
device = new ArtemisDevice(rgbDevice, plugin, surface, existingDeviceConfig);
|
||||
}
|
||||
// Fall back on creating a new device
|
||||
@ -195,7 +195,7 @@ namespace Artemis.Core.Services.Storage
|
||||
rgbDevice.DeviceInfo,
|
||||
deviceIdentifier
|
||||
);
|
||||
var plugin = _pluginService.GetDevicePlugin(rgbDevice);
|
||||
var plugin = _pluginService.GetPluginByDevice(rgbDevice);
|
||||
device = new ArtemisDevice(rgbDevice, plugin, surface);
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Newtonsoft.Json;
|
||||
@ -91,10 +88,5 @@ namespace Artemis.Core.Utilities
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override IEnumerable<ModuleTab> GetModuleTabs()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
@ -39,9 +41,9 @@ namespace Artemis.UI.Screens.Module
|
||||
Items.Add(profileEditor);
|
||||
}
|
||||
|
||||
var moduleTabs = Module.GetModuleTabs();
|
||||
if (moduleTabs != null)
|
||||
if (Module.ModuleTabs != null)
|
||||
{
|
||||
var moduleTabs = new List<ModuleTab>(Module.ModuleTabs);
|
||||
foreach (var moduleTab in moduleTabs.Where(m => m != null))
|
||||
{
|
||||
var module = new ConstructorArgument("module", Module);
|
||||
|
||||
@ -106,7 +106,7 @@
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{s:Action OpenBrushSettings}"
|
||||
Visibility="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerBrush.HasConfigurationViewModel, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
Visibility="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerBrush.ConfigurationDialog, Converter={StaticResource NullToVisibilityConverter}}">
|
||||
<materialDesign:PackIcon Kind="Settings" Height="16" Width="16" />
|
||||
</Button>
|
||||
</Grid>
|
||||
@ -184,7 +184,7 @@
|
||||
Height="24"
|
||||
VerticalAlignment="Center"
|
||||
Command="{s:Action OpenEffectSettings}"
|
||||
Visibility="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.HasConfigurationViewModel, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
Visibility="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.ConfigurationDialog, Converter={StaticResource NullToVisibilityConverter}}">
|
||||
<materialDesign:PackIcon Kind="Settings" Height="16" Width="16" />
|
||||
</Button>
|
||||
<Button Style="{StaticResource MaterialDesignIconButton}"
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Screens.ProfileEditor.Dialogs;
|
||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties.Abstract;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
@ -12,16 +15,22 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IRenderElementService _renderElementService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
|
||||
public TreePropertyGroupViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel,
|
||||
IProfileEditorService profileEditorService, IRenderElementService renderElementService, IDialogService dialogService, IWindowManager windowManager)
|
||||
IProfileEditorService profileEditorService,
|
||||
IRenderElementService renderElementService,
|
||||
IDialogService dialogService,
|
||||
IWindowManager windowManager,
|
||||
IKernel kernel)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_renderElementService = renderElementService;
|
||||
_dialogService = dialogService;
|
||||
_windowManager = windowManager;
|
||||
_kernel = kernel;
|
||||
LayerPropertyGroupViewModel = (LayerPropertyGroupViewModel) layerPropertyBaseViewModel;
|
||||
}
|
||||
|
||||
@ -29,11 +38,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
|
||||
public void OpenBrushSettings()
|
||||
{
|
||||
var configurationViewModel = LayerPropertyGroupViewModel.LayerPropertyGroup.LayerBrush.ConfigurationDialog;
|
||||
if (configurationViewModel == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var configurationViewModel = LayerPropertyGroupViewModel.LayerPropertyGroup.LayerBrush.GetConfigurationViewModel();
|
||||
if (configurationViewModel != null)
|
||||
_windowManager.ShowDialog(new LayerBrushSettingsWindowViewModel(configurationViewModel));
|
||||
var layerBrush = new ConstructorArgument("layerBrush", LayerPropertyGroupViewModel.LayerPropertyGroup.LayerBrush);
|
||||
var viewModel = (BrushConfigurationViewModel) _kernel.Get(configurationViewModel.Type, layerBrush);
|
||||
_windowManager.ShowDialog(new LayerBrushSettingsWindowViewModel(viewModel));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -44,11 +57,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
|
||||
public void OpenEffectSettings()
|
||||
{
|
||||
var configurationViewModel = LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.ConfigurationDialog;
|
||||
if (configurationViewModel == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var configurationViewModel = LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.GetConfigurationViewModel();
|
||||
if (configurationViewModel != null)
|
||||
_windowManager.ShowDialog(new LayerEffectSettingsWindowViewModel(configurationViewModel));
|
||||
var layerEffect = new ConstructorArgument("layerEffect", LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect);
|
||||
var viewModel = (EffectConfigurationViewModel) _kernel.Get(configurationViewModel.Type, layerEffect);
|
||||
_windowManager.ShowDialog(new LayerEffectSettingsWindowViewModel(viewModel));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@ -3,10 +3,13 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
@ -16,17 +19,23 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly ISnackbarMessageQueue _snackbarMessageQueue;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private Plugin _plugin;
|
||||
private PluginInfo _pluginInfo;
|
||||
private bool _enabling;
|
||||
|
||||
public PluginSettingsViewModel(Plugin plugin, IWindowManager windowManager, IDialogService dialogService, IPluginService pluginService,
|
||||
public PluginSettingsViewModel(Plugin plugin,
|
||||
IKernel kernel,
|
||||
IWindowManager windowManager,
|
||||
IDialogService dialogService,
|
||||
IPluginService pluginService,
|
||||
ISnackbarMessageQueue snackbarMessageQueue)
|
||||
{
|
||||
Plugin = plugin;
|
||||
PluginInfo = plugin.PluginInfo;
|
||||
|
||||
_kernel = kernel;
|
||||
_windowManager = windowManager;
|
||||
_dialogService = dialogService;
|
||||
_pluginService = pluginService;
|
||||
@ -53,7 +62,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
|
||||
public PackIconKind Icon => GetIconKind();
|
||||
public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name;
|
||||
public bool CanOpenSettings => IsEnabled && Plugin.HasConfigurationViewModel;
|
||||
public bool CanOpenSettings => IsEnabled && Plugin.ConfigurationDialog != null;
|
||||
public bool DisplayLoadFailed => !Enabling && PluginInfo.LoadException != null;
|
||||
|
||||
public bool IsEnabled
|
||||
@ -64,11 +73,15 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
|
||||
public void OpenSettings()
|
||||
{
|
||||
var configurationViewModel = Plugin.ConfigurationDialog;
|
||||
if (configurationViewModel == null)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
var configurationViewModel = Plugin.GetConfigurationViewModel();
|
||||
if (configurationViewModel != null)
|
||||
_windowManager.ShowDialog(new PluginSettingsWindowViewModel(configurationViewModel, Icon));
|
||||
var plugin = new ConstructorArgument("plugin", Plugin);
|
||||
var viewModel = (PluginConfigurationViewModel) _kernel.Get(configurationViewModel.Type, plugin);
|
||||
_windowManager.ShowDialog(new PluginSettingsWindowViewModel(viewModel, Icon));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Plugins.Devices.DMX.ViewModels;
|
||||
|
||||
@ -13,19 +12,15 @@ namespace Artemis.Plugins.Devices.DMX
|
||||
public DMXDeviceProvider(IRgbService rgbService) : base(RGB.NET.Devices.DMX.DMXDeviceProvider.Instance)
|
||||
{
|
||||
_rgbService = rgbService;
|
||||
HasConfigurationViewModel = true;
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
ConfigurationDialog = new PluginConfigurationDialog<DMXConfigurationViewModel>();
|
||||
|
||||
// TODO: Load from configuration
|
||||
// RGB.NET.Devices.DMX.DMXDeviceProvider.Instance.AddDeviceDefinition();
|
||||
_rgbService.AddDeviceProvider(RgbDeviceProvider);
|
||||
}
|
||||
|
||||
public override PluginConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return new DMXConfigurationViewModel(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
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.Debug.Settings;
|
||||
@ -24,13 +22,12 @@ namespace Artemis.Plugins.Devices.Debug
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
HasConfigurationViewModel = true;
|
||||
ConfigurationDialog = new PluginConfigurationDialog<DebugConfigurationViewModel>();
|
||||
PathHelper.ResolvingAbsolutePath += PathHelperOnResolvingAbsolutePath;
|
||||
|
||||
var definitions = _settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
|
||||
var definitions = _settings.GetSetting("DeviceDefinitions", new List<DeviceDefinition>());
|
||||
if (definitions.Value == null)
|
||||
definitions.Value = new List<DeviceDefinition>();
|
||||
|
||||
@ -40,6 +37,11 @@ namespace Artemis.Plugins.Devices.Debug
|
||||
_rgbService.AddDeviceProvider(RgbDeviceProvider);
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
// TODO: Remove the device provider from the surface
|
||||
}
|
||||
|
||||
private void PathHelperOnResolvingAbsolutePath(object sender, ResolvePathEventArgs e)
|
||||
{
|
||||
if (sender is DebugRGBDevice debugRgbDevice)
|
||||
@ -49,19 +51,7 @@ namespace Artemis.Plugins.Devices.Debug
|
||||
var rootDirectory = debugRgbDevice.LayoutPath.Split("\\Layouts")[0];
|
||||
e.FinalPath = Path.Combine(rootDirectory, e.RelativePath);
|
||||
}
|
||||
|
||||
var test =debugRgbDevice.LayoutPath;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
// TODO: Remove the device provider from the surface
|
||||
}
|
||||
|
||||
public override PluginConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return new DebugConfigurationViewModel(this, _settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -10,11 +10,11 @@ namespace Artemis.Plugins.Devices.Debug.ViewModels
|
||||
{
|
||||
public class DebugConfigurationViewModel : PluginConfigurationViewModel
|
||||
{
|
||||
private PluginSetting<List<DeviceDefinition>> _definitions;
|
||||
private readonly PluginSetting<List<DeviceDefinition>> _definitions;
|
||||
|
||||
public DebugConfigurationViewModel(Plugin plugin, PluginSettings settings) : base(plugin)
|
||||
{
|
||||
_definitions = settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
|
||||
_definitions = settings.GetSetting("DeviceDefinitions", new List<DeviceDefinition>());
|
||||
Definitions = new BindableCollection<DeviceDefinition>(_definitions.Value);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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.WS281X.Settings;
|
||||
@ -23,10 +22,9 @@ namespace Artemis.Plugins.Devices.WS281X
|
||||
_rgbService = rgbService;
|
||||
}
|
||||
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
HasConfigurationViewModel = true;
|
||||
ConfigurationDialog = new PluginConfigurationDialog<WS281XConfigurationViewModel>();
|
||||
|
||||
var definitions = _settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
|
||||
if (definitions.Value == null)
|
||||
@ -54,10 +52,5 @@ namespace Artemis.Plugins.Devices.WS281X
|
||||
{
|
||||
// TODO: Remove the device provider from the surface
|
||||
}
|
||||
|
||||
public override PluginConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return new WS281XConfigurationViewModel(this, _settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.LayerEffect;
|
||||
using Artemis.Core.Plugins.LayerEffect.Abstract;
|
||||
using Artemis.Plugins.LayerEffects.Filter.ViewModels;
|
||||
using SkiaSharp;
|
||||
@ -9,12 +9,7 @@ namespace Artemis.Plugins.LayerEffects.Filter
|
||||
{
|
||||
public override void EnableLayerEffect()
|
||||
{
|
||||
HasConfigurationViewModel = true;
|
||||
}
|
||||
|
||||
public override EffectConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return new ColorMatrixConfigurationViewModel(this);
|
||||
ConfigurationDialog = new LayerEffectConfigurationDialog<ColorMatrixConfigurationViewModel>();
|
||||
}
|
||||
|
||||
public override void DisableLayerEffect()
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Modules;
|
||||
using Artemis.Plugins.Modules.General.DataModel;
|
||||
using Artemis.Plugins.Modules.General.DataModel.Windows;
|
||||
@ -18,6 +17,7 @@ namespace Artemis.Plugins.Modules.General
|
||||
DisplayName = "General";
|
||||
DisplayIcon = "AllInclusive";
|
||||
ExpandsDataModel = true;
|
||||
ModuleTabs = new List<ModuleTab> {new ModuleTab<GeneralViewModel>("General")};
|
||||
|
||||
DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTime.Now.AddDays(1), CurrentTimeUTC = DateTime.UtcNow.AddDays(1)});
|
||||
DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTime.Now.AddDays(2), CurrentTimeUTC = DateTime.UtcNow.AddDays(2)});
|
||||
@ -46,11 +46,6 @@ namespace Artemis.Plugins.Modules.General
|
||||
base.Update(deltaTime);
|
||||
}
|
||||
|
||||
public override IEnumerable<ModuleTab> GetModuleTabs()
|
||||
{
|
||||
return new List<ModuleTab> {new ModuleTab<GeneralViewModel>("General")};
|
||||
}
|
||||
|
||||
#region Open windows
|
||||
|
||||
public void UpdateCurrentWindow()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user