mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Code style - Use file scoped namespaces
Code style - Ran code cleanup
This commit is contained in:
1 parent
e68e16df4d
commit
f6090dc296
691 files changed
+37301
-38119
No files matched your search
@@ -3,66 +3,65 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Modules;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
internal class DataModelService : IDataModelService
|
||||
{
|
||||
internal class DataModelService : IDataModelService
|
||||
public DataModelService(IPluginManagementService pluginManagementService)
|
||||
{
|
||||
public DataModelService(IPluginManagementService pluginManagementService)
|
||||
{
|
||||
// Add data models of already loaded plugins
|
||||
foreach (Module module in pluginManagementService.GetFeaturesOfType<Module>().Where(p => p.IsEnabled))
|
||||
AddModuleDataModel(module);
|
||||
// Add data models of already loaded plugins
|
||||
foreach (Module module in pluginManagementService.GetFeaturesOfType<Module>().Where(p => p.IsEnabled))
|
||||
AddModuleDataModel(module);
|
||||
|
||||
// Add data models of new plugins when they get enabled
|
||||
pluginManagementService.PluginFeatureEnabled += OnPluginFeatureEnabled;
|
||||
}
|
||||
// Add data models of new plugins when they get enabled
|
||||
pluginManagementService.PluginFeatureEnabled += OnPluginFeatureEnabled;
|
||||
}
|
||||
|
||||
private void OnPluginFeatureEnabled(object? sender, PluginFeatureEventArgs e)
|
||||
{
|
||||
if (e.PluginFeature is Module module)
|
||||
AddModuleDataModel(module);
|
||||
}
|
||||
|
||||
private void AddModuleDataModel(Module module)
|
||||
{
|
||||
if (module.InternalDataModel == null)
|
||||
return;
|
||||
|
||||
if (module.InternalDataModel.DataModelDescription == null)
|
||||
throw new ArtemisPluginFeatureException(module, "Module overrides GetDataModelDescription but returned null");
|
||||
|
||||
module.InternalDataModel.IsExpansion = module.IsAlwaysAvailable;
|
||||
RegisterDataModel(module.InternalDataModel);
|
||||
}
|
||||
|
||||
|
||||
public DataModelRegistration RegisterDataModel(DataModel dataModel)
|
||||
{
|
||||
if (dataModel == null)
|
||||
throw new ArgumentNullException(nameof(dataModel));
|
||||
return DataModelStore.Add(dataModel);
|
||||
}
|
||||
public DataModelRegistration RegisterDataModel(DataModel dataModel)
|
||||
{
|
||||
if (dataModel == null)
|
||||
throw new ArgumentNullException(nameof(dataModel));
|
||||
return DataModelStore.Add(dataModel);
|
||||
}
|
||||
|
||||
public void RemoveDataModel(DataModelRegistration registration)
|
||||
{
|
||||
if (registration == null)
|
||||
throw new ArgumentNullException(nameof(registration));
|
||||
DataModelStore.Remove(registration);
|
||||
}
|
||||
public void RemoveDataModel(DataModelRegistration registration)
|
||||
{
|
||||
if (registration == null)
|
||||
throw new ArgumentNullException(nameof(registration));
|
||||
DataModelStore.Remove(registration);
|
||||
}
|
||||
|
||||
public List<DataModel> GetDataModels()
|
||||
{
|
||||
return DataModelStore.GetAll().Select(d => d.DataModel).ToList();
|
||||
}
|
||||
public List<DataModel> GetDataModels()
|
||||
{
|
||||
return DataModelStore.GetAll().Select(d => d.DataModel).ToList();
|
||||
}
|
||||
|
||||
public T? GetDataModel<T>() where T : DataModel
|
||||
{
|
||||
return (T?) DataModelStore.GetAll().FirstOrDefault(d => d.DataModel is T)?.DataModel;
|
||||
}
|
||||
public T? GetDataModel<T>() where T : DataModel
|
||||
{
|
||||
return (T?) DataModelStore.GetAll().FirstOrDefault(d => d.DataModel is T)?.DataModel;
|
||||
}
|
||||
|
||||
public DataModel? GetPluginDataModel(PluginFeature pluginFeature)
|
||||
{
|
||||
return DataModelStore.Get(pluginFeature.Id)?.DataModel;
|
||||
}
|
||||
|
||||
private void OnPluginFeatureEnabled(object? sender, PluginFeatureEventArgs e)
|
||||
{
|
||||
if (e.PluginFeature is Module module)
|
||||
AddModuleDataModel(module);
|
||||
}
|
||||
|
||||
private void AddModuleDataModel(Module module)
|
||||
{
|
||||
if (module.InternalDataModel == null)
|
||||
return;
|
||||
|
||||
if (module.InternalDataModel.DataModelDescription == null)
|
||||
throw new ArtemisPluginFeatureException(module, "Module overrides GetDataModelDescription but returned null");
|
||||
|
||||
module.InternalDataModel.IsExpansion = module.IsAlwaysAvailable;
|
||||
RegisterDataModel(module.InternalDataModel);
|
||||
}
|
||||
public DataModel? GetPluginDataModel(PluginFeature pluginFeature)
|
||||
{
|
||||
return DataModelStore.Get(pluginFeature.Id)?.DataModel;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Modules;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
/// <summary>
|
||||
/// A service that allows you to register and retrieve data models
|
||||
/// </summary>
|
||||
public interface IDataModelService : IArtemisService
|
||||
{
|
||||
/// <summary>
|
||||
/// A service that allows you to register and retrieve data models
|
||||
/// Add a data model to so that it is available to conditions and data bindings
|
||||
/// </summary>
|
||||
public interface IDataModelService : IArtemisService
|
||||
{
|
||||
/// <summary>
|
||||
/// Add a data model to so that it is available to conditions and data bindings
|
||||
/// </summary>
|
||||
/// <param name="dataModel"></param>
|
||||
DataModelRegistration RegisterDataModel(DataModel dataModel);
|
||||
/// <param name="dataModel"></param>
|
||||
DataModelRegistration RegisterDataModel(DataModel dataModel);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a previously added data model so that it is no longer available
|
||||
/// </summary>
|
||||
void RemoveDataModel(DataModelRegistration registration);
|
||||
/// <summary>
|
||||
/// Remove a previously added data model so that it is no longer available
|
||||
/// </summary>
|
||||
void RemoveDataModel(DataModelRegistration registration);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of all registered data models
|
||||
/// </summary>
|
||||
List<DataModel> GetDataModels();
|
||||
/// <summary>
|
||||
/// Returns a list of all registered data models
|
||||
/// </summary>
|
||||
List<DataModel> GetDataModels();
|
||||
|
||||
/// <summary>
|
||||
/// If found, returns the registered data model of type <typeparamref name="T" />
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data model to find</typeparam>
|
||||
T? GetDataModel<T>() where T : DataModel;
|
||||
/// <summary>
|
||||
/// If found, returns the registered data model of type <typeparamref name="T" />
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the data model to find</typeparam>
|
||||
T? GetDataModel<T>() where T : DataModel;
|
||||
|
||||
/// <summary>
|
||||
/// If found, returns the data model of the provided plugin
|
||||
/// </summary>
|
||||
/// <param name="pluginFeature">The plugin to find the data model of</param>
|
||||
DataModel? GetPluginDataModel(PluginFeature pluginFeature);
|
||||
}
|
||||
/// <summary>
|
||||
/// If found, returns the data model of the provided plugin
|
||||
/// </summary>
|
||||
/// <param name="pluginFeature">The plugin to find the data model of</param>
|
||||
DataModel? GetPluginDataModel(PluginFeature pluginFeature);
|
||||
}
|
||||
@@ -1,37 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
/// <summary>
|
||||
/// A service that allows you to register and retrieve layer brushes
|
||||
/// </summary>
|
||||
public interface ILayerBrushService : IArtemisService
|
||||
{
|
||||
/// <summary>
|
||||
/// A service that allows you to register and retrieve layer brushes
|
||||
/// Add a layer brush descriptor so that it is available to layers
|
||||
/// </summary>
|
||||
public interface ILayerBrushService : IArtemisService
|
||||
{
|
||||
/// <summary>
|
||||
/// Add a layer brush descriptor so that it is available to layers
|
||||
/// </summary>
|
||||
LayerBrushRegistration RegisterLayerBrush(LayerBrushDescriptor descriptor);
|
||||
LayerBrushRegistration RegisterLayerBrush(LayerBrushDescriptor descriptor);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a previously added layer brush descriptor so that it is no longer available
|
||||
/// </summary>
|
||||
void RemoveLayerBrush(LayerBrushRegistration registration);
|
||||
/// <summary>
|
||||
/// Remove a previously added layer brush descriptor so that it is no longer available
|
||||
/// </summary>
|
||||
void RemoveLayerBrush(LayerBrushRegistration registration);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of all registered layer brush descriptors
|
||||
/// </summary>
|
||||
List<LayerBrushDescriptor> GetLayerBrushes();
|
||||
/// <summary>
|
||||
/// Returns a list of all registered layer brush descriptors
|
||||
/// </summary>
|
||||
List<LayerBrushDescriptor> GetLayerBrushes();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the descriptor of the default layer brush
|
||||
/// </summary>
|
||||
LayerBrushDescriptor? GetDefaultLayerBrush();
|
||||
/// <summary>
|
||||
/// Returns the descriptor of the default layer brush
|
||||
/// </summary>
|
||||
LayerBrushDescriptor? GetDefaultLayerBrush();
|
||||
|
||||
/// <summary>
|
||||
/// Applies the configured default brush to the provided <paramref name="layer" />.
|
||||
/// </summary>
|
||||
/// <param name="layer">The layer to apply the default brush to.</param>
|
||||
void ApplyDefaultBrush(Layer layer);
|
||||
}
|
||||
/// <summary>
|
||||
/// Applies the configured default brush to the provided <paramref name="layer" />.
|
||||
/// </summary>
|
||||
/// <param name="layer">The layer to apply the default brush to.</param>
|
||||
void ApplyDefaultBrush(Layer layer);
|
||||
}
|
||||
@@ -1,27 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
using Artemis.Core.LayerEffects;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
/// <summary>
|
||||
/// A service that allows you to register and retrieve layer brushes
|
||||
/// </summary>
|
||||
public interface ILayerEffectService : IArtemisService
|
||||
{
|
||||
/// <summary>
|
||||
/// A service that allows you to register and retrieve layer brushes
|
||||
/// Add an effect descriptor so that it is available to profile elements
|
||||
/// </summary>
|
||||
public interface ILayerEffectService : IArtemisService
|
||||
{
|
||||
/// <summary>
|
||||
/// Add an effect descriptor so that it is available to profile elements
|
||||
/// </summary>
|
||||
LayerEffectRegistration RegisterLayerEffect(LayerEffectDescriptor descriptor);
|
||||
LayerEffectRegistration RegisterLayerEffect(LayerEffectDescriptor descriptor);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a previously added layer effect descriptor so that it is no longer available
|
||||
/// </summary>
|
||||
void RemoveLayerEffect(LayerEffectRegistration registration);
|
||||
/// <summary>
|
||||
/// Remove a previously added layer effect descriptor so that it is no longer available
|
||||
/// </summary>
|
||||
void RemoveLayerEffect(LayerEffectRegistration registration);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of all registered layer effect descriptors
|
||||
/// </summary>
|
||||
List<LayerEffectDescriptor> GetLayerEffects();
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns a list of all registered layer effect descriptors
|
||||
/// </summary>
|
||||
List<LayerEffectDescriptor> GetLayerEffects();
|
||||
}
|
||||
@@ -3,56 +3,55 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
internal class LayerBrushService : ILayerBrushService
|
||||
{
|
||||
internal class LayerBrushService : ILayerBrushService
|
||||
private readonly ISettingsService _settingsService;
|
||||
|
||||
public LayerBrushService(ISettingsService settingsService)
|
||||
{
|
||||
private readonly ISettingsService _settingsService;
|
||||
_settingsService = settingsService;
|
||||
}
|
||||
|
||||
public LayerBrushService(ISettingsService settingsService)
|
||||
public LayerBrushRegistration RegisterLayerBrush(LayerBrushDescriptor descriptor)
|
||||
{
|
||||
if (descriptor == null)
|
||||
throw new ArgumentNullException(nameof(descriptor));
|
||||
|
||||
return LayerBrushStore.Add(descriptor);
|
||||
}
|
||||
|
||||
public void RemoveLayerBrush(LayerBrushRegistration registration)
|
||||
{
|
||||
if (registration == null)
|
||||
throw new ArgumentNullException(nameof(registration));
|
||||
LayerBrushStore.Remove(registration);
|
||||
}
|
||||
|
||||
public List<LayerBrushDescriptor> GetLayerBrushes()
|
||||
{
|
||||
return LayerBrushStore.GetAll().Select(r => r.LayerBrushDescriptor).ToList();
|
||||
}
|
||||
|
||||
public LayerBrushDescriptor? GetDefaultLayerBrush()
|
||||
{
|
||||
PluginSetting<LayerBrushReference> defaultReference = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference
|
||||
{
|
||||
_settingsService = settingsService;
|
||||
}
|
||||
LayerBrushProviderId = "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba",
|
||||
BrushType = "SolidBrush"
|
||||
});
|
||||
|
||||
public LayerBrushRegistration RegisterLayerBrush(LayerBrushDescriptor descriptor)
|
||||
{
|
||||
if (descriptor == null)
|
||||
throw new ArgumentNullException(nameof(descriptor));
|
||||
defaultReference.Value.LayerBrushProviderId ??= "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba";
|
||||
defaultReference.Value.BrushType ??= "SolidBrush";
|
||||
return LayerBrushStore.Get(defaultReference.Value.LayerBrushProviderId, defaultReference.Value.BrushType)?.LayerBrushDescriptor;
|
||||
}
|
||||
|
||||
return LayerBrushStore.Add(descriptor);
|
||||
}
|
||||
|
||||
public void RemoveLayerBrush(LayerBrushRegistration registration)
|
||||
{
|
||||
if (registration == null)
|
||||
throw new ArgumentNullException(nameof(registration));
|
||||
LayerBrushStore.Remove(registration);
|
||||
}
|
||||
|
||||
public List<LayerBrushDescriptor> GetLayerBrushes()
|
||||
{
|
||||
return LayerBrushStore.GetAll().Select(r => r.LayerBrushDescriptor).ToList();
|
||||
}
|
||||
|
||||
public LayerBrushDescriptor? GetDefaultLayerBrush()
|
||||
{
|
||||
PluginSetting<LayerBrushReference> defaultReference = _settingsService.GetSetting("ProfileEditor.DefaultLayerBrushDescriptor", new LayerBrushReference
|
||||
{
|
||||
LayerBrushProviderId = "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba",
|
||||
BrushType = "SolidBrush"
|
||||
});
|
||||
|
||||
defaultReference.Value.LayerBrushProviderId ??= "Artemis.Plugins.LayerBrushes.Color.ColorBrushProvider-92a9d6ba";
|
||||
defaultReference.Value.BrushType ??= "SolidBrush";
|
||||
return LayerBrushStore.Get(defaultReference.Value.LayerBrushProviderId, defaultReference.Value.BrushType)?.LayerBrushDescriptor;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ApplyDefaultBrush(Layer layer)
|
||||
{
|
||||
LayerBrushDescriptor? brush = GetDefaultLayerBrush();
|
||||
if (brush != null)
|
||||
layer.ChangeLayerBrush(brush.CreateInstance(layer, null));
|
||||
}
|
||||
/// <inheritdoc />
|
||||
public void ApplyDefaultBrush(Layer layer)
|
||||
{
|
||||
LayerBrushDescriptor? brush = GetDefaultLayerBrush();
|
||||
if (brush != null)
|
||||
layer.ChangeLayerBrush(brush.CreateInstance(layer, null));
|
||||
}
|
||||
}
|
||||
@@ -3,28 +3,27 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.LayerEffects;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
namespace Artemis.Core.Services;
|
||||
|
||||
internal class LayerEffectService : ILayerEffectService
|
||||
{
|
||||
internal class LayerEffectService : ILayerEffectService
|
||||
public LayerEffectRegistration RegisterLayerEffect(LayerEffectDescriptor descriptor)
|
||||
{
|
||||
public LayerEffectRegistration RegisterLayerEffect(LayerEffectDescriptor descriptor)
|
||||
{
|
||||
if (descriptor == null)
|
||||
throw new ArgumentNullException(nameof(descriptor));
|
||||
if (descriptor == null)
|
||||
throw new ArgumentNullException(nameof(descriptor));
|
||||
|
||||
return LayerEffectStore.Add(descriptor);
|
||||
}
|
||||
return LayerEffectStore.Add(descriptor);
|
||||
}
|
||||
|
||||
public void RemoveLayerEffect(LayerEffectRegistration registration)
|
||||
{
|
||||
if (registration == null)
|
||||
throw new ArgumentNullException(nameof(registration));
|
||||
LayerEffectStore.Remove(registration);
|
||||
}
|
||||
public void RemoveLayerEffect(LayerEffectRegistration registration)
|
||||
{
|
||||
if (registration == null)
|
||||
throw new ArgumentNullException(nameof(registration));
|
||||
LayerEffectStore.Remove(registration);
|
||||
}
|
||||
|
||||
public List<LayerEffectDescriptor> GetLayerEffects()
|
||||
{
|
||||
return LayerEffectStore.GetAll().Select(r => r.LayerEffectDescriptor).ToList();
|
||||
}
|
||||
public List<LayerEffectDescriptor> GetLayerEffects()
|
||||
{
|
||||
return LayerEffectStore.GetAll().Select(r => r.LayerEffectDescriptor).ToList();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user