mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Profile editor - Fix race condition causing the editor to fail to activate on suspended profiles
Surface editor - Implemented left-handed preset
This commit is contained in:
1 parent
108cbaae3d
commit
06c5294e88
12 files changed
+99
-51
No files matched your search
@@ -157,10 +157,11 @@ internal class DeviceService : IDeviceService
|
||||
}
|
||||
}
|
||||
|
||||
/// <param name="leftHanded"></param>
|
||||
/// <inheritdoc />
|
||||
public void AutoArrangeDevices()
|
||||
public void AutoArrangeDevices(bool leftHanded)
|
||||
{
|
||||
SurfaceArrangement surfaceArrangement = SurfaceArrangement.GetDefaultArrangement();
|
||||
SurfaceArrangement surfaceArrangement = SurfaceArrangement.GetDefaultArrangement(leftHanded);
|
||||
surfaceArrangement.Arrange(_devices);
|
||||
foreach (ArtemisDevice artemisDevice in _devices)
|
||||
artemisDevice.ApplyDefaultCategories();
|
||||
|
||||
@@ -46,7 +46,8 @@ public interface IDeviceService : IArtemisService
|
||||
/// <summary>
|
||||
/// Applies auto-arranging logic to the surface
|
||||
/// </summary>
|
||||
void AutoArrangeDevices();
|
||||
/// <param name="leftHanded"></param>
|
||||
void AutoArrangeDevices(bool leftHanded);
|
||||
|
||||
/// <summary>
|
||||
/// Apples the best available to the provided <see cref="ArtemisDevice" />
|
||||
|
||||
@@ -48,22 +48,42 @@ internal class SurfaceArrangement
|
||||
}
|
||||
}
|
||||
|
||||
internal static SurfaceArrangement GetDefaultArrangement()
|
||||
internal static SurfaceArrangement GetDefaultArrangement(bool leftHanded)
|
||||
{
|
||||
SurfaceArrangement arrangement = new();
|
||||
|
||||
SurfaceArrangementType keypad = arrangement.AddType(RGBDeviceType.Keypad, 1);
|
||||
keypad.AddConfiguration(new SurfaceArrangementConfiguration(null, HorizontalArrangementPosition.Equal, VerticalArrangementPosition.Equal, 20));
|
||||
SurfaceArrangementType keyboard, keypad, mousepad, mouse;
|
||||
if (leftHanded)
|
||||
{
|
||||
mousepad = arrangement.AddType(RGBDeviceType.Mousepad, 1);
|
||||
mousepad.AddConfiguration(new SurfaceArrangementConfiguration(null, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Equal, 10));
|
||||
|
||||
SurfaceArrangementType keyboard = arrangement.AddType(RGBDeviceType.Keyboard, 1);
|
||||
keyboard.AddConfiguration(new SurfaceArrangementConfiguration(keypad, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Equal, 20));
|
||||
mouse = arrangement.AddType(RGBDeviceType.Mouse, 2);
|
||||
mouse.AddConfiguration(new SurfaceArrangementConfiguration(mousepad, HorizontalArrangementPosition.Center, VerticalArrangementPosition.Center, 0));
|
||||
mouse.AddConfiguration(new SurfaceArrangementConfiguration(null, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Center, 10));
|
||||
|
||||
SurfaceArrangementType mousepad = arrangement.AddType(RGBDeviceType.Mousepad, 1);
|
||||
mousepad.AddConfiguration(new SurfaceArrangementConfiguration(keyboard, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Equal, 10));
|
||||
keyboard = arrangement.AddType(RGBDeviceType.Keyboard, 1);
|
||||
keyboard.AddConfiguration(new SurfaceArrangementConfiguration(mousepad, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Equal, 10));
|
||||
keyboard.AddConfiguration(new SurfaceArrangementConfiguration(mouse, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Equal, 100));
|
||||
|
||||
SurfaceArrangementType mouse = arrangement.AddType(RGBDeviceType.Mouse, 2);
|
||||
mouse.AddConfiguration(new SurfaceArrangementConfiguration(mousepad, HorizontalArrangementPosition.Center, VerticalArrangementPosition.Center, 0));
|
||||
mouse.AddConfiguration(new SurfaceArrangementConfiguration(keyboard, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Center, 100));
|
||||
keypad = arrangement.AddType(RGBDeviceType.Keypad, 1);
|
||||
keypad.AddConfiguration(new SurfaceArrangementConfiguration(keyboard, HorizontalArrangementPosition.Equal, VerticalArrangementPosition.Equal, 20));
|
||||
}
|
||||
else
|
||||
{
|
||||
keypad = arrangement.AddType(RGBDeviceType.Keypad, 1);
|
||||
keypad.AddConfiguration(new SurfaceArrangementConfiguration(null, HorizontalArrangementPosition.Equal, VerticalArrangementPosition.Equal, 20));
|
||||
|
||||
keyboard = arrangement.AddType(RGBDeviceType.Keyboard, 1);
|
||||
keyboard.AddConfiguration(new SurfaceArrangementConfiguration(keypad, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Equal, 20));
|
||||
|
||||
mousepad = arrangement.AddType(RGBDeviceType.Mousepad, 1);
|
||||
mousepad.AddConfiguration(new SurfaceArrangementConfiguration(keyboard, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Equal, 10));
|
||||
|
||||
mouse = arrangement.AddType(RGBDeviceType.Mouse, 2);
|
||||
mouse.AddConfiguration(new SurfaceArrangementConfiguration(mousepad, HorizontalArrangementPosition.Center, VerticalArrangementPosition.Center, 0));
|
||||
mouse.AddConfiguration(new SurfaceArrangementConfiguration(keyboard, HorizontalArrangementPosition.Right, VerticalArrangementPosition.Center, 100));
|
||||
}
|
||||
|
||||
SurfaceArrangementType headset = arrangement.AddType(RGBDeviceType.Headset, 1);
|
||||
headset.AddConfiguration(new SurfaceArrangementConfiguration(keyboard, HorizontalArrangementPosition.Center, VerticalArrangementPosition.Bottom, 100));
|
||||
|
||||
@@ -32,7 +32,7 @@ internal class SurfaceArrangementConfiguration
|
||||
public int MarginBottom { get; }
|
||||
public SurfaceArrangement SurfaceArrangement { get; set; }
|
||||
|
||||
public bool Apply(List<ArtemisDevice> devices)
|
||||
public bool Apply(List<ArtemisDevice> devicesToArrange, List<ArtemisDevice> devices)
|
||||
{
|
||||
if (Anchor != null && !Anchor.HasDevices(devices))
|
||||
return false;
|
||||
@@ -42,10 +42,10 @@ internal class SurfaceArrangementConfiguration
|
||||
new SurfaceArrangementType(SurfaceArrangement, RGBDeviceType.All, 1).GetEdge(HorizontalPosition, VerticalPosition);
|
||||
|
||||
// Stack multiple devices of the same type vertically if they are wider than they are tall
|
||||
bool stackVertically = devices.Average(d => d.RgbDevice.Size.Width) >= devices.Average(d => d.RgbDevice.Size.Height);
|
||||
bool stackVertically = devicesToArrange.Average(d => d.RgbDevice.Size.Width) >= devicesToArrange.Average(d => d.RgbDevice.Size.Height);
|
||||
|
||||
ArtemisDevice? previous = null;
|
||||
foreach (ArtemisDevice artemisDevice in devices)
|
||||
foreach (ArtemisDevice artemisDevice in devicesToArrange)
|
||||
{
|
||||
if (previous != null)
|
||||
{
|
||||
|
||||
@@ -28,18 +28,18 @@ internal class SurfaceArrangementType
|
||||
|
||||
public void Arrange(List<ArtemisDevice> devices)
|
||||
{
|
||||
devices = devices.Where(d => d.DeviceType == DeviceType).ToList();
|
||||
if (!devices.Any())
|
||||
List<ArtemisDevice> devicesToArrange = devices.Where(d => d.DeviceType == DeviceType).ToList();
|
||||
if (!devicesToArrange.Any())
|
||||
return;
|
||||
|
||||
AppliedConfiguration = null;
|
||||
foreach (SurfaceArrangementConfiguration configuration in Configurations)
|
||||
{
|
||||
bool applied = configuration.Apply(devices);
|
||||
bool applied = configuration.Apply(devicesToArrange, devices);
|
||||
if (applied)
|
||||
{
|
||||
AppliedConfiguration = configuration;
|
||||
foreach (ArtemisDevice artemisDevice in devices)
|
||||
foreach (ArtemisDevice artemisDevice in devicesToArrange)
|
||||
artemisDevice.ZIndex = ZIndex;
|
||||
return;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ internal class SurfaceArrangementType
|
||||
VerticalArrangementPosition.Equal,
|
||||
10
|
||||
) {SurfaceArrangement = SurfaceArrangement};
|
||||
fallback.Apply(devices);
|
||||
fallback.Apply(devicesToArrange, devices);
|
||||
AppliedConfiguration = fallback;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user