diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index 882081df0..f3f636825 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -102,6 +102,7 @@
+
@@ -110,8 +111,6 @@
-
-
diff --git a/src/Artemis.Core/Plugins/Abstract/ModuleDataModel.cs b/src/Artemis.Core/Plugins/Abstract/ModuleDataModel.cs
new file mode 100644
index 000000000..ad95bd980
--- /dev/null
+++ b/src/Artemis.Core/Plugins/Abstract/ModuleDataModel.cs
@@ -0,0 +1,15 @@
+using Artemis.Core.Plugins.Interfaces;
+using Stylet;
+
+namespace Artemis.Core.Plugins.Abstract
+{
+ public abstract class ModuleDataModel
+ {
+ protected ModuleDataModel(IModule module)
+ {
+ Module = module;
+ }
+
+ public IModule 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 0546b23a8..68ec913a6 100644
--- a/src/Artemis.Core/Plugins/Abstract/ModuleViewModel.cs
+++ b/src/Artemis.Core/Plugins/Abstract/ModuleViewModel.cs
@@ -4,8 +4,13 @@ using Stylet;
namespace Artemis.Core.Plugins.Abstract
{
- public abstract class ModuleViewModel : Screen, IModuleViewModel
+ public abstract class ModuleViewModel : Screen
{
- public PluginInfo PluginInfo { get; set; }
+ protected ModuleViewModel(IModule module)
+ {
+ Module = module;
+ }
+
+ public IModule Module { get; }
}
}
\ 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 509460501..50c4b9fbd 100644
--- a/src/Artemis.Core/Plugins/Abstract/ProfileModule.cs
+++ b/src/Artemis.Core/Plugins/Abstract/ProfileModule.cs
@@ -11,6 +11,9 @@ namespace Artemis.Core.Plugins.Abstract
{
public Profile ActiveProfile { get; private set; }
+ ///
+ public abstract string DisplayName { get; }
+
///
public abstract bool ExpandsMainDataModel { get; }
diff --git a/src/Artemis.Core/Plugins/Interfaces/IModule.cs b/src/Artemis.Core/Plugins/Interfaces/IModule.cs
index a21baed39..d397b09b9 100644
--- a/src/Artemis.Core/Plugins/Interfaces/IModule.cs
+++ b/src/Artemis.Core/Plugins/Interfaces/IModule.cs
@@ -11,7 +11,12 @@ namespace Artemis.Core.Plugins.Interfaces
public interface IModule : IPlugin
{
///
- /// Wether or not this module expands upon the main data model. If set to true any data in main data model can be
+ /// The modules display name that's shown in the menu
+ ///
+ string DisplayName { get; }
+
+ ///
+ /// 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; }
diff --git a/src/Artemis.Core/Plugins/Interfaces/IModuleDataModel.cs b/src/Artemis.Core/Plugins/Interfaces/IModuleDataModel.cs
deleted file mode 100644
index adeae8664..000000000
--- a/src/Artemis.Core/Plugins/Interfaces/IModuleDataModel.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace Artemis.Core.Plugins.Interfaces
-{
- public interface IModuleDataModel
- {
- }
-}
\ No newline at end of file
diff --git a/src/Artemis.Core/Plugins/Interfaces/IModuleViewModel.cs b/src/Artemis.Core/Plugins/Interfaces/IModuleViewModel.cs
deleted file mode 100644
index 2035567a7..000000000
--- a/src/Artemis.Core/Plugins/Interfaces/IModuleViewModel.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using Artemis.Core.Plugins.Models;
-using Stylet;
-
-namespace Artemis.Core.Plugins.Interfaces
-{
- ///
- ///
- /// Allows you to create a view model for a module
- ///
- public interface IModuleViewModel : IScreen
- {
- PluginInfo PluginInfo { get; set; }
- }
-}
\ 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 359ed7511..c11d66f61 100644
--- a/src/Artemis.Core/Plugins/Models/PluginInfo.cs
+++ b/src/Artemis.Core/Plugins/Models/PluginInfo.cs
@@ -7,6 +7,11 @@ namespace Artemis.Core.Plugins.Models
{
public class PluginInfo
{
+ public PluginInfo()
+ {
+ Instances = new List();
+ }
+
///
/// The plugins GUID
///
diff --git a/src/Artemis.Core/Services/PluginService.cs b/src/Artemis.Core/Services/PluginService.cs
index a7c825562..080a30fb5 100644
--- a/src/Artemis.Core/Services/PluginService.cs
+++ b/src/Artemis.Core/Services/PluginService.cs
@@ -68,12 +68,28 @@ namespace Artemis.Core.Services
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
- var assembly = Assembly.LoadFile(mainFile);
+ Assembly assembly;
+ try
+ {
+ assembly = Assembly.LoadFile(mainFile);
+ }
+ catch (Exception e)
+ {
+ throw new ArtemisPluginException(pluginInfo, "Failed to load the plugins assembly", e);
+ }
+
var pluginTypes = assembly.GetTypes().Where(t => typeof(IPlugin).IsAssignableFrom(t)).ToArray();
foreach (var pluginType in pluginTypes)
{
- _childKernel.Bind(pluginType).To().InSingletonScope();
- pluginInfo.Instances.Add((IPlugin) _childKernel.Get(pluginType));
+ _childKernel.Bind().To(pluginType).InSingletonScope();
+ try
+ {
+ pluginInfo.Instances.Add((IPlugin) _childKernel.Get(pluginType));
+ }
+ catch (Exception e)
+ {
+ throw new ArtemisPluginException(pluginInfo, "Failed to instantiate the plugin", e);
+ }
}
_plugins.Add(pluginInfo);
diff --git a/src/Artemis.Plugins.Modules.General/GeneralDataModel.cs b/src/Artemis.Plugins.Modules.General/GeneralDataModel.cs
index 76e09a167..f00c82340 100644
--- a/src/Artemis.Plugins.Modules.General/GeneralDataModel.cs
+++ b/src/Artemis.Plugins.Modules.General/GeneralDataModel.cs
@@ -1,11 +1,16 @@
using Artemis.Core.Attributes;
+using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Interfaces;
namespace Artemis.Plugins.Modules.General
{
- public class GeneralDataModel : IModuleDataModel
+ public class GeneralDataModel : ModuleDataModel
{
[DataModelProperty(DisplayName = "Unique boolean")]
public bool PropertyUniqueToThisDm { get; set; }
+
+ public GeneralDataModel(IModule module) : base(module)
+ {
+ }
}
}
\ No newline at end of file
diff --git a/src/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Artemis.Plugins.Modules.General/GeneralModule.cs
index f4770ec36..a5089b49c 100644
--- a/src/Artemis.Plugins.Modules.General/GeneralModule.cs
+++ b/src/Artemis.Plugins.Modules.General/GeneralModule.cs
@@ -13,23 +13,20 @@ namespace Artemis.Plugins.Modules.General
{
public class GeneralModule : IModule
{
- private readonly IRgbService _rgbService;
private readonly RGBSurface _surface;
private Dictionary _colors;
- public GeneralModule()
- {
-
- }
public GeneralModule(IRgbService rgbService)
{
- _rgbService = rgbService;
- _surface = _rgbService.Surface;
+ var rgbService1 = rgbService;
+ _surface = rgbService1.Surface;
_colors = new Dictionary();
- _rgbService.FinishedLoadedDevices += (sender, args) => PopulateColors();
+ rgbService1.FinishedLoadedDevices += (sender, args) => PopulateColors();
}
+ public string DisplayName => "General";
+
// True since the main data model is all this module shows
public bool ExpandsMainDataModel => true;
@@ -58,7 +55,7 @@ namespace Artemis.Plugins.Modules.General
public IScreen GetMainViewModel()
{
- return new GeneralViewModel();
+ return new GeneralViewModel(this);
}
public void Dispose()
diff --git a/src/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs b/src/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs
index 3db2d3641..5f131c1ba 100644
--- a/src/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs
+++ b/src/Artemis.Plugins.Modules.General/ViewModels/GeneralViewModel.cs
@@ -1,11 +1,12 @@
-using Artemis.Core.Plugins.Interfaces;
-using Artemis.Core.Plugins.Models;
-using Stylet;
+using Artemis.Core.Plugins.Abstract;
+using Artemis.Core.Plugins.Interfaces;
namespace Artemis.Plugins.Modules.General.ViewModels
{
- public class GeneralViewModel : Screen, IModuleViewModel
+ public class GeneralViewModel : ModuleViewModel
{
- public PluginInfo PluginInfo { get; set; }
+ public GeneralViewModel(IModule module) : base(module)
+ {
+ }
}
}
\ No newline at end of file
diff --git a/src/Artemis.Plugins.Modules.General/Views/GeneralView.xaml b/src/Artemis.Plugins.Modules.General/Views/GeneralView.xaml
index fcfb5103b..63ac61c87 100644
--- a/src/Artemis.Plugins.Modules.General/Views/GeneralView.xaml
+++ b/src/Artemis.Plugins.Modules.General/Views/GeneralView.xaml
@@ -6,5 +6,7 @@
xmlns:local="clr-namespace:Artemis.Plugins.Modules.General.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.UI/Stylet/ArtemisViewManager.cs b/src/Artemis.UI/Stylet/ArtemisViewManager.cs
index 55beb3441..fdb164b3e 100644
--- a/src/Artemis.UI/Stylet/ArtemisViewManager.cs
+++ b/src/Artemis.UI/Stylet/ArtemisViewManager.cs
@@ -1,8 +1,4 @@
-using System.IO;
-using System.Windows;
-using System.Windows.Markup;
-using Artemis.Core.Plugins.Interfaces;
-using Stylet;
+using Stylet;
namespace Artemis.UI.Stylet
{
@@ -10,30 +6,7 @@ namespace Artemis.UI.Stylet
{
public ArtemisViewManager(ViewManagerConfig config) : base(config)
{
- }
- public override UIElement CreateViewForModel(object model)
- {
- if (model is IModuleViewModel)
- return CreateViewForPlugin(model);
-
- return base.CreateViewForModel(model);
- }
-
- private UIElement CreateViewForPlugin(object model)
- {
- var viewName = model.GetType().Name.Replace("Model", "");
- var pluginInfo = ((IModuleViewModel) model).PluginInfo;
- var viewPath = $"{pluginInfo.Folder}{viewName}.xaml";
- // There doesn't have to be a view so make sure one exists
- if (!File.Exists(viewPath))
- return null;
-
- // Compile the view if found, must be done on UI thread sadly
- object view = null;
- Execute.OnUIThread(() => view = XamlReader.Parse(File.ReadAllText(viewPath)));
-
- return (UIElement) view;
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/Stylet/NinjectBootstrapper.cs b/src/Artemis.UI/Stylet/NinjectBootstrapper.cs
index e11b476b1..e04484bed 100644
--- a/src/Artemis.UI/Stylet/NinjectBootstrapper.cs
+++ b/src/Artemis.UI/Stylet/NinjectBootstrapper.cs
@@ -31,11 +31,10 @@ namespace Artemis.UI.Stylet
ViewFactory = GetInstance,
ViewAssemblies = new List {GetType().Assembly}
};
- kernel.Bind().ToConstant(new ArtemisViewManager(viewManagerConfig));
+ kernel.Bind().ToConstant(new ViewManager(viewManagerConfig));
kernel.Bind().ToConstant(this).InTransientScope();
- kernel.Bind().ToMethod(c => new WindowManager(c.Kernel.Get(),
- () => c.Kernel.Get(), c.Kernel.Get())).InSingletonScope();
+ kernel.Bind().ToMethod(c => new WindowManager(c.Kernel.Get(),() => c.Kernel.Get(), c.Kernel.Get())).InSingletonScope();
kernel.Bind().To().InSingletonScope();
kernel.Bind().To(); // Not singleton!
}
diff --git a/src/Artemis.UI/Views/HomeView.xaml b/src/Artemis.UI/Views/HomeView.xaml
index 1e298826b..9d8e62487 100644
--- a/src/Artemis.UI/Views/HomeView.xaml
+++ b/src/Artemis.UI/Views/HomeView.xaml
@@ -65,7 +65,7 @@
-
+
Have a chat
-
@@ -92,7 +92,7 @@
GitHub
-