mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Data bindings - WIP commit
Layer/effect config dialogs - Don't require specific ctor parameter names
This commit is contained in:
1 parent
0d0ba7bd7d
commit
3bb4e86f65
15 files changed
+408
-130
No files matched your search
@@ -10,6 +10,7 @@ using Artemis.Core.LayerBrushes;
|
||||
using Artemis.Core.LayerEffects;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Exceptions;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject;
|
||||
@@ -88,7 +89,13 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
|
||||
try
|
||||
{
|
||||
var plugin = new ConstructorArgument("plugin", Plugin);
|
||||
// Limit to one constructor, there's no need to have more and it complicates things anyway
|
||||
var constructors = configurationViewModel.Type.GetConstructors();
|
||||
if (constructors.Length != 1)
|
||||
throw new ArtemisUIException("Plugin configuration dialogs must have exactly one constructor");
|
||||
|
||||
var pluginParameter = constructors.First().GetParameters().First(p => typeof(Plugin).IsAssignableFrom(p.ParameterType));
|
||||
var plugin = new ConstructorArgument(pluginParameter.Name, Plugin);
|
||||
var viewModel = (PluginConfigurationViewModel) _kernel.Get(configurationViewModel.Type, plugin);
|
||||
_windowManager.ShowDialog(new PluginSettingsWindowViewModel(viewModel, Icon));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user