Added Corsair support as a plugin

This commit is contained in:
SpoinkyNL committed 2019-08-11 16:58:43 +02:00
1 parent 6e23c079b1
commit 8cd8b051f7
25 files changed
+302 -131

No files matched your search

+22 -56
View File
@@ -6,7 +6,6 @@ using Artemis.Core.RGB.NET;
using Artemis.Core.Services.Interfaces;
using RGB.NET.Brushes;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair;
using RGB.NET.Groups;
namespace Artemis.Core.Services
@@ -39,49 +38,30 @@ namespace Artemis.Core.Services
public RGBSurface Surface { get; set; }
public GraphicsDecorator GraphicsDecorator { get; private set; }
/// <inheritdoc />
public async Task LoadDevices()
public void AddDeviceProvider(IRGBDeviceProvider deviceProvider)
{
OnStartedLoadingDevices();
Surface.LoadDevices(deviceProvider);
Surface.AlignDevices();
await Task.Run(() =>
{
// TODO SpoinkyNL 8-1-18: Keep settings into account
// This one doesn't work well without ASUS devices installed
// Surface.LoadDevices(AsusDeviceProvider.Instance);
// Surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
Surface.LoadDevices(CorsairDeviceProvider.Instance);
// Surface.LoadDevices(DMXDeviceProvider.Instance);
// Surface.LoadDevices(LogitechDeviceProvider.Instance);
// Surface.LoadDevices(MsiDeviceProvider.Instance);
// Surface.LoadDevices(NovationDeviceProvider.Instance);
// Surface.LoadDevices(RazerDeviceProvider.Instance);
lock (_loadedDevices)
{
foreach (var surfaceDevice in deviceProvider.Devices)
{
if (!_loadedDevices.Contains(surfaceDevice))
{
_loadedDevices.Add(surfaceDevice);
OnDeviceLoaded(new DeviceEventArgs(surfaceDevice));
}
else
OnDeviceReloaded(new DeviceEventArgs(surfaceDevice));
}
}
// TODO SpoinkyNL 8-1-18: Load alignment
Surface.AlignDevices();
lock (_loadedDevices)
{
foreach (var surfaceDevice in Surface.Devices)
{
if (!_loadedDevices.Contains(surfaceDevice))
{
_loadedDevices.Add(surfaceDevice);
OnDeviceLoaded(new DeviceEventArgs(surfaceDevice));
}
else
OnDeviceReloaded(new DeviceEventArgs(surfaceDevice));
}
}
});
// Apply the application wide brush and decorator
var background = new ListLedGroup(Surface.Leds) {Brush = new SolidColorBrush(new Color(255, 255, 255, 255))};
GraphicsDecorator = new GraphicsDecorator(background);
background.Brush.AddDecorator(GraphicsDecorator);
OnFinishedLoadedDevices();
// Apply the application wide brush and decorator
var background = new ListLedGroup(Surface.Leds) { Brush = new SolidColorBrush(new Color(255, 255, 255, 255)) };
GraphicsDecorator = new GraphicsDecorator(background);
background.Brush.AddDecorator(GraphicsDecorator);
}
public void Dispose()
@@ -101,8 +81,6 @@ namespace Artemis.Core.Services
public event EventHandler<DeviceEventArgs> DeviceLoaded;
public event EventHandler<DeviceEventArgs> DeviceReloaded;
public event EventHandler StartingLoadingDevices;
public event EventHandler FinishedLoadedDevices;
private void OnDeviceLoaded(DeviceEventArgs e)
{
@@ -113,19 +91,7 @@ namespace Artemis.Core.Services
{
DeviceReloaded?.Invoke(this, e);
}
private void OnStartedLoadingDevices()
{
LoadingDevices = true;
StartingLoadingDevices?.Invoke(this, EventArgs.Empty);
}
private void OnFinishedLoadedDevices()
{
LoadingDevices = false;
FinishedLoadedDevices?.Invoke(this, EventArgs.Empty);
}
#endregion
}
}