mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Plugins - Separated plugins and implementations as different principles
This commit is contained in:
1 parent
c0d0e421c7
commit
1e0dc1894d
53 files changed
+438
-410
No files matched your search
@@ -22,7 +22,7 @@ namespace Artemis.UI.Shared
|
||||
ViewModelType = viewModelType;
|
||||
|
||||
if (PluginInfo != Constants.CorePluginInfo)
|
||||
PluginInfo.Instance.PluginDisabled += InstanceOnPluginDisabled;
|
||||
PluginInfo.Instance.Disabled += InstanceOnDisabled;
|
||||
}
|
||||
|
||||
public RegistrationType RegistrationType { get; }
|
||||
@@ -35,10 +35,10 @@ namespace Artemis.UI.Shared
|
||||
internal void Unsubscribe()
|
||||
{
|
||||
if (PluginInfo != Constants.CorePluginInfo)
|
||||
PluginInfo.Instance.PluginDisabled -= InstanceOnPluginDisabled;
|
||||
PluginInfo.Instance.Disabled -= InstanceOnDisabled;
|
||||
}
|
||||
|
||||
private void InstanceOnPluginDisabled(object sender, EventArgs e)
|
||||
private void InstanceOnDisabled(object sender, EventArgs e)
|
||||
{
|
||||
if (RegistrationType == RegistrationType.Input)
|
||||
_dataModelUIService.RemoveDataModelInput(this);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Artemis.UI.Shared
|
||||
ViewModelType = viewModelType;
|
||||
|
||||
if (PluginInfo != Constants.CorePluginInfo)
|
||||
PluginInfo.Instance.PluginDisabled += InstanceOnPluginDisabled;
|
||||
PluginInfo.Instance.Disabled += InstanceOnDisabled;
|
||||
}
|
||||
|
||||
public PluginInfo PluginInfo { get; }
|
||||
@@ -26,10 +26,10 @@ namespace Artemis.UI.Shared
|
||||
internal void Unsubscribe()
|
||||
{
|
||||
if (PluginInfo != Constants.CorePluginInfo)
|
||||
PluginInfo.Instance.PluginDisabled -= InstanceOnPluginDisabled;
|
||||
PluginInfo.Instance.Disabled -= InstanceOnDisabled;
|
||||
}
|
||||
|
||||
private void InstanceOnPluginDisabled(object sender, EventArgs e)
|
||||
private void InstanceOnDisabled(object sender, EventArgs e)
|
||||
{
|
||||
// Profile editor service will call Unsubscribe
|
||||
_profileEditorService.RemovePropertyInput(this);
|
||||
|
||||
@@ -42,24 +42,24 @@ namespace Artemis.UI.Shared.Services
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
public DataModelPropertiesViewModel GetPluginDataModelVisualization(Plugin plugin, bool includeMainDataModel)
|
||||
public DataModelPropertiesViewModel GetPluginDataModelVisualization(PluginImplementation pluginImplementation, bool includeMainDataModel)
|
||||
{
|
||||
if (includeMainDataModel)
|
||||
{
|
||||
DataModelPropertiesViewModel mainDataModel = GetMainDataModelVisualization();
|
||||
|
||||
// If the main data model already includes the plugin data model we're done
|
||||
if (mainDataModel.Children.Any(c => c.DataModel.PluginInfo.Instance == plugin))
|
||||
if (mainDataModel.Children.Any(c => c.DataModel.Implementation.Instance == pluginImplementation))
|
||||
return mainDataModel;
|
||||
// Otherwise get just the plugin data model and add it
|
||||
DataModelPropertiesViewModel pluginDataModel = GetPluginDataModelVisualization(plugin, false);
|
||||
DataModelPropertiesViewModel pluginDataModel = GetPluginDataModelVisualization(pluginImplementation, false);
|
||||
if (pluginDataModel != null)
|
||||
mainDataModel.Children.Add(pluginDataModel);
|
||||
|
||||
return mainDataModel;
|
||||
}
|
||||
|
||||
DataModel dataModel = _dataModelService.GetPluginDataModel(plugin);
|
||||
DataModel dataModel = _dataModelService.GetPluginDataModel(pluginImplementation);
|
||||
if (dataModel == null)
|
||||
return null;
|
||||
|
||||
|
||||
@@ -109,11 +109,11 @@ namespace Artemis.UI.Shared.Services
|
||||
|
||||
private async Task<object> ShowDialogAt<T>(string identifier, IParameter[] parameters) where T : DialogViewModelBase
|
||||
{
|
||||
Plugin callingPlugin = _pluginService.GetCallingPlugin();
|
||||
PluginImplementation callingPluginImplementation = _pluginService.GetCallingPlugin();
|
||||
if (parameters == null) throw new ArgumentNullException(nameof(parameters));
|
||||
|
||||
if (callingPlugin != null)
|
||||
return await ShowDialog(identifier, callingPlugin.PluginInfo.Kernel.Get<T>(parameters));
|
||||
if (callingPluginImplementation != null)
|
||||
return await ShowDialog(identifier, callingPluginImplementation.PluginInfo.Kernel.Get<T>(parameters));
|
||||
return await ShowDialog(identifier, _kernel.Get<T>(parameters));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Artemis.UI.Shared.Services
|
||||
IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelEditors { get; }
|
||||
IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelDisplays { get; }
|
||||
DataModelPropertiesViewModel GetMainDataModelVisualization();
|
||||
DataModelPropertiesViewModel GetPluginDataModelVisualization(Plugin plugin, bool includeMainDataModel);
|
||||
DataModelPropertiesViewModel GetPluginDataModelVisualization(PluginImplementation pluginImplementation, bool includeMainDataModel);
|
||||
|
||||
DataModelVisualizationRegistration RegisterDataModelInput<T>(PluginInfo pluginInfo, IReadOnlyCollection<Type> compatibleConversionTypes) where T : DataModelInputViewModel;
|
||||
DataModelVisualizationRegistration RegisterDataModelDisplay<T>(PluginInfo pluginInfo) where T : DataModelDisplayViewModel;
|
||||
|
||||
Reference in new issue
Block a user