diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index a86594536..97c51fdc9 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -208,10 +208,6 @@
{cd23bc5e-57f0-46ce-a007-24d031146219}
Artemis.Plugins
-
- {58113cc5-a9ca-4ec3-ab4e-3c94b99268d8}
- Module.General
-
diff --git a/src/Artemis.Core/Ninject/CoreModule.cs b/src/Artemis.Core/Ninject/CoreModule.cs
index 5698176f1..09c579f60 100644
--- a/src/Artemis.Core/Ninject/CoreModule.cs
+++ b/src/Artemis.Core/Ninject/CoreModule.cs
@@ -1,5 +1,9 @@
-using Artemis.Core.Services.Interfaces;
+using System.Linq;
+using System.Reflection;
+using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Interfaces;
+using Artemis.Plugins.Models;
+using Newtonsoft.Json;
using Ninject.Extensions.Conventions;
using Ninject.Modules;
@@ -18,15 +22,6 @@ namespace Artemis.Core.Ninject
.BindAllInterfaces()
.Configure(c => c.InSingletonScope());
});
-
- // Bind all built-in plugins
- Kernel.Bind(x =>
- {
- x.FromThisAssembly()
- .SelectAllClasses()
- .InheritedFrom()
- .BindAllBaseClasses();
- });
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Services/PluginService.cs b/src/Artemis.Core/Services/PluginService.cs
index 8473f0ffc..74bcc48de 100644
--- a/src/Artemis.Core/Services/PluginService.cs
+++ b/src/Artemis.Core/Services/PluginService.cs
@@ -42,10 +42,6 @@ namespace Artemis.Core.Services
pluginInfo.Dispose();
_plugins.Clear();
- // Load all built-in plugins
- foreach (var builtInPlugin in _kernel.GetAll())
- _plugins.Add(PluginInfo.FromBuiltInPlugin(_kernel, builtInPlugin));
-
// Iterate all plugin folders and load each plugin
foreach (var directory in Directory.GetDirectories(Constants.DataFolder + "plugins"))
_plugins.Add(await PluginInfo.FromFolder(_kernel, directory));
@@ -53,11 +49,13 @@ namespace Artemis.Core.Services
OnFinishedLoadedPlugins();
}
+ ///
public async Task ReloadPlugin(PluginInfo pluginInfo)
{
throw new NotImplementedException();
}
+ ///
public async Task GetModuleViewModel(PluginInfo pluginInfo)
{
return await pluginInfo.GetModuleViewModel(_kernel);
diff --git a/src/Artemis.Core/Services/RgbService.cs b/src/Artemis.Core/Services/RgbService.cs
index 8d65c2bf1..3bd9db7d5 100644
--- a/src/Artemis.Core/Services/RgbService.cs
+++ b/src/Artemis.Core/Services/RgbService.cs
@@ -43,7 +43,8 @@ namespace Artemis.Core.Services
await Task.Run(() =>
{
// TODO SpoinkyNL 8-1-18: Keep settings into account
- Surface.LoadDevices(AsusDeviceProvider.Instance);
+ // This one doesn't work well without ASUS devices installed
+ // Surface.LoadDevices(AsusDeviceProvider.Instance);
Surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
Surface.LoadDevices(CorsairDeviceProvider.Instance);
Surface.LoadDevices(DMXDeviceProvider.Instance);
diff --git a/src/Artemis.Plugins/Models/PluginInfo.cs b/src/Artemis.Plugins/Models/PluginInfo.cs
index 9c4663e99..4e840af7b 100644
--- a/src/Artemis.Plugins/Models/PluginInfo.cs
+++ b/src/Artemis.Plugins/Models/PluginInfo.cs
@@ -47,13 +47,27 @@ namespace Artemis.Plugins.Models
public string Folder { get; set; }
///
- /// Indicates wether this is a built-in plugin. Built-in plugins are precompiled and have no files
+ /// Indicates wether this is a built-in plugin.
///
[JsonIgnore]
public bool IsBuiltIn { get; private set; }
+ public void Dispose()
+ {
+ Plugin.UnloadPlugin();
+ }
+
+ ///
+ /// Load a plugin from a folder
+ ///
+ /// The Ninject kernel to use for DI
+ /// The folder in which plugin.json is located
+ ///
public static async Task FromFolder(IKernel kernel, string folder)
{
+ // Make sure the right engine is used
+ CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
+
if (!folder.EndsWith("\\"))
folder += "\\";
if (!File.Exists(folder + "plugin.json"))
@@ -76,33 +90,24 @@ namespace Artemis.Plugins.Models
return pluginInfo;
}
-
- public static PluginInfo FromBuiltInPlugin(IKernel kernel, IPlugin builtInPlugin)
- {
- var pluginInfo = new PluginInfo
- {
- Name = builtInPlugin.GetType().Name,
- Version = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion,
- Plugin = builtInPlugin,
- IsBuiltIn = true
- };
- pluginInfo.Plugin.LoadPlugin();
-
- return pluginInfo;
- }
-
- public void Dispose()
- {
- }
-
+
+ ///
+ /// Gets the view model of the module accompanying the provided plugin info
+ ///
+ /// The Ninject kernel to use for DI
+ ///
public async Task GetModuleViewModel(IKernel kernel)
{
+ // Make sure the right engine is used
+ CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom;
+
// Don't attempt to locave VMs for something other than a module
- if (Plugin is IModule)
+ if (!(Plugin is IModule))
throw new ArtemisPluginException(this, "Cannot locate a view model for this plugin as it's not a module.");
- // Compile the ViewModel script and get the type
+ // Use the plugin's assembly as the VM is precompiled if built in, otherwise compile the VM into a new assembly
var assembly = await CSScript.Evaluator.CompileCodeAsync(File.ReadAllText(Folder + ViewModel));
+
var vmType = assembly.GetTypes().Where(t => typeof(IModuleViewModel).IsAssignableFrom(t)).ToList();
if (!vmType.Any())
throw new ArtemisPluginException(this, "Failed to load plugin, no type found that implements IModuleViewModel");
@@ -110,7 +115,7 @@ namespace Artemis.Plugins.Models
throw new ArtemisPluginException(this, "Failed to load plugin, more than one type found that implements IModuleViewModel");
// Instantiate the ViewModel with Ninject
- var vm = (IModuleViewModel)kernel.Get(vmType.First());
+ var vm = (IModuleViewModel) kernel.Get(vmType.First());
vm.PluginInfo = this;
return vm;
}
diff --git a/src/Module.General/GeneralModule.cs b/src/Module.General/GeneralModule.cs
index 960921fa0..cffdcedc9 100644
--- a/src/Module.General/GeneralModule.cs
+++ b/src/Module.General/GeneralModule.cs
@@ -1,28 +1,30 @@
using System;
+using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Interfaces;
-namespace Artemis.BuiltIn.Module.General
+namespace Module.General
{
public class GeneralModule : IModule
{
+ public GeneralModule(ICoreService coreService)
+ {
+ Console.WriteLine(coreService);
+ }
+
public void LoadPlugin()
{
- throw new NotImplementedException();
}
public void UnloadPlugin()
{
- throw new NotImplementedException();
}
public void Update(double deltaTime)
{
- throw new NotImplementedException();
}
public void Render(double deltaTime)
{
- throw new NotImplementedException();
}
}
}
\ No newline at end of file
diff --git a/src/Module.General/GeneralView.xaml b/src/Module.General/GeneralView.xaml
index 05e2774f6..b27e2ec37 100644
--- a/src/Module.General/GeneralView.xaml
+++ b/src/Module.General/GeneralView.xaml
@@ -1,12 +1,8 @@
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/src/Module.General/GeneralView.xaml.cs b/src/Module.General/GeneralView.xaml.cs
deleted file mode 100644
index f8f249854..000000000
--- a/src/Module.General/GeneralView.xaml.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Windows.Controls;
-
-namespace Artemis.BuiltIn.Module.General
-{
- ///
- /// Interaction logic for GeneralView.xaml
- ///
- public partial class GeneralView : UserControl
- {
- public GeneralView()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/src/Module.General/GeneralViewModel.cs b/src/Module.General/GeneralViewModel.cs
index 6a169469a..4b5976943 100644
--- a/src/Module.General/GeneralViewModel.cs
+++ b/src/Module.General/GeneralViewModel.cs
@@ -1,6 +1,11 @@
-namespace Artemis.BuiltIn.Module.General
+using Artemis.Plugins.Interfaces;
+using Artemis.Plugins.Models;
+using Stylet;
+
+namespace Module.General
{
- public class GeneralViewModel
+ public class GeneralViewModel : Screen, IModuleViewModel
{
+ public PluginInfo PluginInfo { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Module.General/Module.General.csproj b/src/Module.General/Module.General.csproj
index 4fe843fc0..463a03c39 100644
--- a/src/Module.General/Module.General.csproj
+++ b/src/Module.General/Module.General.csproj
@@ -7,7 +7,7 @@
{58113CC5-A9CA-4EC3-AB4E-3C94B99268D8}
Library
Properties
- Artemis.BuiltIn.Module.General
+ Module.General
Module.General
v4.6
512
@@ -33,6 +33,9 @@
+
+ ..\packages\Stylet.1.1.21\lib\net45\Stylet.dll
+
@@ -48,13 +51,14 @@
-
- GeneralView.xaml
-
+
+ {9B811F9B-86B9-4771-87AF-72BAE7078A36}
+ Artemis.Core
+
{CD23BC5E-57F0-46CE-A007-24D031146219}
Artemis.Plugins
@@ -68,6 +72,8 @@
+
+
\ No newline at end of file
diff --git a/src/Module.General/Properties/AssemblyInfo.cs b/src/Module.General/Properties/AssemblyInfo.cs
index f07413909..7a8f13690 100644
--- a/src/Module.General/Properties/AssemblyInfo.cs
+++ b/src/Module.General/Properties/AssemblyInfo.cs
@@ -1,5 +1,4 @@
using System.Reflection;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
@@ -33,4 +32,4 @@ using System.Runtime.InteropServices;
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/src/Module.General/app.config b/src/Module.General/app.config
index 4d7b27125..0560a422e 100644
--- a/src/Module.General/app.config
+++ b/src/Module.General/app.config
@@ -1,39 +1,51 @@
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
\ No newline at end of file
diff --git a/src/Module.General/packages.config b/src/Module.General/packages.config
new file mode 100644
index 000000000..a89678ca1
--- /dev/null
+++ b/src/Module.General/packages.config
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Module.General/plugin.json b/src/Module.General/plugin.json
new file mode 100644
index 000000000..d245a84e2
--- /dev/null
+++ b/src/Module.General/plugin.json
@@ -0,0 +1,6 @@
+{
+ "Name": "Default",
+ "Version": "1.0.0",
+ "Main": "GeneralModule.cs",
+ "ViewModel": "GeneralViewModel.cs"
+}
\ No newline at end of file
diff --git a/src/TestModule/GeneralView.xaml b/src/TestModule/GeneralView.xaml
deleted file mode 100644
index bc034ce86..000000000
--- a/src/TestModule/GeneralView.xaml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/src/TestModule/GeneralViewModel.cs b/src/TestModule/GeneralViewModel.cs
deleted file mode 100644
index 69dfdeded..000000000
--- a/src/TestModule/GeneralViewModel.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace TestModule
-{
- public class TestModuleViewModel
- {
- }
-}
\ No newline at end of file
diff --git a/src/TestModule/TestModule.cs b/src/TestModule/TestModule.cs
deleted file mode 100644
index c8dae1f71..000000000
--- a/src/TestModule/TestModule.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using Artemis.Core.Plugins.Interfaces;
-
-namespace TestModule
-{
- public class TestModule : IModule
- {
- }
-}
\ No newline at end of file