diff --git a/src/Artemis.Core/Ninject/PluginSettingsProvider.cs b/src/Artemis.Core/Ninject/PluginSettingsProvider.cs index c2f780f6d..96aef2db4 100644 --- a/src/Artemis.Core/Ninject/PluginSettingsProvider.cs +++ b/src/Artemis.Core/Ninject/PluginSettingsProvider.cs @@ -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 { 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); } diff --git a/src/Artemis.Core/Plugins/Abstract/DeviceProvider.cs b/src/Artemis.Core/Plugins/Abstract/DeviceProvider.cs index d9bde1593..cf17cd9e3 100644 --- a/src/Artemis.Core/Plugins/Abstract/DeviceProvider.cs +++ b/src/Artemis.Core/Plugins/Abstract/DeviceProvider.cs @@ -13,21 +13,38 @@ namespace Artemis.Core.Plugins.Abstract /// public abstract class DeviceProvider : Plugin { + /// + /// Creates a new instance of the class + /// + /// protected DeviceProvider(IRGBDeviceProvider rgbDeviceProvider) { RgbDeviceProvider = rgbDeviceProvider ?? throw new ArgumentNullException(nameof(rgbDeviceProvider)); } + /// + /// The RGB.NET device provider backing this Artemis device provider + /// public IRGBDeviceProvider RgbDeviceProvider { get; } + /// + /// TODO: Make internal while still injecting. + /// A logger used by the device provider internally, ignore this + /// [Inject] public ILogger Logger { get; set; } + /// public override void DisablePlugin() { // Does not happen with device providers, they require Artemis to restart } + /// + /// + /// + /// + /// protected void ResolveAbsolutePath(Type type, object sender, ResolvePathEventArgs e) { if (sender.GetType() == type || sender.GetType().IsGenericType(type)) diff --git a/src/Artemis.Core/Plugins/Abstract/LayerBrushProvider.cs b/src/Artemis.Core/Plugins/Abstract/LayerBrushProvider.cs index f44945385..c50847758 100644 --- a/src/Artemis.Core/Plugins/Abstract/LayerBrushProvider.cs +++ b/src/Artemis.Core/Plugins/Abstract/LayerBrushProvider.cs @@ -7,14 +7,16 @@ using Artemis.Core.Plugins.LayerBrush.Abstract; namespace Artemis.Core.Plugins.Abstract { - /// /// - /// Allows you to create one or more s usable by profile layers. + /// Allows you to create one or more s usable by profile layers. /// public abstract class LayerBrushProvider : Plugin { private readonly List _layerBrushDescriptors; + /// + /// Allows you to register one or more s usable by profile layers. + /// protected LayerBrushProvider() { _layerBrushDescriptors = new List(); diff --git a/src/Artemis.Core/Plugins/Abstract/LayerEffectProvider.cs b/src/Artemis.Core/Plugins/Abstract/LayerEffectProvider.cs index 2d2d0a188..367e2a23b 100644 --- a/src/Artemis.Core/Plugins/Abstract/LayerEffectProvider.cs +++ b/src/Artemis.Core/Plugins/Abstract/LayerEffectProvider.cs @@ -7,14 +7,16 @@ using Artemis.Core.Plugins.LayerEffect.Abstract; namespace Artemis.Core.Plugins.Abstract { - /// /// - /// Allows you to create one or more s usable by profile layers. + /// Allows you to register one or more s usable by profile layers. /// public abstract class LayerEffectProvider : Plugin { private readonly List _layerEffectDescriptors; + /// + /// Allows you to register one or more s usable by profile layers. + /// protected LayerEffectProvider() { _layerEffectDescriptors = new List(); diff --git a/src/Artemis.Core/Plugins/Abstract/Module.cs b/src/Artemis.Core/Plugins/Abstract/Module.cs index dd4754745..71a43340d 100644 --- a/src/Artemis.Core/Plugins/Abstract/Module.cs +++ b/src/Artemis.Core/Plugins/Abstract/Module.cs @@ -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; /// - /// Gets or sets the current priority category of this module + /// Gets the current priority category of this module /// - public ModulePriorityCategory PriorityCategory { get; set; } + public ModulePriorityCategory PriorityCategory { get; internal set; } /// - /// Gets or sets the current priority of this module within its priority category + /// Gets the current priority of this module within its priority category /// - 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; } + /// + /// A list of custom module tabs that show in the UI + /// + public IEnumerable ModuleTabs { get; protected set; } + /// /// Called each frame when the module must update /// @@ -133,12 +137,6 @@ namespace Artemis.Core.Plugins.Abstract /// public abstract void Render(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo); - /// - /// 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 - /// - /// - public abstract IEnumerable GetModuleTabs(); - /// /// Called when the are met /// @@ -194,6 +192,9 @@ namespace Artemis.Core.Plugins.Abstract } } + /// + /// Describes in what way the activation requirements of a module must be met + /// public enum ActivationRequirementType { /// @@ -207,6 +208,9 @@ namespace Artemis.Core.Plugins.Abstract All } + /// + /// Describes the priority category of a module + /// public enum ModulePriorityCategory { /// diff --git a/src/Artemis.Core/Plugins/Abstract/Plugin.cs b/src/Artemis.Core/Plugins/Abstract/Plugin.cs index e96463090..209a3015b 100644 --- a/src/Artemis.Core/Plugins/Abstract/Plugin.cs +++ b/src/Artemis.Core/Plugins/Abstract/Plugin.cs @@ -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,19 +11,22 @@ namespace Artemis.Core.Plugins.Abstract /// public abstract class Plugin : IDisposable { + /// + /// Gets the plugin info related to this plugin + /// public PluginInfo PluginInfo { get; internal set; } /// /// Gets whether the plugin is enabled /// public bool Enabled { get; private set; } - + /// - /// Gets or sets whether this plugin has a configuration view model. - /// If set to true, 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 /// - public bool HasConfigurationViewModel { get; protected set; } + public PluginConfigurationDialog ConfigurationDialog { get; protected set; } + /// public void Dispose() { DisablePlugin(); @@ -40,16 +42,6 @@ namespace Artemis.Core.Plugins.Abstract /// public abstract void DisablePlugin(); - /// - /// Called when the plugins configuration window is opened from the UI. The UI will only attempt to open if - /// is set to True. - /// - /// - 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 + /// + /// Occurs when the plugin is enabled + /// public event EventHandler PluginEnabled; + + /// + /// Occurs when the plugin is disabled + /// public event EventHandler PluginDisabled; + /// + /// Triggers the PluginEnabled event + /// protected virtual void OnPluginEnabled() { PluginEnabled?.Invoke(this, EventArgs.Empty); } + /// + /// Triggers the PluginDisabled event + /// protected virtual void OnPluginDisabled() { PluginDisabled?.Invoke(this, EventArgs.Empty); diff --git a/src/Artemis.Core/Plugins/Abstract/PluginConfigurationDialog.cs b/src/Artemis.Core/Plugins/Abstract/PluginConfigurationDialog.cs new file mode 100644 index 000000000..90fd5598e --- /dev/null +++ b/src/Artemis.Core/Plugins/Abstract/PluginConfigurationDialog.cs @@ -0,0 +1,28 @@ +using System; +using Artemis.Core.Plugins.Abstract.ViewModels; + +namespace Artemis.Core.Plugins.Abstract +{ + /// + public class PluginConfigurationDialog : PluginConfigurationDialog where T : PluginConfigurationViewModel + { + /// + public override Type Type => typeof(T); + } + + /// + /// Describes a configuration dialog for a specific plugin + /// + public abstract class PluginConfigurationDialog + { + /// + /// The layer brush this dialog belongs to + /// + internal Plugin Plugin { get; set; } + + /// + /// The type of view model the tab contains + /// + public abstract Type Type { get; } + } +} \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerBrush/Abstract/BaseLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrush/Abstract/BaseLayerBrush.cs index 38bbd2c13..9e2d03aad 100644 --- a/src/Artemis.Core/Plugins/LayerBrush/Abstract/BaseLayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrush/Abstract/BaseLayerBrush.cs @@ -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); } + /// + /// Gets or sets a configuration dialog complementing the regular properties + /// + public LayerBrushConfigurationDialog ConfigurationDialog + { + get => _configurationDialog; + protected set => SetAndNotify(ref _configurationDialog, value); + } + /// /// Gets the type of layer brush /// @@ -71,17 +80,12 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract } } - /// - /// Gets or sets whether this plugin has a configuration view model. - /// If set to true, will be called when the plugin is configured from the UI. - /// - public bool HasConfigurationViewModel { get; protected set; } - + /// public void Dispose() { DisableLayerBrush(); BaseProperties.Dispose(); - + Dispose(true); GC.SuppressFinalize(this); } @@ -102,16 +106,6 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract /// Seconds passed since last update public abstract void Update(double deltaTime); - /// - /// Called when the brush configuration window is opened from the UI. The UI will only attempt to open if - /// is set to True. - /// - /// - 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 and RgbNetLayerBrush outside the core internal abstract void Initialize(IRenderElementService renderElementService); @@ -123,9 +117,19 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract } } + /// + /// Describes the type of a layer brush + /// public enum LayerBrushType { + /// + /// A regular brush that users Artemis' SkiaSharp-based rendering engine + /// Regular, + + /// + /// An RGB.NET brush that uses RGB.NET's per-LED rendering engine. + /// RgbNet } } \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerBrush/Abstract/RgbNetLayerBrush.cs b/src/Artemis.Core/Plugins/LayerBrush/Abstract/RgbNetLayerBrush.cs index 6e38a6913..c92044a58 100644 --- a/src/Artemis.Core/Plugins/LayerBrush/Abstract/RgbNetLayerBrush.cs +++ b/src/Artemis.Core/Plugins/LayerBrush/Abstract/RgbNetLayerBrush.cs @@ -8,8 +8,16 @@ using SkiaSharp; namespace Artemis.Core.Plugins.LayerBrush.Abstract { + /// + /// An RGB.NET brush that uses RGB.NET's per-LED rendering engine. + /// Note: This brush type always renders on top of regular brushes + /// + /// public abstract class RgbNetLayerBrush : PropertiesLayerBrush where T : LayerPropertyGroup { + /// + /// Creates a new instance of the class + /// protected RgbNetLayerBrush() { BrushType = LayerBrushType.RgbNet; diff --git a/src/Artemis.Core/Plugins/LayerBrush/LayerBrushConfigurationDialog.cs b/src/Artemis.Core/Plugins/LayerBrush/LayerBrushConfigurationDialog.cs new file mode 100644 index 000000000..b6747ee48 --- /dev/null +++ b/src/Artemis.Core/Plugins/LayerBrush/LayerBrushConfigurationDialog.cs @@ -0,0 +1,29 @@ +using System; +using Artemis.Core.Plugins.Abstract.ViewModels; +using Artemis.Core.Plugins.LayerBrush.Abstract; + +namespace Artemis.Core.Plugins.LayerBrush +{ + /// + public class LayerBrushConfigurationDialog : LayerBrushConfigurationDialog where T : BrushConfigurationViewModel + { + /// + public override Type Type => typeof(T); + } + + /// + /// Describes a UI tab for a layer brush + /// + public abstract class LayerBrushConfigurationDialog + { + /// + /// The layer brush this dialog belongs to + /// + internal BaseLayerBrush LayerBrush { get; set; } + + /// + /// The type of view model the tab contains + /// + public abstract Type Type { get; } + } +} \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerBrush/LayerBrushDescriptor.cs b/src/Artemis.Core/Plugins/LayerBrush/LayerBrushDescriptor.cs index 9e05da117..25e5bfe38 100644 --- a/src/Artemis.Core/Plugins/LayerBrush/LayerBrushDescriptor.cs +++ b/src/Artemis.Core/Plugins/LayerBrush/LayerBrushDescriptor.cs @@ -3,6 +3,9 @@ using Artemis.Core.Plugins.Abstract; namespace Artemis.Core.Plugins.LayerBrush { + /// + /// A class that describes a layer brush + /// 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; } + /// + /// The name that is displayed in the UI + /// public string DisplayName { get; } + + /// + /// The description that is displayed in the UI + /// public string Description { get; } + + /// + /// The Material icon to display in the UI, a full reference can be found + /// here + /// public string Icon { get; } + + /// + /// The type of the layer brush + /// public Type LayerBrushType { get; } + + /// + /// The plugin that provided this + /// public LayerBrushProvider LayerBrushProvider { get; } } } \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerEffect/Abstract/BaseLayerEffect.cs b/src/Artemis.Core/Plugins/LayerEffect/Abstract/BaseLayerEffect.cs index 6913defa4..0c47944e3 100644 --- a/src/Artemis.Core/Plugins/LayerEffect/Abstract/BaseLayerEffect.cs +++ b/src/Artemis.Core/Plugins/LayerEffect/Abstract/BaseLayerEffect.cs @@ -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 /// 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; /// /// Gets the unique ID of this effect @@ -77,7 +77,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract } /// - /// Gets the descriptor of this effect + /// Gets the that registered this effect /// public LayerEffectDescriptor Descriptor { @@ -85,6 +85,15 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract internal set => SetAndNotify(ref _descriptor, value); } + /// + /// Gets or sets a configuration dialog complementing the regular properties + /// + public LayerEffectConfigurationDialog ConfigurationDialog + { + get => _configurationDialog; + protected set => SetAndNotify(ref _configurationDialog, value); + } + /// /// Gets the plugin info that defined this effect /// @@ -97,12 +106,7 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract internal string PropertyRootPath => $"LayerEffect.{EntityId}.{GetType().Name}."; - /// - /// Gets or sets whether this plugin has a configuration view model. - /// If set to true, will be called when the plugin is configured from the UI. - /// - public bool HasConfigurationViewModel { get; protected set; } - + /// 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 outside the core internal abstract void Initialize(IRenderElementService renderElementService); - - - /// - /// Called when the effect configuration window is opened from the UI. The UI will only attempt to open if - /// is set to True. - /// - /// - public virtual EffectConfigurationViewModel GetConfigurationViewModel() - { - return null; - } } } \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerEffect/LayerEffectConfigurationDialog.cs b/src/Artemis.Core/Plugins/LayerEffect/LayerEffectConfigurationDialog.cs new file mode 100644 index 000000000..f51684b17 --- /dev/null +++ b/src/Artemis.Core/Plugins/LayerEffect/LayerEffectConfigurationDialog.cs @@ -0,0 +1,29 @@ +using System; +using Artemis.Core.Plugins.Abstract.ViewModels; +using Artemis.Core.Plugins.LayerEffect.Abstract; + +namespace Artemis.Core.Plugins.LayerEffect +{ + /// + public class LayerEffectConfigurationDialog : LayerEffectConfigurationDialog where T : EffectConfigurationViewModel + { + /// + public override Type Type => typeof(T); + } + + /// + /// Describes a UI tab for a specific layer effect + /// + public abstract class LayerEffectConfigurationDialog + { + /// + /// The layer effect this dialog belongs to + /// + internal BaseLayerEffect LayerEffect { get; set; } + + /// + /// The type of view model the tab contains + /// + public abstract Type Type { get; } + } +} \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/LayerEffect/LayerEffectDescriptor.cs b/src/Artemis.Core/Plugins/LayerEffect/LayerEffectDescriptor.cs index 50da1da2c..58d5a39eb 100644 --- a/src/Artemis.Core/Plugins/LayerEffect/LayerEffectDescriptor.cs +++ b/src/Artemis.Core/Plugins/LayerEffect/LayerEffectDescriptor.cs @@ -3,6 +3,9 @@ using Artemis.Core.Plugins.Abstract; namespace Artemis.Core.Plugins.LayerEffect { + /// + /// A class that describes a layer effect + /// 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; } + /// + /// The name that is displayed in the UI + /// public string DisplayName { get; } + + /// + /// The description that is displayed in the UI + /// public string Description { get; } + + /// + /// The Material icon to display in the UI, a full reference can be found + /// here + /// public string Icon { get; } + + /// + /// The type of the layer effect + /// public Type LayerEffectType { get; } + + /// + /// The plugin that provided this + /// public LayerEffectProvider LayerEffectProvider { get; } } } \ No newline at end of file diff --git a/src/Artemis.Core/Plugins/Models/PluginSettings.cs b/src/Artemis.Core/Plugins/Models/PluginSettings.cs index ebd3f8788..f23db2d34 100644 --- a/src/Artemis.Core/Plugins/Models/PluginSettings.cs +++ b/src/Artemis.Core/Plugins/Models/PluginSettings.cs @@ -46,6 +46,12 @@ namespace Artemis.Core.Plugins.Models } var pluginSetting = new PluginSetting(_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; } diff --git a/src/Artemis.Core/Services/Interfaces/IPluginService.cs b/src/Artemis.Core/Services/Interfaces/IPluginService.cs index ce2915738..e8b88943a 100644 --- a/src/Artemis.Core/Services/Interfaces/IPluginService.cs +++ b/src/Artemis.Core/Services/Interfaces/IPluginService.cs @@ -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 a list of plug instances of type List GetPluginsOfType() where T : Plugin; - Plugin GetDevicePlugin(IRGBDevice device); + /// + /// Gets the plugin that provided the specified assembly + /// + /// + /// + Plugin GetPluginByAssembly(Assembly assembly); + + /// + /// Gets the plugin that defined the specified device + /// + /// + /// + Plugin GetPluginByDevice(IRGBDevice device); #region Events diff --git a/src/Artemis.Core/Services/PluginService.cs b/src/Artemis.Core/Services/PluginService.cs index 1bc59c87a..c80bf38de 100644 --- a/src/Artemis.Core/Services/PluginService.cs +++ b/src/Artemis.Core/Services/PluginService.cs @@ -46,10 +46,8 @@ namespace Artemis.Core.Services Directory.CreateDirectory(Constants.DataFolder + "plugins"); } - /// public bool LoadingPlugins { get; private set; } - /// public void CopyBuiltInPlugins() { OnCopyingBuildInPlugins(); @@ -161,7 +159,6 @@ namespace Artemis.Core.Services } } - /// public void UnloadPlugins() { lock (_plugins) @@ -181,7 +178,6 @@ namespace Artemis.Core.Services } } - /// public void LoadPlugin(PluginInfo pluginInfo) { lock (_plugins) @@ -256,7 +252,6 @@ namespace Artemis.Core.Services } } - /// public void UnloadPlugin(PluginInfo pluginInfo) { lock (_plugins) @@ -347,25 +342,27 @@ namespace Artemis.Core.Services OnPluginDisabled(new PluginEventArgs(plugin.PluginInfo)); } - /// public PluginInfo GetPluginInfo(Plugin plugin) { return _plugins.FirstOrDefault(p => p.Instance == plugin); } - /// public List GetAllPluginInfo() { return new List(_plugins); } - /// public List GetPluginsOfType() 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().First(d => d.RgbDeviceProvider.Devices != null && d.RgbDeviceProvider.Devices.Contains(rgbDevice)); } diff --git a/src/Artemis.Core/Services/Storage/SurfaceService.cs b/src/Artemis.Core/Services/Storage/SurfaceService.cs index dc4dc2145..fc3d2cea3 100644 --- a/src/Artemis.Core/Services/Storage/SurfaceService.cs +++ b/src/Artemis.Core/Services/Storage/SurfaceService.cs @@ -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); } diff --git a/src/Artemis.Core/Utilities/IntroAnimation.cs b/src/Artemis.Core/Utilities/IntroAnimation.cs index 76dae9def..77541c8bb 100644 --- a/src/Artemis.Core/Utilities/IntroAnimation.cs +++ b/src/Artemis.Core/Utilities/IntroAnimation.cs @@ -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 GetModuleTabs() - { - throw new NotImplementedException(); - } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ModuleRootViewModel.cs b/src/Artemis.UI/Screens/Module/ModuleRootViewModel.cs index 907e0c2e9..73659603a 100644 --- a/src/Artemis.UI/Screens/Module/ModuleRootViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ModuleRootViewModel.cs @@ -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(Module.ModuleTabs); foreach (var moduleTab in moduleTabs.Where(m => m != null)) { var module = new ConstructorArgument("module", Module); diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreePropertyGroupView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreePropertyGroupView.xaml index 83a3f8868..406333f4d 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreePropertyGroupView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/Tree/TreePropertyGroupView.xaml @@ -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}}"> @@ -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}}">