mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Added UI elements borrowed from DarthAffe
Added a WIP of profile classes
This commit is contained in:
1 parent
7d4c5dbae6
commit
0c47b9a2fb
23 files changed
+847
-108
No files matched your search
@@ -1,22 +1,26 @@
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
public class CoreService : ICoreService
|
||||
{
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly IDeviceService _deviceService;
|
||||
|
||||
public CoreService(IPluginService pluginService, IDeviceService deviceService)
|
||||
public CoreService(IPluginService pluginService, IRgbService rgbService)
|
||||
{
|
||||
_pluginService = pluginService;
|
||||
_deviceService = deviceService;
|
||||
_rgbService = rgbService;
|
||||
|
||||
Task.Run(Initialize);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Dispose services
|
||||
_pluginService.Dispose();
|
||||
}
|
||||
|
||||
@@ -24,9 +28,26 @@ namespace Artemis.Core.Services
|
||||
|
||||
private async Task Initialize()
|
||||
{
|
||||
if (IsInitialized)
|
||||
throw new ArtemisCoreException("Cannot initialize the core as it is already initialized.");
|
||||
|
||||
// Initialize the services
|
||||
await _pluginService.LoadPlugins();
|
||||
await _deviceService.LoadDevices();
|
||||
IsInitialized = true;
|
||||
await _rgbService.LoadDevices();
|
||||
|
||||
OnInitialized();
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler Initialized;
|
||||
|
||||
private void OnInitialized()
|
||||
{
|
||||
IsInitialized = true;
|
||||
Initialized?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
using System;
|
||||
using Artemis.Core.Events;
|
||||
|
||||
namespace Artemis.Core.Services.Interfaces
|
||||
{
|
||||
public interface ICoreService: IArtemisService, IDisposable
|
||||
{
|
||||
bool IsInitialized { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs the core has finished initializing
|
||||
/// </summary>
|
||||
event EventHandler Initialized;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.Services.Interfaces
|
||||
{
|
||||
public interface IRgbService : IArtemisService
|
||||
{
|
||||
bool LoadingDevices { get; }
|
||||
RGBSurface Surface { get; set; }
|
||||
Task LoadDevices();
|
||||
void Dispose();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a single device has loaded
|
||||
/// </summary>
|
||||
event EventHandler<DeviceEventArgs> DeviceLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a single device has reloaded
|
||||
/// </summary>
|
||||
event EventHandler<DeviceEventArgs> DeviceReloaded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when loading all devices has started
|
||||
/// </summary>
|
||||
event EventHandler StartingLoadingDevices;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when loading all devices has finished
|
||||
/// </summary>
|
||||
event EventHandler FinishedLoadedDevices;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ namespace Artemis.Core.Services
|
||||
public bool LoadingPlugins { get; private set; }
|
||||
public ReadOnlyCollection<PluginInfo> Plugins => _plugins.AsReadOnly();
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Loads all installed plugins. If plugins already loaded this will reload them all
|
||||
/// </summary>
|
||||
|
||||
+12
-28
@@ -11,21 +11,25 @@ using RGB.NET.Groups;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
public class DeviceService : IDeviceService, IDisposable
|
||||
public class RgbService : IRgbService, IDisposable
|
||||
{
|
||||
public DeviceService()
|
||||
public RgbService()
|
||||
{
|
||||
Surface = RGBSurface.Instance;
|
||||
LoadingDevices = false;
|
||||
|
||||
// Let's throw these for now
|
||||
Surface.Exception += SurfaceOnException;
|
||||
Surface.UpdateMode = UpdateMode.Continuous;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool LoadingDevices { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public RGBSurface Surface { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task LoadDevices()
|
||||
{
|
||||
OnStartedLoadingDevices();
|
||||
@@ -33,19 +37,19 @@ namespace Artemis.Core.Services
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// TODO SpoinkyNL 8-1-18: Keep settings into account
|
||||
// Surface.LoadDevices(AsusDeviceProvider.Instance);
|
||||
// Surface.LoadDevices(AsusDeviceProvider.Instance);
|
||||
Surface.LoadDevices(CorsairDeviceProvider.Instance);
|
||||
Surface.LoadDevices(LogitechDeviceProvider.Instance);
|
||||
Surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
|
||||
// Surface.LoadDevices(NovationDeviceProvider.Instance);
|
||||
|
||||
// Surface.LoadDevices(NovationDeviceProvider.Instance);
|
||||
|
||||
// TODO SpoinkyNL 8-1-18: Load alignment
|
||||
Surface.AlignDevies();
|
||||
|
||||
// Do some testing, why does this work, how does it know I want to target the surface? Check source!
|
||||
var ledGroup = new RectangleLedGroup(Surface.SurfaceRectangle)
|
||||
{
|
||||
Brush = new SolidColorBrush(new Color(255, 0, 0)) {BrushCalculationMode = BrushCalculationMode.Absolute}
|
||||
Brush = new SolidColorBrush(new Color(255, 0, 0)) { BrushCalculationMode = BrushCalculationMode.Absolute }
|
||||
};
|
||||
Surface.UpdateMode = UpdateMode.Continuous;
|
||||
});
|
||||
@@ -65,24 +69,9 @@ namespace Artemis.Core.Services
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a single device has loaded
|
||||
/// </summary>
|
||||
public event EventHandler<DeviceEventArgs> DeviceLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a single device has reloaded
|
||||
/// </summary>
|
||||
public event EventHandler<DeviceEventArgs> DeviceReloaded;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when loading all devices has started
|
||||
/// </summary>
|
||||
public event EventHandler StartedLoadingDevices;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when loading all devices has finished
|
||||
/// </summary>
|
||||
public event EventHandler StartingLoadingDevices;
|
||||
public event EventHandler FinishedLoadedDevices;
|
||||
|
||||
private void OnDeviceLoaded(DeviceEventArgs e)
|
||||
@@ -98,7 +87,7 @@ namespace Artemis.Core.Services
|
||||
private void OnStartedLoadingDevices()
|
||||
{
|
||||
LoadingDevices = true;
|
||||
StartedLoadingDevices?.Invoke(this, EventArgs.Empty);
|
||||
StartingLoadingDevices?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void OnFinishedLoadedDevices()
|
||||
@@ -109,9 +98,4 @@ namespace Artemis.Core.Services
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public interface IDeviceService : IArtemisService
|
||||
{
|
||||
Task LoadDevices();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user