mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Plugins - Implemented enabling/disabling (doesnt work for devices)
Plugins - Disable plugins that caused a crash Tray icon - Added menu items for quick access
This commit is contained in:
1 parent
16b221d2f8
commit
57d82fafa8
29 files changed
+442
-164
No files matched your search
@@ -0,0 +1,14 @@
|
||||
namespace Artemis.Plugins.Devices.WS281X.Settings
|
||||
{
|
||||
public class DeviceDefinition
|
||||
{
|
||||
public DeviceDefinitionType Type { get; set; }
|
||||
public string Port { get; set; }
|
||||
}
|
||||
|
||||
public enum DeviceDefinitionType
|
||||
{
|
||||
Arduino,
|
||||
Bitwizard
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -1,17 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Plugins.Devices.WS281X.Settings;
|
||||
|
||||
namespace Artemis.Plugins.Devices.WS281X.ViewModels
|
||||
{
|
||||
public class WS281XConfigurationViewModel : PluginConfigurationViewModel
|
||||
{
|
||||
public WS281XConfigurationViewModel(Plugin plugin) : base(plugin)
|
||||
private PluginSetting<List<DeviceDefinition>> _definitions;
|
||||
|
||||
public WS281XConfigurationViewModel(Plugin plugin, PluginSettings settings) : base(plugin)
|
||||
{
|
||||
var WS281XInstance = RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance;
|
||||
|
||||
_definitions = settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,47 @@
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.Abstract.ViewModels;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Plugins.Devices.WS281X.Settings;
|
||||
using Artemis.Plugins.Devices.WS281X.ViewModels;
|
||||
using RGB.NET.Devices.WS281X.Arduino;
|
||||
using RGB.NET.Devices.WS281X.Bitwizard;
|
||||
|
||||
namespace Artemis.Plugins.Devices.WS281X
|
||||
{
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public class WS281XDeviceProvider : DeviceProvider
|
||||
{
|
||||
public PluginSettings Settings { get; }
|
||||
private readonly IRgbService _rgbService;
|
||||
|
||||
public WS281XDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance)
|
||||
public WS281XDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService, PluginSettings settings) : base(pluginInfo, RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance)
|
||||
{
|
||||
Settings = settings;
|
||||
_rgbService = rgbService;
|
||||
HasConfigurationViewModel = true;
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
// TODO: Load from configuration
|
||||
//RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance.AddDeviceDefinition();
|
||||
var definitions = Settings.GetSetting<List<DeviceDefinition>>("DeviceDefinitions");
|
||||
foreach (var deviceDefinition in definitions.Value)
|
||||
{
|
||||
switch (deviceDefinition.Type)
|
||||
{
|
||||
case DeviceDefinitionType.Arduino:
|
||||
RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance.AddDeviceDefinition(new ArduinoWS281XDeviceDefinition(deviceDefinition.Port));
|
||||
break;
|
||||
case DeviceDefinitionType.Bitwizard:
|
||||
RGB.NET.Devices.WS281X.WS281XDeviceProvider.Instance.AddDeviceDefinition(new BitwizardWS281XDeviceDefinition(deviceDefinition.Port));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
_rgbService.AddDeviceProvider(RgbDeviceProvider);
|
||||
}
|
||||
|
||||
@@ -38,7 +59,7 @@ namespace Artemis.Plugins.Devices.WS281X
|
||||
|
||||
public override PluginConfigurationViewModel GetConfigurationViewModel()
|
||||
{
|
||||
return new WS281XConfigurationViewModel(this);
|
||||
return new WS281XConfigurationViewModel(this, Settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user