mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Core - Provide BitmapBrush with the currently active surface
UI - Small style change to the confirmation dialog Surface - Add API to get an ArtemisLed by its corresponding RGB.NET LED Devices - Add API to get an ArtemisLed by its corresponding RGB.NET LED Devices - Add API to get an ArtemisLed by its corresponding RGB.NET LedId
This commit is contained in:
1 parent
5b0e1c91dd
commit
f05740a5f1
10 files changed
+182
-38
No files matched your search
@@ -192,11 +192,11 @@ namespace Artemis.Core.Services
|
||||
if (UpdatePressedKeys(e.Device, e.Key, e.IsDown))
|
||||
return;
|
||||
|
||||
// Get the LED - TODO: leverage a lookup
|
||||
// Get the LED
|
||||
bool foundLedId = InputKeyUtilities.KeyboardKeyLedIdMap.TryGetValue(e.Key, out LedId ledId);
|
||||
ArtemisLed? led = null;
|
||||
if (foundLedId && e.Device != null)
|
||||
led = e.Device.Leds.FirstOrDefault(l => l.RgbLed.Id == ledId);
|
||||
led = e.Device.GetLed(ledId);
|
||||
|
||||
// Create the UpDown event args because it can be used for every event
|
||||
ArtemisKeyboardKeyUpDownEventArgs eventArgs = new ArtemisKeyboardKeyUpDownEventArgs(e.Device, led, e.Key, keyboardModifierKey, e.IsDown);
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace Artemis.Core.Services
|
||||
/// <summary>
|
||||
/// Recalculates the LED group used by the <see cref="BitmapBrush" />
|
||||
/// </summary>
|
||||
void UpdateSurfaceLedGroup();
|
||||
/// <param name="artemisSurface"></param>
|
||||
void UpdateSurfaceLedGroup(ArtemisSurface artemisSurface);
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,8 @@ namespace Artemis.Core.Services
|
||||
|
||||
private void RenderScaleSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
{
|
||||
UpdateSurfaceLedGroup();
|
||||
// The surface hasn't changed so we can safely reuse it
|
||||
UpdateSurfaceLedGroup(BitmapBrush?.Surface);
|
||||
}
|
||||
|
||||
private void TargetFrameRateSettingOnSettingChanged(object? sender, EventArgs e)
|
||||
@@ -107,8 +108,11 @@ namespace Artemis.Core.Services
|
||||
public event EventHandler<DeviceEventArgs>? DeviceLoaded;
|
||||
public event EventHandler<DeviceEventArgs>? DeviceReloaded;
|
||||
|
||||
public void UpdateSurfaceLedGroup()
|
||||
public void UpdateSurfaceLedGroup(ArtemisSurface? artemisSurface)
|
||||
{
|
||||
if (artemisSurface == null)
|
||||
return;
|
||||
|
||||
if (_surfaceLedGroup == null || BitmapBrush == null)
|
||||
{
|
||||
// Apply the application wide brush and decorator
|
||||
@@ -124,6 +128,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
// Apply the application wide brush and decorator
|
||||
BitmapBrush.Scale = new Scale(_renderScaleSetting.Value);
|
||||
BitmapBrush.Surface = artemisSurface;
|
||||
_surfaceLedGroup = new ListLedGroup(Surface.Leds) {Brush = BitmapBrush};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.Services.Models
|
||||
{
|
||||
internal class SurfaceArrangement
|
||||
{
|
||||
public SurfaceArrangement()
|
||||
{
|
||||
Devices = new List<SurfaceArrangementDevice>();
|
||||
}
|
||||
|
||||
public List<SurfaceArrangementDevice> Devices { get; }
|
||||
|
||||
internal static SurfaceArrangement GetDefaultArrangement()
|
||||
{
|
||||
SurfaceArrangement arrangement = new SurfaceArrangement();
|
||||
arrangement.Devices.Add(new SurfaceArrangementDevice(null, RGBDeviceType.Keyboard, ArrangementPosition.Right));
|
||||
return arrangement;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace Artemis.Core.Services.Models
|
||||
{
|
||||
internal class SurfaceArrangementDevice
|
||||
{
|
||||
public SurfaceArrangementDevice? Anchor { get; }
|
||||
public RGBDeviceType DeviceType { get; }
|
||||
public ArrangementPosition Position { get; }
|
||||
|
||||
public SurfaceArrangementDevice(SurfaceArrangementDevice? anchor, RGBDeviceType deviceType, ArrangementPosition position)
|
||||
{
|
||||
Anchor = anchor;
|
||||
DeviceType = deviceType;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public void Apply(ArtemisSurface surface)
|
||||
{
|
||||
List<ArtemisDevice> devices = surface.Devices.Where(d => d.RgbDevice.DeviceInfo.DeviceType == DeviceType).ToList();
|
||||
ArtemisDevice? previous = null;
|
||||
foreach (ArtemisDevice artemisDevice in devices)
|
||||
{
|
||||
if (previous != null)
|
||||
{
|
||||
|
||||
}
|
||||
previous = artemisDevice;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal enum ArrangementPosition
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom,
|
||||
Center
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace Artemis.Core.Services
|
||||
device.ApplyToRgbDevice();
|
||||
|
||||
// Update the RGB service's graphics decorator to work with the new surface entity
|
||||
_rgbService.UpdateSurfaceLedGroup();
|
||||
_rgbService.UpdateSurfaceLedGroup(ActiveSurface);
|
||||
OnActiveSurfaceConfigurationChanged(new SurfaceConfigurationEventArgs(ActiveSurface));
|
||||
}
|
||||
|
||||
@@ -104,9 +104,10 @@ namespace Artemis.Core.Services
|
||||
deviceConfiguration.ApplyToRgbDevice();
|
||||
}
|
||||
}
|
||||
surface.UpdateLedMap();
|
||||
|
||||
_surfaceRepository.Save(surface.SurfaceEntity);
|
||||
_rgbService.UpdateSurfaceLedGroup();
|
||||
_rgbService.UpdateSurfaceLedGroup(ActiveSurface);
|
||||
OnSurfaceConfigurationUpdated(new SurfaceConfigurationEventArgs(surface));
|
||||
}
|
||||
|
||||
@@ -199,6 +200,19 @@ namespace Artemis.Core.Services
|
||||
|
||||
#endregion
|
||||
|
||||
#region AutoLayout
|
||||
|
||||
public void AutoLayout()
|
||||
{
|
||||
// Phase one, bottom layer
|
||||
// Keyboard
|
||||
|
||||
// Phase two, top layer
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void RgbServiceOnDeviceLoaded(object? sender, DeviceEventArgs e)
|
||||
|
||||
Reference in new issue
Block a user