mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Implemented layer LED assignment
Added a centralised ProfileEditorSurface for communication between VMs Prefixed Surface, Device and Led with Artemis to differentiate them better
This commit is contained in:
1 parent
8a596f1426
commit
f32edcf502
50 files changed
+556
-662
No files matched your search
@@ -44,7 +44,7 @@ namespace Artemis.Core.Models.Profile.Abstract
|
||||
/// <summary>
|
||||
/// Renders the element
|
||||
/// </summary>
|
||||
public abstract void Render(double deltaTime, Surface.Surface surface, Graphics graphics);
|
||||
public abstract void Render(double deltaTime, Surface.ArtemisSurface surface, Graphics graphics);
|
||||
|
||||
/// <summary>
|
||||
/// Applies the profile element's properties to the underlying storage entity
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Artemis.Core.Models.Profile
|
||||
profileElement.Update(deltaTime);
|
||||
}
|
||||
|
||||
public override void Render(double deltaTime, Surface.Surface surface, Graphics graphics)
|
||||
public override void Render(double deltaTime, Surface.ArtemisSurface surface, Graphics graphics)
|
||||
{
|
||||
// Folders don't render but their children do
|
||||
foreach (var profileElement in Children)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
@@ -15,6 +16,8 @@ namespace Artemis.Core.Models.Profile
|
||||
{
|
||||
public sealed class Layer : ProfileElement
|
||||
{
|
||||
private List<ArtemisLed> _leds;
|
||||
|
||||
public Layer(Profile profile, ProfileElement parent, string name)
|
||||
{
|
||||
LayerEntity = new LayerEntity();
|
||||
@@ -23,7 +26,7 @@ namespace Artemis.Core.Models.Profile
|
||||
Profile = profile;
|
||||
Parent = parent;
|
||||
Name = name;
|
||||
Leds = new List<DeviceLed>();
|
||||
_leds = new List<ArtemisLed>();
|
||||
}
|
||||
|
||||
internal Layer(Profile profile, ProfileElement parent, LayerEntity layerEntity, IPluginService pluginService)
|
||||
@@ -37,12 +40,12 @@ namespace Artemis.Core.Models.Profile
|
||||
Order = layerEntity.Order;
|
||||
|
||||
LayerType = pluginService.GetLayerTypeByGuid(layerEntity.LayerTypeGuid);
|
||||
Leds = new List<DeviceLed>();
|
||||
_leds = new List<ArtemisLed>();
|
||||
}
|
||||
|
||||
internal LayerEntity LayerEntity { get; set; }
|
||||
|
||||
public List<DeviceLed> Leds { get; private set; }
|
||||
public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly();
|
||||
public LayerType LayerType { get; private set; }
|
||||
public ILayerTypeConfiguration LayerTypeConfiguration { get; set; }
|
||||
|
||||
@@ -60,7 +63,7 @@ namespace Artemis.Core.Models.Profile
|
||||
}
|
||||
}
|
||||
|
||||
public override void Render(double deltaTime, Surface.Surface surface, Graphics graphics)
|
||||
public override void Render(double deltaTime, ArtemisSurface surface, Graphics graphics)
|
||||
{
|
||||
if (LayerType == null)
|
||||
return;
|
||||
@@ -81,19 +84,62 @@ namespace Artemis.Core.Models.Profile
|
||||
LayerEntity.Name = Name;
|
||||
|
||||
LayerEntity.ProfileId = Profile.EntityId;
|
||||
// TODO: LEDs, conditions, elements
|
||||
}
|
||||
|
||||
public void ApplySurface(Surface.Surface surface)
|
||||
{
|
||||
var leds = new List<DeviceLed>();
|
||||
foreach (var surfaceDevice in surface.Devices)
|
||||
LayerEntity.Leds.Clear();
|
||||
foreach (var artemisLed in Leds)
|
||||
{
|
||||
var deviceHash = surfaceDevice.RgbDevice.GetDeviceHashCode();
|
||||
leds.AddRange(surfaceDevice.Leds.Where(dl => LayerEntity.Leds.Any(l => l.DeviceHash == deviceHash && l.LedName == dl.RgbLed.ToString())));
|
||||
var ledEntity = new LedEntity
|
||||
{
|
||||
DeviceHash = artemisLed.Device.RgbDevice.GetDeviceHashCode(),
|
||||
LedName = artemisLed.RgbLed.Id.ToString()
|
||||
};
|
||||
LayerEntity.Leds.Add(ledEntity);
|
||||
}
|
||||
|
||||
Leds = leds;
|
||||
LayerEntity.Condition.Clear();
|
||||
|
||||
LayerEntity.Elements.Clear();
|
||||
}
|
||||
|
||||
public void ApplySurface(ArtemisSurface surface)
|
||||
{
|
||||
var leds = new List<ArtemisLed>();
|
||||
|
||||
// Get the surface LEDs for this layer
|
||||
var availableLeds = surface.Devices.SelectMany(d => d.Leds).ToList();
|
||||
foreach (var ledEntity in LayerEntity.Leds)
|
||||
{
|
||||
var match = availableLeds.FirstOrDefault(a => a.Device.RgbDevice.GetDeviceHashCode() == ledEntity.DeviceHash &&
|
||||
a.RgbLed.Id.ToString() == ledEntity.LedName);
|
||||
if (match != null)
|
||||
leds.Add(match);
|
||||
}
|
||||
|
||||
_leds = leds;
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
public void AddLed(ArtemisLed led)
|
||||
{
|
||||
_leds.Add(led);
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
public void AddLeds(IEnumerable<ArtemisLed> leds)
|
||||
{
|
||||
_leds.AddRange(leds);
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
public void RemoveLed(ArtemisLed led)
|
||||
{
|
||||
_leds.Remove(led);
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
public void ClearLeds()
|
||||
{
|
||||
_leds.Clear();
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Artemis.Core.Models.Profile
|
||||
}
|
||||
}
|
||||
|
||||
public override void Render(double deltaTime, Surface.Surface surface, Graphics graphics)
|
||||
public override void Render(double deltaTime, Surface.ArtemisSurface surface, Graphics graphics)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ namespace Artemis.Core.Models.Profile
|
||||
return $"{nameof(Order)}: {Order}, {nameof(Name)}: {Name}, {nameof(PluginInfo)}: {PluginInfo}";
|
||||
}
|
||||
|
||||
public void ApplySurface(Surface.Surface surface)
|
||||
public void ApplySurface(Surface.ArtemisSurface surface)
|
||||
{
|
||||
foreach (var layer in GetAllLayers())
|
||||
layer.ApplySurface(surface);
|
||||
|
||||
+7
-7
@@ -11,15 +11,15 @@ using Rectangle = System.Drawing.Rectangle;
|
||||
|
||||
namespace Artemis.Core.Models.Surface
|
||||
{
|
||||
public class Device : PropertyChangedBase
|
||||
public class ArtemisDevice : PropertyChangedBase
|
||||
{
|
||||
internal Device(IRGBDevice rgbDevice, Plugin plugin, Surface surface)
|
||||
internal ArtemisDevice(IRGBDevice rgbDevice, Plugin plugin, ArtemisSurface surface)
|
||||
{
|
||||
RgbDevice = rgbDevice;
|
||||
Plugin = plugin;
|
||||
Surface = surface;
|
||||
DeviceEntity = new DeviceEntity();
|
||||
Leds = rgbDevice.Select(l => new DeviceLed(l, this)).ToList().AsReadOnly();
|
||||
Leds = rgbDevice.Select(l => new ArtemisLed(l, this)).ToList().AsReadOnly();
|
||||
|
||||
Rotation = 0;
|
||||
Scale = 1;
|
||||
@@ -29,13 +29,13 @@ namespace Artemis.Core.Models.Surface
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
internal Device(IRGBDevice rgbDevice, Plugin plugin, Surface surface, DeviceEntity deviceEntity)
|
||||
internal ArtemisDevice(IRGBDevice rgbDevice, Plugin plugin, ArtemisSurface surface, DeviceEntity deviceEntity)
|
||||
{
|
||||
RgbDevice = rgbDevice;
|
||||
Plugin = plugin;
|
||||
Surface = surface;
|
||||
DeviceEntity = deviceEntity;
|
||||
Leds = rgbDevice.Select(l => new DeviceLed(l, this)).ToList().AsReadOnly();
|
||||
Leds = rgbDevice.Select(l => new ArtemisLed(l, this)).ToList().AsReadOnly();
|
||||
}
|
||||
|
||||
public Rectangle RenderRectangle { get; private set; }
|
||||
@@ -43,9 +43,9 @@ namespace Artemis.Core.Models.Surface
|
||||
|
||||
public IRGBDevice RgbDevice { get; }
|
||||
public Plugin Plugin { get; }
|
||||
public Surface Surface { get; }
|
||||
public ArtemisSurface Surface { get; }
|
||||
public DeviceEntity DeviceEntity { get; }
|
||||
public ReadOnlyCollection<DeviceLed> Leds { get; set; }
|
||||
public ReadOnlyCollection<ArtemisLed> Leds { get; set; }
|
||||
|
||||
public double X
|
||||
{
|
||||
+3
-3
@@ -5,9 +5,9 @@ using Rectangle = System.Drawing.Rectangle;
|
||||
|
||||
namespace Artemis.Core.Models.Surface
|
||||
{
|
||||
public class DeviceLed : PropertyChangedBase
|
||||
public class ArtemisLed : PropertyChangedBase
|
||||
{
|
||||
public DeviceLed(Led led, Device device)
|
||||
public ArtemisLed(Led led, ArtemisDevice device)
|
||||
{
|
||||
RgbLed = led;
|
||||
Device = device;
|
||||
@@ -15,7 +15,7 @@ namespace Artemis.Core.Models.Surface
|
||||
}
|
||||
|
||||
public Led RgbLed { get; }
|
||||
public Device Device { get; }
|
||||
public ArtemisDevice Device { get; }
|
||||
|
||||
public Rectangle RenderRectangle { get; private set; }
|
||||
public Rectangle AbsoluteRenderRectangle { get; private set; }
|
||||
+6
-6
@@ -7,9 +7,9 @@ using Stylet;
|
||||
|
||||
namespace Artemis.Core.Models.Surface
|
||||
{
|
||||
public class Surface : PropertyChangedBase
|
||||
public class ArtemisSurface : PropertyChangedBase
|
||||
{
|
||||
internal Surface(RGBSurface rgbSurface, string name, double scale)
|
||||
internal ArtemisSurface(RGBSurface rgbSurface, string name, double scale)
|
||||
{
|
||||
SurfaceEntity = new SurfaceEntity {DeviceEntities = new List<DeviceEntity>()};
|
||||
EntityId = Guid.NewGuid();
|
||||
@@ -20,12 +20,12 @@ namespace Artemis.Core.Models.Surface
|
||||
IsActive = false;
|
||||
|
||||
// Devices are not populated here but as they are detected
|
||||
Devices = new List<Device>();
|
||||
Devices = new List<ArtemisDevice>();
|
||||
|
||||
ApplyToEntity();
|
||||
}
|
||||
|
||||
internal Surface(RGBSurface rgbSurface, SurfaceEntity surfaceEntity, double scale)
|
||||
internal ArtemisSurface(RGBSurface rgbSurface, SurfaceEntity surfaceEntity, double scale)
|
||||
{
|
||||
SurfaceEntity = surfaceEntity;
|
||||
EntityId = surfaceEntity.Id;
|
||||
@@ -36,14 +36,14 @@ namespace Artemis.Core.Models.Surface
|
||||
IsActive = surfaceEntity.IsActive;
|
||||
|
||||
// Devices are not populated here but as they are detected
|
||||
Devices = new List<Device>();
|
||||
Devices = new List<ArtemisDevice>();
|
||||
}
|
||||
|
||||
public RGBSurface RgbSurface { get; }
|
||||
public double Scale { get; private set; }
|
||||
public string Name { get; set; }
|
||||
public bool IsActive { get; internal set; }
|
||||
public List<Device> Devices { get; internal set; }
|
||||
public List<ArtemisDevice> Devices { get; internal set; }
|
||||
|
||||
internal SurfaceEntity SurfaceEntity { get; set; }
|
||||
internal Guid EntityId { get; set; }
|
||||
Reference in new issue
Block a user