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