mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Plugins - Added optional configuration window
Plugins - Moved plugins to their own directory Device providers - Added all RGB.NET device providers
This commit is contained in:
1 parent
13943f86a7
commit
9b62ba5f3d
752 files changed
+2198
-73
No files matched your search
@@ -25,8 +25,6 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
if (sender.GetType().IsGenericType(type))
|
||||
{
|
||||
Debug.WriteLine(e.RelativePart);
|
||||
Debug.WriteLine(e.FileName);
|
||||
// Start from the plugin directory
|
||||
if (e.RelativePart != null && e.FileName != null)
|
||||
e.FinalPath = Path.Combine(PluginInfo.Directory.FullName, e.RelativePart, e.FileName);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using SkiaSharp;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
@@ -16,6 +17,12 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
|
||||
public PluginInfo PluginInfo { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this plugin has a configuration view model.
|
||||
/// If set to true, <see cref="GetConfigurationViewModel" /> will be called when the plugin is configured from the UI.
|
||||
/// </summary>
|
||||
public bool HasConfigurationViewModel { get; protected set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Called when the plugin is unloaded, clean up any unmanaged resources here
|
||||
@@ -31,5 +38,15 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
/// Called when the plugin is deactivated
|
||||
/// </summary>
|
||||
public abstract void DisablePlugin();
|
||||
|
||||
/// <summary>
|
||||
/// Called when the plugin's configuration window is opened from the UI. The UI will only attempt to open if
|
||||
/// <see cref="HasConfigurationViewModel" /> is set to True.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual PluginConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract
|
||||
namespace Artemis.Core.Plugins.Abstract.ViewModels
|
||||
{
|
||||
public abstract class ModuleViewModel : Screen
|
||||
{
|
||||
@@ -0,0 +1,14 @@
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core.Plugins.Abstract.ViewModels
|
||||
{
|
||||
public abstract class PluginConfigurationViewModel : Screen
|
||||
{
|
||||
protected PluginConfigurationViewModel(Plugin plugin)
|
||||
{
|
||||
Plugin = plugin;
|
||||
}
|
||||
|
||||
public Plugin Plugin { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,11 @@ namespace Artemis.Core.Plugins.Models
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public string Name { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// A short description of the plugin
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The version of the plugin
|
||||
/// </summary>
|
||||
@@ -62,7 +67,7 @@ namespace Artemis.Core.Plugins.Models
|
||||
internal PluginLoader PluginLoader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The assembly the plugin code lives in
|
||||
/// The assembly the plugin code lives in
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
internal Assembly Assembly { get; set; }
|
||||
|
||||
@@ -28,7 +28,18 @@ namespace Artemis.Core.Services.Interfaces
|
||||
/// </summary>
|
||||
IReadOnlyCollection<IRGBDevice> LoadedDevices { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds the given device provider to the <see cref="Surface" />
|
||||
/// </summary>
|
||||
/// <param name="deviceProvider"></param>
|
||||
void AddDeviceProvider(IRGBDeviceProvider deviceProvider);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given device provider from the <see cref="Surface" /> by recreating it without the device provider
|
||||
/// </summary>
|
||||
/// <param name="deviceProvider"></param>
|
||||
void RemoveDeviceProvider(IRGBDeviceProvider deviceProvider);
|
||||
|
||||
void Dispose();
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.RGB.NET;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
@@ -16,13 +18,14 @@ namespace Artemis.Core.Services
|
||||
public class RgbService : IRgbService, IDisposable
|
||||
{
|
||||
private readonly List<IRGBDevice> _loadedDevices;
|
||||
private readonly List<IRGBDeviceProvider> _loadedDeviceProviders;
|
||||
private readonly ILogger _logger;
|
||||
private readonly PluginSetting<double> _renderScaleSetting;
|
||||
private readonly PluginSetting<int> _sampleSizeSetting;
|
||||
private readonly PluginSetting<int> _targetFrameRateSetting;
|
||||
private readonly TimerUpdateTrigger _updateTrigger;
|
||||
private ListLedGroup _surfaceLedGroup;
|
||||
|
||||
|
||||
internal RgbService(ILogger logger, ISettingsService settingsService)
|
||||
{
|
||||
_logger = logger;
|
||||
@@ -37,6 +40,7 @@ namespace Artemis.Core.Services
|
||||
_renderScaleSetting.SettingChanged += RenderScaleSettingOnSettingChanged;
|
||||
_targetFrameRateSetting.SettingChanged += TargetFrameRateSettingOnSettingChanged;
|
||||
_loadedDevices = new List<IRGBDevice>();
|
||||
_loadedDeviceProviders = new List<IRGBDeviceProvider>();
|
||||
_updateTrigger = new TimerUpdateTrigger {UpdateFrequency = 1.0 / _targetFrameRateSetting.Value};
|
||||
Surface.RegisterUpdateTrigger(_updateTrigger);
|
||||
}
|
||||
@@ -52,7 +56,11 @@ namespace Artemis.Core.Services
|
||||
|
||||
public void AddDeviceProvider(IRGBDeviceProvider deviceProvider)
|
||||
{
|
||||
if (_loadedDeviceProviders.Contains(deviceProvider))
|
||||
return;
|
||||
|
||||
Surface.LoadDevices(deviceProvider);
|
||||
_loadedDeviceProviders.Add(deviceProvider);
|
||||
|
||||
if (deviceProvider.Devices == null)
|
||||
{
|
||||
@@ -72,6 +80,12 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveDeviceProvider(IRGBDeviceProvider deviceProvider)
|
||||
{
|
||||
if (!_loadedDeviceProviders.Contains(deviceProvider))
|
||||
return;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Surface.UnregisterUpdateTrigger(_updateTrigger);
|
||||
|
||||
Reference in new issue
Block a user