diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index 7e8af7b5f..0d71cb1fa 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -109,13 +109,14 @@
-
-
-
+
+
+
-
-
+
+
+
@@ -134,6 +135,7 @@
+
diff --git a/src/Artemis.Core/Plugins/Abstract/DataModelExpansion.cs b/src/Artemis.Core/Plugins/Abstract/DataModelExpansion.cs
new file mode 100644
index 000000000..60ebf3b37
--- /dev/null
+++ b/src/Artemis.Core/Plugins/Abstract/DataModelExpansion.cs
@@ -0,0 +1,17 @@
+using Artemis.Core.Plugins.Models;
+
+namespace Artemis.Core.Plugins.Abstract
+{
+ ///
+ ///
+ /// Allows you to expand the application-wide datamodel
+ ///
+ public abstract class DataModelExpansion : Plugin
+ {
+ protected DataModelExpansion(PluginInfo pluginInfo) : base(pluginInfo)
+ {
+ }
+
+ public abstract void Update(double deltaTime);
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Abstract/Device.cs b/src/Artemis.Core/Plugins/Abstract/Device.cs
new file mode 100644
index 000000000..a945b9cab
--- /dev/null
+++ b/src/Artemis.Core/Plugins/Abstract/Device.cs
@@ -0,0 +1,15 @@
+using Artemis.Core.Plugins.Models;
+
+namespace Artemis.Core.Plugins.Abstract
+{
+ ///
+ ///
+ /// Allows you to implement your own RGB device
+ ///
+ public abstract class Device : Plugin
+ {
+ protected Device(PluginInfo pluginInfo) : base(pluginInfo)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Interfaces/ILayerType.cs b/src/Artemis.Core/Plugins/Abstract/LayerType.cs
similarity index 54%
rename from src/Artemis.Core/Plugins/Interfaces/ILayerType.cs
rename to src/Artemis.Core/Plugins/Abstract/LayerType.cs
index 5391f2a10..b20e57d98 100644
--- a/src/Artemis.Core/Plugins/Interfaces/ILayerType.cs
+++ b/src/Artemis.Core/Plugins/Abstract/LayerType.cs
@@ -1,24 +1,29 @@
using System.Drawing;
+using Artemis.Core.Plugins.Models;
using Artemis.Core.ProfileElements;
using RGB.NET.Core;
-namespace Artemis.Core.Plugins.Interfaces
+namespace Artemis.Core.Plugins.Abstract
{
///
///
/// Allows you to create your own layer type
///
- public interface ILayerType : IPlugin
+ public abstract class LayerType : Plugin
{
+ protected LayerType(PluginInfo pluginInfo) : base(pluginInfo)
+ {
+ }
+
///
/// Updates the layer type
///
///
- void Update(Layer layer);
+ public abstract void Update(Layer layer);
///
/// Renders the layer type
///
- void Render(Layer device, RGBSurface surface, Graphics graphics);
+ public abstract void Render(Layer device, RGBSurface surface, Graphics graphics);
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Interfaces/IModule.cs b/src/Artemis.Core/Plugins/Abstract/Module.cs
similarity index 68%
rename from src/Artemis.Core/Plugins/Interfaces/IModule.cs
rename to src/Artemis.Core/Plugins/Abstract/Module.cs
index d397b09b9..2b0c592c2 100644
--- a/src/Artemis.Core/Plugins/Interfaces/IModule.cs
+++ b/src/Artemis.Core/Plugins/Abstract/Module.cs
@@ -1,31 +1,36 @@
using System.Drawing;
+using Artemis.Core.Plugins.Models;
using RGB.NET.Core;
using Stylet;
-namespace Artemis.Core.Plugins.Interfaces
+namespace Artemis.Core.Plugins.Abstract
{
///
///
/// Allows you to add support for new games/applications
///
- public interface IModule : IPlugin
+ public abstract class Module : Plugin
{
+ protected Module(PluginInfo pluginInfo) : base(pluginInfo)
+ {
+ }
+
///
/// The modules display name that's shown in the menu
///
- string DisplayName { get; }
+ public string DisplayName { get; protected set; }
///
/// Whether or not this module expands upon the main data model. If set to true any data in main data model can be
/// accessed by profiles in this module
///
- bool ExpandsMainDataModel { get; }
+ public bool ExpandsMainDataModel { get; protected set; }
///
/// Called each frame when the module must update
///
/// Time since the last update
- void Update(double deltaTime);
+ public abstract void Update(double deltaTime);
///
/// Called each frame when the module must render
@@ -33,12 +38,12 @@ namespace Artemis.Core.Plugins.Interfaces
/// Time since the last render
/// The RGB Surface to render to
///
- void Render(double deltaTime, RGBSurface surface, Graphics graphics);
+ public abstract void Render(double deltaTime, RGBSurface surface, Graphics graphics);
///
/// Called when the module's main view is being shown
///
///
- IScreen GetMainViewModel();
+ public abstract IScreen GetMainViewModel();
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Abstract/ModuleDataModel.cs b/src/Artemis.Core/Plugins/Abstract/ModuleDataModel.cs
index d2ce723de..aef8fe778 100644
--- a/src/Artemis.Core/Plugins/Abstract/ModuleDataModel.cs
+++ b/src/Artemis.Core/Plugins/Abstract/ModuleDataModel.cs
@@ -1,14 +1,12 @@
-using Artemis.Core.Plugins.Interfaces;
-
-namespace Artemis.Core.Plugins.Abstract
+namespace Artemis.Core.Plugins.Abstract
{
public abstract class ModuleDataModel
{
- protected ModuleDataModel(IModule module)
+ protected ModuleDataModel(Module module)
{
Module = module;
}
- public IModule Module { get; }
+ public Module Module { get; }
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Abstract/ModuleViewModel.cs b/src/Artemis.Core/Plugins/Abstract/ModuleViewModel.cs
index 10ba6fe62..559f5ed42 100644
--- a/src/Artemis.Core/Plugins/Abstract/ModuleViewModel.cs
+++ b/src/Artemis.Core/Plugins/Abstract/ModuleViewModel.cs
@@ -1,15 +1,14 @@
-using Artemis.Core.Plugins.Interfaces;
-using Stylet;
+using Stylet;
namespace Artemis.Core.Plugins.Abstract
{
public abstract class ModuleViewModel : Screen
{
- protected ModuleViewModel(IModule module)
+ protected ModuleViewModel(Module module)
{
Module = module;
}
- public IModule Module { get; }
+ public Module Module { get; }
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Abstract/Plugin.cs b/src/Artemis.Core/Plugins/Abstract/Plugin.cs
new file mode 100644
index 000000000..7306880e1
--- /dev/null
+++ b/src/Artemis.Core/Plugins/Abstract/Plugin.cs
@@ -0,0 +1,35 @@
+using System;
+using Artemis.Core.Plugins.Models;
+
+namespace Artemis.Core.Plugins.Abstract
+{
+ ///
+ ///
+ /// This is the base plugin type, use the other interfaces such as Module to create plugins
+ ///
+ public abstract class Plugin : IDisposable
+ {
+ internal Plugin(PluginInfo pluginInfo)
+ {
+ PluginInfo = pluginInfo;
+ }
+
+ public PluginInfo PluginInfo { get; internal set; }
+
+ ///
+ /// Called when the plugin is activated
+ ///
+ public abstract void EnablePlugin();
+
+ ///
+ /// Called when the plugin is deactivated
+ ///
+ public abstract void DisablePlugin();
+
+ ///
+ ///
+ /// Called when the plugin is unloaded, clean up any unmanaged resources here
+ ///
+ public abstract void Dispose();
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Abstract/ProfileModule.cs b/src/Artemis.Core/Plugins/Abstract/ProfileModule.cs
index 8cce411ae..648fe98b8 100644
--- a/src/Artemis.Core/Plugins/Abstract/ProfileModule.cs
+++ b/src/Artemis.Core/Plugins/Abstract/ProfileModule.cs
@@ -1,25 +1,21 @@
using System;
using System.Drawing;
-using Artemis.Core.Plugins.Interfaces;
+using Artemis.Core.Plugins.Models;
using Artemis.Core.ProfileElements;
using RGB.NET.Core;
-using Stylet;
namespace Artemis.Core.Plugins.Abstract
{
- public abstract class ProfileModule : IModule
+ public abstract class ProfileModule : Module
{
+ protected ProfileModule(PluginInfo pluginInfo) : base(pluginInfo)
+ {
+ }
+
public Profile ActiveProfile { get; private set; }
///
- public abstract string DisplayName { get; }
-
- ///
- public abstract bool ExpandsMainDataModel { get; }
-
-
- ///
- public virtual void Update(double deltaTime)
+ public override void Update(double deltaTime)
{
lock (this)
{
@@ -29,7 +25,7 @@ namespace Artemis.Core.Plugins.Abstract
}
///
- public virtual void Render(double deltaTime, RGBSurface surface, Graphics graphics)
+ public override void Render(double deltaTime, RGBSurface surface, Graphics graphics)
{
lock (this)
{
@@ -38,18 +34,6 @@ namespace Artemis.Core.Plugins.Abstract
}
}
- ///
- public abstract IScreen GetMainViewModel();
-
- ///
- public abstract void EnablePlugin();
-
- ///
- public abstract void DisablePlugin();
-
- ///
- public abstract void Dispose();
-
public void ChangeActiveProfile(Profile profile)
{
lock (this)
diff --git a/src/Artemis.Core/Plugins/Interfaces/IDataModelExpansion.cs b/src/Artemis.Core/Plugins/Interfaces/IDataModelExpansion.cs
deleted file mode 100644
index f7fdd593a..000000000
--- a/src/Artemis.Core/Plugins/Interfaces/IDataModelExpansion.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace Artemis.Core.Plugins.Interfaces
-{
- ///
- ///
- /// Allows you to expand the application-wide datamodel
- ///
- public interface IDataModelExpansion : IPlugin
- {
- void Update(double deltaTime);
- }
-}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Interfaces/IDevice.cs b/src/Artemis.Core/Plugins/Interfaces/IDevice.cs
deleted file mode 100644
index 47ae0c773..000000000
--- a/src/Artemis.Core/Plugins/Interfaces/IDevice.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace Artemis.Core.Plugins.Interfaces
-{
- ///
- ///
- /// Allows you to implement your own RGB device
- ///
- public interface IDevice : IPlugin
- {
- }
-}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Interfaces/IPlugin.cs b/src/Artemis.Core/Plugins/Interfaces/IPlugin.cs
deleted file mode 100644
index c1a703cee..000000000
--- a/src/Artemis.Core/Plugins/Interfaces/IPlugin.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System;
-
-namespace Artemis.Core.Plugins.Interfaces
-{
- ///
- ///
- /// This is the base plugin type, use the other interfaces such as IModule to create plugins
- ///
- public interface IPlugin : IDisposable
- {
- ///
- /// Called when the plugin is activated
- ///
- void EnablePlugin();
-
-
- ///
- /// Called when the plugin is deactivated
- ///
- void DisablePlugin();
- }
-}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Models/PluginInfo.cs b/src/Artemis.Core/Plugins/Models/PluginInfo.cs
index d2746ca07..956ca67b6 100644
--- a/src/Artemis.Core/Plugins/Models/PluginInfo.cs
+++ b/src/Artemis.Core/Plugins/Models/PluginInfo.cs
@@ -1,7 +1,7 @@
using System;
using System.IO;
using AppDomainToolkit;
-using Artemis.Core.Plugins.Interfaces;
+using Artemis.Core.Plugins.Abstract;
using Newtonsoft.Json;
namespace Artemis.Core.Plugins.Models
@@ -15,40 +15,40 @@ namespace Artemis.Core.Plugins.Models
///
/// The plugins GUID
///
- public Guid Guid { get; set; }
+ public Guid Guid { get; internal set; }
///
/// The name of the plugin
///
- public string Name { get; set; }
+ public string Name { get; internal set; }
///
/// The version of the plugin
///
- public string Version { get; set; }
+ public string Version { get; internal set; }
///
- /// The main entry DLL, should contain a class implementing IPlugin
+ /// The main entry DLL, should contain a class implementing Plugin
///
- public string Main { get; set; }
+ public string Main { get; internal set; }
///
/// The plugins root directory
///
[JsonIgnore]
- public DirectoryInfo Directory { get; set; }
+ public DirectoryInfo Directory { get; internal set; }
///
- /// A reference to the type implementing IPlugin, available after successful load
+ /// A reference to the type implementing Plugin, available after successful load
///
[JsonIgnore]
- public IPlugin Instance { get; set; }
+ public Plugin Instance { get; internal set; }
///
/// Indicates whether the user enabled the plugin or not
///
[JsonIgnore]
- public bool Enabled { get; set; }
+ public bool Enabled { get; internal set; }
///
/// The AppDomain context of this plugin
diff --git a/src/Artemis.Core/Plugins/Models/PluginSettings.cs b/src/Artemis.Core/Plugins/Models/PluginSettings.cs
new file mode 100644
index 000000000..010521cf2
--- /dev/null
+++ b/src/Artemis.Core/Plugins/Models/PluginSettings.cs
@@ -0,0 +1,26 @@
+using Artemis.Storage.Repositories;
+
+namespace Artemis.Core.Plugins.Models
+{
+ public class PluginSettings
+ {
+ private readonly PluginInfo _pluginInfo;
+ private readonly SettingRepository _settingRepository;
+
+ internal PluginSettings(PluginInfo pluginInfo, SettingRepository settingRepository)
+ {
+ _pluginInfo = pluginInfo;
+ _settingRepository = settingRepository;
+ }
+
+ public bool HasSettingChanged(string settingName)
+ {
+ return false;
+ }
+
+ public bool HasAnySettingChanged()
+ {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.Core/ProfileElements/Layer.cs b/src/Artemis.Core/ProfileElements/Layer.cs
index 7cd3a612a..5bb680113 100644
--- a/src/Artemis.Core/ProfileElements/Layer.cs
+++ b/src/Artemis.Core/ProfileElements/Layer.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Interfaces;
using Artemis.Core.ProfileElements.Interfaces;
using Artemis.Core.Services.Interfaces;
@@ -18,7 +19,7 @@ namespace Artemis.Core.ProfileElements
}
public Profile Profile { get; }
- public ILayerType LayerType { get; private set; }
+ public LayerType LayerType { get; private set; }
public ILayerTypeConfiguration LayerTypeConfiguration { get; set; }
public List Children { get; set; }
public int Order { get; set; }
@@ -58,13 +59,15 @@ namespace Artemis.Core.ProfileElements
return layer;
}
- public void UpdateLayerType(ILayerType layerType)
+ public void UpdateLayerType(LayerType layerType)
{
if (LayerType != null)
+ {
lock (LayerType)
{
LayerType.Dispose();
}
+ }
LayerType = layerType;
}
diff --git a/src/Artemis.Core/Services/CoreService.cs b/src/Artemis.Core/Services/CoreService.cs
index f4b1ebd6b..ce47d39c9 100644
--- a/src/Artemis.Core/Services/CoreService.cs
+++ b/src/Artemis.Core/Services/CoreService.cs
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using Artemis.Core.Exceptions;
-using Artemis.Core.Plugins.Interfaces;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services.Interfaces;
using RGB.NET.Core;
using Color = System.Drawing.Color;
@@ -47,7 +47,7 @@ namespace Artemis.Core.Services
{
try
{
- var modules = _pluginService.GetPluginsOfType();
+ var modules = _pluginService.GetPluginsOfType();
// Update all active modules
foreach (var module in modules)
diff --git a/src/Artemis.Core/Services/Interfaces/IMainDataModelService.cs b/src/Artemis.Core/Services/Interfaces/IMainDataModelService.cs
index 684f048b9..25ed1c2f4 100644
--- a/src/Artemis.Core/Services/Interfaces/IMainDataModelService.cs
+++ b/src/Artemis.Core/Services/Interfaces/IMainDataModelService.cs
@@ -1,4 +1,5 @@
using Artemis.Core.Models;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Interfaces;
namespace Artemis.Core.Services.Interfaces
@@ -15,13 +16,13 @@ namespace Artemis.Core.Services.Interfaces
/// Add an expansion to the datamodel to be available for use after the next update
///
///
- void AddExpansion(IDataModelExpansion dataModelExpansion);
+ void AddExpansion(DataModelExpansion dataModelExpansion);
///
/// Remove a previously added expansion so that it is no longer available and updated
///
///
- void RemoveExpansion(IDataModelExpansion dataModelExpansion);
+ void RemoveExpansion(DataModelExpansion dataModelExpansion);
///
/// Generates a data model description for the main datamodel including all it's expansions
diff --git a/src/Artemis.Core/Services/Interfaces/IPluginService.cs b/src/Artemis.Core/Services/Interfaces/IPluginService.cs
index ce31000e3..c51cd70db 100644
--- a/src/Artemis.Core/Services/Interfaces/IPluginService.cs
+++ b/src/Artemis.Core/Services/Interfaces/IPluginService.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Artemis.Core.Events;
-using Artemis.Core.Plugins.Interfaces;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
namespace Artemis.Core.Services.Interfaces
@@ -40,7 +40,7 @@ namespace Artemis.Core.Services.Interfaces
///
/// The plugin you want to find the plugin info for
/// The plugins PluginInfo
- PluginInfo GetPluginInfo(IPlugin plugin);
+ PluginInfo GetPluginInfo(Plugin plugin);
///
/// Gets the plugin info of all loaded plugins
@@ -53,14 +53,14 @@ namespace Artemis.Core.Services.Interfaces
///
/// The GUID of the layer type to find
/// An instance of the layer type
- ILayerType GetLayerTypeByGuid(Guid layerTypeGuid);
+ LayerType GetLayerTypeByGuid(Guid layerTypeGuid);
///
- /// Finds all enabled instances of type
+ /// Finds all enabled instances of type
///
- /// Either or a plugin type implementing
+ /// Either or a plugin type implementing
/// Returns a list of plug instances of type
- List GetPluginsOfType() where T : IPlugin;
+ List GetPluginsOfType() where T : Plugin;
#region Events
diff --git a/src/Artemis.Core/Services/MainDataModelService.cs b/src/Artemis.Core/Services/MainDataModelService.cs
index 4c3d2366e..16064da64 100644
--- a/src/Artemis.Core/Services/MainDataModelService.cs
+++ b/src/Artemis.Core/Services/MainDataModelService.cs
@@ -2,6 +2,7 @@
using System.Collections.ObjectModel;
using Artemis.Core.Exceptions;
using Artemis.Core.Models;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Interfaces;
using Artemis.Core.Services.Interfaces;
@@ -9,14 +10,14 @@ namespace Artemis.Core.Services
{
public class MainDataModelService : IMainDataModelService
{
- private readonly List _dataModelExpansions;
+ private readonly List _dataModelExpansions;
public MainDataModelService()
{
- _dataModelExpansions = new List();
+ _dataModelExpansions = new List();
}
- public ReadOnlyCollection DataModelExpansions
+ public ReadOnlyCollection DataModelExpansions
{
get
{
@@ -37,7 +38,7 @@ namespace Artemis.Core.Services
}
}
- public void AddExpansion(IDataModelExpansion dataModelExpansion)
+ public void AddExpansion(DataModelExpansion dataModelExpansion)
{
lock (_dataModelExpansions)
{
@@ -46,7 +47,7 @@ namespace Artemis.Core.Services
}
}
- public void RemoveExpansion(IDataModelExpansion dataModelExpansion)
+ public void RemoveExpansion(DataModelExpansion dataModelExpansion)
{
lock (_dataModelExpansions)
{
diff --git a/src/Artemis.Core/Services/PluginService.cs b/src/Artemis.Core/Services/PluginService.cs
index aa7e9a4b9..1af180d45 100644
--- a/src/Artemis.Core/Services/PluginService.cs
+++ b/src/Artemis.Core/Services/PluginService.cs
@@ -5,13 +5,14 @@ using System.Linq;
using AppDomainToolkit;
using Artemis.Core.Events;
using Artemis.Core.Exceptions;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Exceptions;
-using Artemis.Core.Plugins.Interfaces;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Newtonsoft.Json;
using Ninject;
using Ninject.Extensions.ChildKernel;
+using Ninject.Parameters;
namespace Artemis.Core.Services
{
@@ -88,10 +89,7 @@ namespace Artemis.Core.Services
lock (_plugins)
{
// Unload all plugins
- while (_plugins.Count > 0)
- {
- UnloadPlugin(_plugins[0]);
- }
+ while (_plugins.Count > 0) UnloadPlugin(_plugins[0]);
// Dispose the child kernel and therefore any leftover plugins instantiated with it
if (_childKernel != null)
@@ -119,7 +117,7 @@ namespace Artemis.Core.Services
if (!File.Exists(mainFile))
throw new ArtemisPluginException(pluginInfo, "Couldn't find the plugins main entry at " + mainFile);
- // Load the plugin, all types implementing IPlugin and register them with DI
+ // Load the plugin, all types implementing Plugin and register them with DI
var setupInfo = new AppDomainSetup
{
ApplicationName = pluginInfo.Guid.ToString(),
@@ -137,18 +135,19 @@ namespace Artemis.Core.Services
throw new ArtemisPluginException(pluginInfo, "Failed to load the plugins assembly", e);
}
- // Get the IPlugin implementation from the main assembly and if there is only one, instantiate it
+ // Get the Plugin implementation from the main assembly and if there is only one, instantiate it
var mainAssembly = pluginInfo.Context.Domain.GetAssemblies().First(a => a.Location == mainFile);
- var pluginTypes = mainAssembly.GetTypes().Where(t => typeof(IPlugin).IsAssignableFrom(t)).ToList();
+ var pluginTypes = mainAssembly.GetTypes().Where(t => typeof(Plugin).IsAssignableFrom(t)).ToList();
if (pluginTypes.Count > 1)
- throw new ArtemisPluginException(pluginInfo, $"Plugin contains {pluginTypes.Count} implementations of IPlugin, only 1 allowed");
+ throw new ArtemisPluginException(pluginInfo, $"Plugin contains {pluginTypes.Count} implementations of Plugin, only 1 allowed");
if (pluginTypes.Count == 0)
- throw new ArtemisPluginException(pluginInfo, "Plugin contains no implementation of IPlugin");
+ throw new ArtemisPluginException(pluginInfo, "Plugin contains no implementation of Plugin");
var pluginType = pluginTypes.Single();
try
{
- pluginInfo.Instance = (IPlugin) _childKernel.Get(pluginType);
+ var constructorArguments = new ConstructorArgument("pluginInfo", pluginInfo);
+ pluginInfo.Instance = (Plugin) _childKernel.Get(pluginType, constraint: null, constructorArguments);
}
catch (Exception e)
{
@@ -179,7 +178,7 @@ namespace Artemis.Core.Services
}
_childKernel.Unbind(pluginInfo.Instance.GetType());
-
+
pluginInfo.Instance.Dispose();
pluginInfo.Context.Dispose();
_plugins.Remove(pluginInfo);
@@ -189,7 +188,7 @@ namespace Artemis.Core.Services
}
///
- public PluginInfo GetPluginInfo(IPlugin plugin)
+ public PluginInfo GetPluginInfo(Plugin plugin)
{
lock (_plugins)
{
@@ -204,20 +203,20 @@ namespace Artemis.Core.Services
}
///
- public ILayerType GetLayerTypeByGuid(Guid layerTypeGuid)
+ public LayerType GetLayerTypeByGuid(Guid layerTypeGuid)
{
var pluginInfo = _plugins.FirstOrDefault(p => p.Guid == layerTypeGuid);
if (pluginInfo == null)
return null;
- if (!(pluginInfo.Instance is ILayerType layerType))
- throw new ArtemisPluginException(pluginInfo, "Plugin is expected to implement exactly one ILayerType");
+ if (!(pluginInfo.Instance is LayerType layerType))
+ throw new ArtemisPluginException(pluginInfo, "Plugin is expected to implement exactly one LayerType");
return layerType;
}
///
- public List GetPluginsOfType() where T : IPlugin
+ public List GetPluginsOfType() where T : Plugin
{
lock (_plugins)
{
diff --git a/src/Artemis.Core/Services/RgbService.cs b/src/Artemis.Core/Services/RgbService.cs
index 8dadac100..233942d6d 100644
--- a/src/Artemis.Core/Services/RgbService.cs
+++ b/src/Artemis.Core/Services/RgbService.cs
@@ -68,9 +68,7 @@ namespace Artemis.Core.Services
OnDeviceLoaded(new DeviceEventArgs(surfaceDevice));
}
else
- {
OnDeviceReloaded(new DeviceEventArgs(surfaceDevice));
- }
}
}
});
diff --git a/src/Artemis.Core/Services/SettingsService.cs b/src/Artemis.Core/Services/SettingsService.cs
new file mode 100644
index 000000000..4029a21c4
--- /dev/null
+++ b/src/Artemis.Core/Services/SettingsService.cs
@@ -0,0 +1,25 @@
+using Artemis.Core.Plugins.Models;
+using Artemis.Core.Services.Interfaces;
+using Artemis.Storage.Repositories;
+
+namespace Artemis.Core.Services
+{
+ public class SettingsService : ISettingsService
+ {
+ private SettingRepository _settingRepository;
+
+ public SettingsService()
+ {
+ _settingRepository = new SettingRepository();
+ }
+
+ public PluginSettings GetPluginSettings(PluginInfo pluginInfo)
+ {
+ return new PluginSettings(pluginInfo, _settingRepository);
+ }
+ }
+
+ public interface ISettingsService : IArtemisService
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.Plugins.LayerTypes.Brush/BrushLayerType.cs b/src/Artemis.Plugins.LayerTypes.Brush/BrushLayerType.cs
index d3f58068a..49687d99a 100644
--- a/src/Artemis.Plugins.LayerTypes.Brush/BrushLayerType.cs
+++ b/src/Artemis.Plugins.LayerTypes.Brush/BrushLayerType.cs
@@ -1,28 +1,28 @@
-using System;
-using System.Drawing;
-using Artemis.Core.Plugins.Interfaces;
+using System.Drawing;
+using Artemis.Core.Plugins.Abstract;
+using Artemis.Core.Plugins.Models;
using Artemis.Core.ProfileElements;
using QRCoder;
using RGB.NET.Core;
namespace Artemis.Plugins.LayerTypes.Brush
{
- public class BrushLayerType : ILayerType
+ public class BrushLayerType : LayerType
{
- public void Dispose()
+ public BrushLayerType(PluginInfo pluginInfo) : base(pluginInfo)
{
}
- public void EnablePlugin()
+ public override void EnablePlugin()
{
var qrGenerator = new QRCodeGenerator();
}
- public void DisablePlugin()
+ public override void DisablePlugin()
{
}
- public void Update(Layer layer)
+ public override void Update(Layer layer)
{
var config = layer.LayerTypeConfiguration as BrushConfiguration;
if (config == null)
@@ -31,7 +31,11 @@ namespace Artemis.Plugins.LayerTypes.Brush
// Update the brush
}
- public void Render(Layer device, RGBSurface surface, Graphics graphics)
+ public override void Render(Layer device, RGBSurface surface, Graphics graphics)
+ {
+ }
+
+ public override void Dispose()
{
}
}
diff --git a/src/Artemis.Plugins.Modules.General/GeneralDataModel.cs b/src/Artemis.Plugins.Modules.General/GeneralDataModel.cs
index 14e360b3c..fd990befb 100644
--- a/src/Artemis.Plugins.Modules.General/GeneralDataModel.cs
+++ b/src/Artemis.Plugins.Modules.General/GeneralDataModel.cs
@@ -6,7 +6,7 @@ namespace Artemis.Plugins.Modules.General
{
public class GeneralDataModel : ModuleDataModel
{
- public GeneralDataModel(IModule module) : base(module)
+ public GeneralDataModel(Module module) : base(module)
{
}
diff --git a/src/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Artemis.Plugins.Modules.General/GeneralModule.cs
index d73e0e4e6..67ea1ad87 100644
--- a/src/Artemis.Plugins.Modules.General/GeneralModule.cs
+++ b/src/Artemis.Plugins.Modules.General/GeneralModule.cs
@@ -1,8 +1,8 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Drawing;
using Artemis.Core;
-using Artemis.Core.Plugins.Interfaces;
+using Artemis.Core.Plugins.Abstract;
+using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Modules.General.ViewModels;
using QRCoder;
@@ -13,26 +13,33 @@ using Rectangle = System.Drawing.Rectangle;
namespace Artemis.Plugins.Modules.General
{
- public class GeneralModule : IModule
+ public class GeneralModule : Module
{
private readonly RGBSurface _surface;
private Dictionary _colors;
- public GeneralModule(IRgbService rgbService)
+ public GeneralModule(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo)
{
- var rgbService1 = rgbService;
- _surface = rgbService1.Surface;
- _colors = new Dictionary();
+ DisplayName = "General";
+ ExpandsMainDataModel = true;
- rgbService1.FinishedLoadedDevices += (sender, args) => PopulateColors();
+ _surface = rgbService.Surface;
+ _colors = new Dictionary();
+
+ rgbService.FinishedLoadedDevices += (sender, args) => PopulateColors();
}
- public string DisplayName => "General";
+ public override void EnablePlugin()
+ {
+ var qrGenerator = new QRCodeGenerator();
+ PopulateColors();
+ }
- // True since the main data model is all this module shows
- public bool ExpandsMainDataModel => true;
+ public override void DisablePlugin()
+ {
+ }
- public void Update(double deltaTime)
+ public override void Update(double deltaTime)
{
if (_colors == null)
return;
@@ -41,7 +48,7 @@ namespace Artemis.Plugins.Modules.General
UpdateLedColor(surfaceLed, deltaTime);
}
- public void Render(double deltaTime, RGBSurface surface, Graphics graphics)
+ public override void Render(double deltaTime, RGBSurface surface, Graphics graphics)
{
foreach (var surfaceLed in _surface.Leds)
{
@@ -55,26 +62,16 @@ namespace Artemis.Plugins.Modules.General
}
}
- public IScreen GetMainViewModel()
+ public override IScreen GetMainViewModel()
{
return new GeneralViewModel(this);
}
- public void Dispose()
+ public override void Dispose()
{
_colors = null;
}
- public void EnablePlugin()
- {
- var qrGenerator = new QRCodeGenerator();
- PopulateColors();
- }
-
- public void DisablePlugin()
- {
- }
-
private void UpdateLedColor(Led led, double deltaTime)
{
if (_colors.ContainsKey(led))
diff --git a/src/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs b/src/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs
index 5f131c1ba..b9f75f0f8 100644
--- a/src/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs
+++ b/src/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs
@@ -5,7 +5,7 @@ namespace Artemis.Plugins.Modules.General.ViewModels
{
public class GeneralViewModel : ModuleViewModel
{
- public GeneralViewModel(IModule module) : base(module)
+ public GeneralViewModel(Module module) : base(module)
{
}
}
diff --git a/src/Artemis.Storage/Entities/SettingEntity.cs b/src/Artemis.Storage/Entities/SettingEntity.cs
index 0e4ba5e13..520235cc6 100644
--- a/src/Artemis.Storage/Entities/SettingEntity.cs
+++ b/src/Artemis.Storage/Entities/SettingEntity.cs
@@ -1,4 +1,5 @@
-using System.ComponentModel.DataAnnotations;
+using System;
+using System.ComponentModel.DataAnnotations;
namespace Artemis.Storage.Entities
{
@@ -7,6 +8,8 @@ namespace Artemis.Storage.Entities
[Key]
public string Name { get; set; }
+ public Guid PluginGuid { get; set; }
+
public string Value { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Artemis.Storage/Migrations/20180406175247_InitialCreate.cs b/src/Artemis.Storage/Migrations/20180406175247_InitialCreate.cs
index f27232e6d..979e01f61 100644
--- a/src/Artemis.Storage/Migrations/20180406175247_InitialCreate.cs
+++ b/src/Artemis.Storage/Migrations/20180406175247_InitialCreate.cs
@@ -11,10 +11,10 @@ namespace Artemis.Storage.Migrations
"Folders",
table => new
{
- Guid = table.Column(nullable: false),
+ Guid = table.Column(),
FolderEntityGuid = table.Column(nullable: true),
Name = table.Column(nullable: true),
- Order = table.Column(nullable: false)
+ Order = table.Column()
},
constraints: table =>
{
@@ -31,7 +31,7 @@ namespace Artemis.Storage.Migrations
"Settings",
table => new
{
- Name = table.Column(nullable: false),
+ Name = table.Column(),
Value = table.Column(nullable: true)
},
constraints: table => { table.PrimaryKey("PK_Settings", x => x.Name); });
@@ -40,10 +40,10 @@ namespace Artemis.Storage.Migrations
"Layers",
table => new
{
- Guid = table.Column(nullable: false),
+ Guid = table.Column(),
FolderEntityGuid = table.Column(nullable: true),
Name = table.Column(nullable: true),
- Order = table.Column(nullable: false)
+ Order = table.Column()
},
constraints: table =>
{
@@ -60,11 +60,11 @@ namespace Artemis.Storage.Migrations
"Profiles",
table => new
{
- Guid = table.Column(nullable: false),
+ Guid = table.Column(),
Name = table.Column(nullable: true),
- PluginGuid = table.Column(nullable: false),
+ PluginGuid = table.Column(),
RootFolderGuid = table.Column(nullable: true),
- RootFolderId = table.Column(nullable: false)
+ RootFolderId = table.Column()
},
constraints: table =>
{
@@ -81,7 +81,7 @@ namespace Artemis.Storage.Migrations
"LayerSettings",
table => new
{
- Guid = table.Column(nullable: false),
+ Guid = table.Column(),
LayerEntityGuid = table.Column(nullable: true),
Name = table.Column(nullable: true),
Value = table.Column(nullable: true)
@@ -101,9 +101,9 @@ namespace Artemis.Storage.Migrations
"Leds",
table => new
{
- Guid = table.Column(nullable: false),
+ Guid = table.Column(),
LayerGuid = table.Column(nullable: true),
- LayerId = table.Column(nullable: false),
+ LayerId = table.Column(),
LedName = table.Column(nullable: true),
LimitedToDevice = table.Column(nullable: true)
},
@@ -122,9 +122,9 @@ namespace Artemis.Storage.Migrations
"Keypoints",
table => new
{
- Guid = table.Column(nullable: false),
+ Guid = table.Column(),
LayerSettingEntityGuid = table.Column(nullable: true),
- Time = table.Column(nullable: false),
+ Time = table.Column(),
Value = table.Column(nullable: true)
},
constraints: table =>
diff --git a/src/Artemis.Storage/Migrations/20190415185618_SettingsPluginGuid.Designer.cs b/src/Artemis.Storage/Migrations/20190415185618_SettingsPluginGuid.Designer.cs
new file mode 100644
index 000000000..1e59124a9
--- /dev/null
+++ b/src/Artemis.Storage/Migrations/20190415185618_SettingsPluginGuid.Designer.cs
@@ -0,0 +1,193 @@
+//
+using System;
+using Artemis.Storage;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Artemis.Storage.Migrations
+{
+ [DbContext(typeof(StorageContext))]
+ [Migration("20190415185618_SettingsPluginGuid")]
+ partial class SettingsPluginGuid
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.4-servicing-10062");
+
+ modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b =>
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
+
+ b.Property("FolderEntityGuid");
+
+ b.Property("Name");
+
+ b.Property("Order");
+
+ b.HasKey("Guid");
+
+ b.HasIndex("FolderEntityGuid");
+
+ b.ToTable("Folders");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.KeypointEntity", b =>
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
+
+ b.Property("LayerSettingEntityGuid");
+
+ b.Property("Time");
+
+ b.Property("Value");
+
+ b.HasKey("Guid");
+
+ b.HasIndex("LayerSettingEntityGuid");
+
+ b.ToTable("Keypoints");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.LayerEntity", b =>
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
+
+ b.Property("FolderEntityGuid");
+
+ b.Property("Name");
+
+ b.Property("Order");
+
+ b.HasKey("Guid");
+
+ b.HasIndex("FolderEntityGuid");
+
+ b.ToTable("Layers");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.LayerSettingEntity", b =>
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
+
+ b.Property("LayerEntityGuid");
+
+ b.Property("Name");
+
+ b.Property("Value");
+
+ b.HasKey("Guid");
+
+ b.HasIndex("LayerEntityGuid");
+
+ b.ToTable("LayerSettings");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.LedEntity", b =>
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
+
+ b.Property("LayerGuid");
+
+ b.Property("LayerId");
+
+ b.Property("LedName");
+
+ b.Property("LimitedToDevice");
+
+ b.HasKey("Guid");
+
+ b.HasIndex("LayerGuid");
+
+ b.ToTable("Leds");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b =>
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Name");
+
+ b.Property("PluginGuid");
+
+ b.Property("RootFolderGuid");
+
+ b.Property("RootFolderId");
+
+ b.HasKey("Guid");
+
+ b.HasIndex("RootFolderGuid");
+
+ b.ToTable("Profiles");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.SettingEntity", b =>
+ {
+ b.Property("Name")
+ .ValueGeneratedOnAdd();
+
+ b.Property("PluginGuid");
+
+ b.Property("Value");
+
+ b.HasKey("Name");
+
+ b.HasIndex("Name", "PluginGuid");
+
+ b.ToTable("Settings");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b =>
+ {
+ b.HasOne("Artemis.Storage.Entities.FolderEntity")
+ .WithMany("Folders")
+ .HasForeignKey("FolderEntityGuid");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.KeypointEntity", b =>
+ {
+ b.HasOne("Artemis.Storage.Entities.LayerSettingEntity")
+ .WithMany("Keypoints")
+ .HasForeignKey("LayerSettingEntityGuid");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.LayerEntity", b =>
+ {
+ b.HasOne("Artemis.Storage.Entities.FolderEntity")
+ .WithMany("Layers")
+ .HasForeignKey("FolderEntityGuid");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.LayerSettingEntity", b =>
+ {
+ b.HasOne("Artemis.Storage.Entities.LayerEntity")
+ .WithMany("Settings")
+ .HasForeignKey("LayerEntityGuid");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.LedEntity", b =>
+ {
+ b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer")
+ .WithMany("Leds")
+ .HasForeignKey("LayerGuid");
+ });
+
+ modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b =>
+ {
+ b.HasOne("Artemis.Storage.Entities.FolderEntity", "RootFolder")
+ .WithMany()
+ .HasForeignKey("RootFolderGuid");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Artemis.Storage/Migrations/20190415185618_SettingsPluginGuid.cs b/src/Artemis.Storage/Migrations/20190415185618_SettingsPluginGuid.cs
new file mode 100644
index 000000000..16ba76f23
--- /dev/null
+++ b/src/Artemis.Storage/Migrations/20190415185618_SettingsPluginGuid.cs
@@ -0,0 +1,33 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Artemis.Storage.Migrations
+{
+ public partial class SettingsPluginGuid : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "PluginGuid",
+ table: "Settings",
+ nullable: false,
+ defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Settings_Name_PluginGuid",
+ table: "Settings",
+ columns: new[] { "Name", "PluginGuid" });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropIndex(
+ name: "IX_Settings_Name_PluginGuid",
+ table: "Settings");
+
+ migrationBuilder.DropColumn(
+ name: "PluginGuid",
+ table: "Settings");
+ }
+ }
+}
diff --git a/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs b/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs
index d0eb9328a..c433fddb1 100644
--- a/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs
+++ b/src/Artemis.Storage/Migrations/StorageContextModelSnapshot.cs
@@ -1,186 +1,191 @@
//
-
using System;
+using Artemis.Storage;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Artemis.Storage.Migrations
{
[DbContext(typeof(StorageContext))]
- internal class StorageContextModelSnapshot : ModelSnapshot
+ partial class StorageContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
- #pragma warning disable 612, 618
+#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "2.0.2-rtm-10011");
+ .HasAnnotation("ProductVersion", "2.2.4-servicing-10062");
modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b =>
- {
- b.Property("Guid")
- .ValueGeneratedOnAdd();
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
- b.Property("FolderEntityGuid");
+ b.Property("FolderEntityGuid");
- b.Property("Name");
+ b.Property("Name");
- b.Property("Order");
+ b.Property("Order");
- b.HasKey("Guid");
+ b.HasKey("Guid");
- b.HasIndex("FolderEntityGuid");
+ b.HasIndex("FolderEntityGuid");
- b.ToTable("Folders");
- });
+ b.ToTable("Folders");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.KeypointEntity", b =>
- {
- b.Property("Guid")
- .ValueGeneratedOnAdd();
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
- b.Property("LayerSettingEntityGuid");
+ b.Property("LayerSettingEntityGuid");
- b.Property("Time");
+ b.Property("Time");
- b.Property("Value");
+ b.Property("Value");
- b.HasKey("Guid");
+ b.HasKey("Guid");
- b.HasIndex("LayerSettingEntityGuid");
+ b.HasIndex("LayerSettingEntityGuid");
- b.ToTable("Keypoints");
- });
+ b.ToTable("Keypoints");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.LayerEntity", b =>
- {
- b.Property("Guid")
- .ValueGeneratedOnAdd();
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
- b.Property("FolderEntityGuid");
+ b.Property("FolderEntityGuid");
- b.Property("Name");
+ b.Property("Name");
- b.Property("Order");
+ b.Property("Order");
- b.HasKey("Guid");
+ b.HasKey("Guid");
- b.HasIndex("FolderEntityGuid");
+ b.HasIndex("FolderEntityGuid");
- b.ToTable("Layers");
- });
+ b.ToTable("Layers");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.LayerSettingEntity", b =>
- {
- b.Property("Guid")
- .ValueGeneratedOnAdd();
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
- b.Property("LayerEntityGuid");
+ b.Property("LayerEntityGuid");
- b.Property("Name");
+ b.Property("Name");
- b.Property("Value");
+ b.Property("Value");
- b.HasKey("Guid");
+ b.HasKey("Guid");
- b.HasIndex("LayerEntityGuid");
+ b.HasIndex("LayerEntityGuid");
- b.ToTable("LayerSettings");
- });
+ b.ToTable("LayerSettings");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.LedEntity", b =>
- {
- b.Property("Guid")
- .ValueGeneratedOnAdd();
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
- b.Property("LayerGuid");
+ b.Property("LayerGuid");
- b.Property("LayerId");
+ b.Property("LayerId");
- b.Property("LedName");
+ b.Property("LedName");
- b.Property("LimitedToDevice");
+ b.Property("LimitedToDevice");
- b.HasKey("Guid");
+ b.HasKey("Guid");
- b.HasIndex("LayerGuid");
+ b.HasIndex("LayerGuid");
- b.ToTable("Leds");
- });
+ b.ToTable("Leds");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b =>
- {
- b.Property("Guid")
- .ValueGeneratedOnAdd();
+ {
+ b.Property("Guid")
+ .ValueGeneratedOnAdd();
- b.Property("Name");
+ b.Property("Name");
- b.Property("PluginGuid");
+ b.Property("PluginGuid");
- b.Property("RootFolderGuid");
+ b.Property("RootFolderGuid");
- b.Property("RootFolderId");
+ b.Property("RootFolderId");
- b.HasKey("Guid");
+ b.HasKey("Guid");
- b.HasIndex("RootFolderGuid");
+ b.HasIndex("RootFolderGuid");
- b.ToTable("Profiles");
- });
+ b.ToTable("Profiles");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.SettingEntity", b =>
- {
- b.Property("Name")
- .ValueGeneratedOnAdd();
+ {
+ b.Property("Name")
+ .ValueGeneratedOnAdd();
- b.Property("Value");
+ b.Property("PluginGuid");
- b.HasKey("Name");
+ b.Property("Value");
- b.ToTable("Settings");
- });
+ b.HasKey("Name");
+
+ b.HasIndex("Name", "PluginGuid");
+
+ b.ToTable("Settings");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.FolderEntity", b =>
- {
- b.HasOne("Artemis.Storage.Entities.FolderEntity")
- .WithMany("Folders")
- .HasForeignKey("FolderEntityGuid");
- });
+ {
+ b.HasOne("Artemis.Storage.Entities.FolderEntity")
+ .WithMany("Folders")
+ .HasForeignKey("FolderEntityGuid");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.KeypointEntity", b =>
- {
- b.HasOne("Artemis.Storage.Entities.LayerSettingEntity")
- .WithMany("Keypoints")
- .HasForeignKey("LayerSettingEntityGuid");
- });
+ {
+ b.HasOne("Artemis.Storage.Entities.LayerSettingEntity")
+ .WithMany("Keypoints")
+ .HasForeignKey("LayerSettingEntityGuid");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.LayerEntity", b =>
- {
- b.HasOne("Artemis.Storage.Entities.FolderEntity")
- .WithMany("Layers")
- .HasForeignKey("FolderEntityGuid");
- });
+ {
+ b.HasOne("Artemis.Storage.Entities.FolderEntity")
+ .WithMany("Layers")
+ .HasForeignKey("FolderEntityGuid");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.LayerSettingEntity", b =>
- {
- b.HasOne("Artemis.Storage.Entities.LayerEntity")
- .WithMany("Settings")
- .HasForeignKey("LayerEntityGuid");
- });
+ {
+ b.HasOne("Artemis.Storage.Entities.LayerEntity")
+ .WithMany("Settings")
+ .HasForeignKey("LayerEntityGuid");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.LedEntity", b =>
- {
- b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer")
- .WithMany("Leds")
- .HasForeignKey("LayerGuid");
- });
+ {
+ b.HasOne("Artemis.Storage.Entities.LayerEntity", "Layer")
+ .WithMany("Leds")
+ .HasForeignKey("LayerGuid");
+ });
modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b =>
- {
- b.HasOne("Artemis.Storage.Entities.FolderEntity", "RootFolder")
- .WithMany()
- .HasForeignKey("RootFolderGuid");
- });
- #pragma warning restore 612, 618
+ {
+ b.HasOne("Artemis.Storage.Entities.FolderEntity", "RootFolder")
+ .WithMany()
+ .HasForeignKey("RootFolderGuid");
+ });
+#pragma warning restore 612, 618
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Artemis.Storage/Repositories/SettingRepository.cs b/src/Artemis.Storage/Repositories/SettingRepository.cs
new file mode 100644
index 000000000..2add6a9eb
--- /dev/null
+++ b/src/Artemis.Storage/Repositories/SettingRepository.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Artemis.Storage.Entities;
+using Microsoft.EntityFrameworkCore;
+
+namespace Artemis.Storage.Repositories
+{
+ public class SettingRepository
+ {
+ private readonly StorageContext _dbContext;
+
+ public SettingRepository()
+ {
+ _dbContext = new StorageContext();
+ }
+
+ public IQueryable GetAll()
+ {
+ return _dbContext.Settings;
+ }
+
+ public async Task> GetByPluginGuid(Guid pluginGuid)
+ {
+ return await _dbContext.Settings.Where(p => p.PluginGuid == pluginGuid).ToListAsync();
+ }
+
+ public async Task GetByNameAndPluginGuid(string name, Guid pluginGuid)
+ {
+ return await _dbContext.Settings.FirstOrDefaultAsync(p => p.Name == name && p.PluginGuid == pluginGuid);
+ }
+
+ public async Task GetByName(string name)
+ {
+ return await _dbContext.Settings.FirstOrDefaultAsync(p => p.Name == name);
+ }
+
+ public async Task SaveAsync()
+ {
+ await _dbContext.SaveChangesAsync();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.Storage/Storage.db b/src/Artemis.Storage/Storage.db
index 77b0d6faa..e93b9c353 100644
Binary files a/src/Artemis.Storage/Storage.db and b/src/Artemis.Storage/Storage.db differ
diff --git a/src/Artemis.Storage/StorageContext.cs b/src/Artemis.Storage/StorageContext.cs
index b10e0a006..f94aed111 100644
--- a/src/Artemis.Storage/StorageContext.cs
+++ b/src/Artemis.Storage/StorageContext.cs
@@ -12,5 +12,11 @@ namespace Artemis.Storage
{
optionsBuilder.UseSqlite("Data Source=Storage.db");
}
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity().HasIndex(s => new {s.Name, s.PluginGuid});
+ base.OnModelCreating(modelBuilder);
+ }
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/ViewModels/RootViewModel.cs b/src/Artemis.UI/ViewModels/RootViewModel.cs
index 392cc0933..c307d11e8 100644
--- a/src/Artemis.UI/ViewModels/RootViewModel.cs
+++ b/src/Artemis.UI/ViewModels/RootViewModel.cs
@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows.Controls;
using Artemis.Core.Events;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Interfaces;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.ViewModels.Interfaces;
@@ -28,8 +29,8 @@ namespace Artemis.UI.ViewModels
ActiveItem = _artemisViewModels.First(v => v.GetType() == typeof(HomeViewModel));
// Sync up with the plugin service
- Modules = new BindableCollection();
- Modules.AddRange(_pluginService.GetPluginsOfType());
+ Modules = new BindableCollection();
+ Modules.AddRange(_pluginService.GetPluginsOfType());
_pluginService.PluginEnabled += PluginServiceOnPluginEnabled;
_pluginService.PluginDisabled += PluginServiceOnPluginDisabled;
@@ -37,10 +38,10 @@ namespace Artemis.UI.ViewModels
PropertyChanged += OnSelectedPageChanged;
}
- public IObservableCollection Modules { get; set; }
+ public IObservableCollection Modules { get; set; }
public bool MenuOpen { get; set; }
public ListBoxItem SelectedPage { get; set; }
- public IModule SelectedModule { get; set; }
+ public Module SelectedModule { get; set; }
public async Task NavigateToSelectedModule()
{
@@ -66,7 +67,7 @@ namespace Artemis.UI.ViewModels
Modules.Remove(existing);
}
- if (e.PluginInfo.Instance is IModule module)
+ if (e.PluginInfo.Instance is Module module)
Modules.Add(module);
}
diff --git a/src/Artemis.UI/Views/RootView.xaml b/src/Artemis.UI/Views/RootView.xaml
index 83bd64323..7e52d4419 100644
--- a/src/Artemis.UI/Views/RootView.xaml
+++ b/src/Artemis.UI/Views/RootView.xaml
@@ -9,6 +9,7 @@
xmlns:vms="clr-namespace:Artemis.UI.ViewModels"
xmlns:models="clr-namespace:Artemis.Core.Plugins.Models;assembly=Artemis.Core"
xmlns:interfaces="clr-namespace:Artemis.Core.Plugins.Interfaces;assembly=Artemis.Core"
+ xmlns:abstract="clr-namespace:Artemis.Core.Plugins.Abstract;assembly=Artemis.Core"
mc:Ignorable="d"
GlowBrush="{DynamicResource AccentColorBrush}"
FontFamily="{StaticResource DefaultFont}"
@@ -127,7 +128,7 @@
SelectedItem="{Binding SelectedModule}"
DockPanel.Dock="Top">
-
+