mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Surface - Removed the ArtemisSurface and reworked device loading
This commit is contained in:
1 parent
7ccc9c54fb
commit
056b2bface
50 files changed
+1292
-1506
No files matched your search
@@ -182,7 +182,11 @@ namespace Artemis.UI.Shared
|
||||
if (_oldDevice != null)
|
||||
{
|
||||
if (Device != null)
|
||||
{
|
||||
Device.RgbDevice.PropertyChanged -= DevicePropertyChanged;
|
||||
Device.DeviceUpdated -= DeviceUpdated;
|
||||
}
|
||||
|
||||
_oldDevice = null;
|
||||
}
|
||||
}
|
||||
@@ -228,10 +232,15 @@ namespace Artemis.UI.Shared
|
||||
return;
|
||||
|
||||
if (_oldDevice != null)
|
||||
{
|
||||
Device.RgbDevice.PropertyChanged -= DevicePropertyChanged;
|
||||
Device.DeviceUpdated -= DeviceUpdated;
|
||||
}
|
||||
|
||||
_oldDevice = Device;
|
||||
|
||||
Device.RgbDevice.PropertyChanged += DevicePropertyChanged;
|
||||
Device.DeviceUpdated += DeviceUpdated;
|
||||
UpdateTransform();
|
||||
|
||||
// Load the device main image
|
||||
@@ -277,13 +286,16 @@ namespace Artemis.UI.Shared
|
||||
InvalidateMeasure();
|
||||
}
|
||||
|
||||
private void DevicePropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
private void DeviceUpdated(object sender, EventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(Device.RgbDevice.Scale) || e.PropertyName == nameof(Device.RgbDevice.Rotation))
|
||||
UpdateTransform();
|
||||
SetupForDevice();
|
||||
}
|
||||
|
||||
|
||||
private void DevicePropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
SetupForDevice();
|
||||
}
|
||||
|
||||
private void Render()
|
||||
{
|
||||
DrawingContext drawingContext = _backingStore.Open();
|
||||
|
||||
@@ -8,7 +8,6 @@ using Artemis.Core.Modules;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.UI.Shared.Services.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
using Serilog;
|
||||
@@ -20,23 +19,23 @@ namespace Artemis.UI.Shared.Services
|
||||
internal class ProfileEditorService : IProfileEditorService
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly List<PropertyInputRegistration> _registeredPropertyEditors;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly object _selectedProfileElementLock = new();
|
||||
private readonly object _selectedProfileLock = new();
|
||||
private TimeSpan _currentTime;
|
||||
private int _pixelsPerSecond;
|
||||
|
||||
public ProfileEditorService(IKernel kernel, ILogger logger, IProfileService profileService, ICoreService coreService, ISurfaceService surfaceService)
|
||||
public ProfileEditorService(IKernel kernel, ILogger logger, IProfileService profileService, ICoreService coreService, IRgbService rgbService)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_logger = logger;
|
||||
_profileService = profileService;
|
||||
_coreService = coreService;
|
||||
_surfaceService = surfaceService;
|
||||
_rgbService = rgbService;
|
||||
_registeredPropertyEditors = new List<PropertyInputRegistration>();
|
||||
|
||||
PixelsPerSecond = 100;
|
||||
@@ -351,7 +350,7 @@ namespace Artemis.UI.Shared.Services
|
||||
|
||||
public List<ArtemisLed> GetLedsInRectangle(Rect rect)
|
||||
{
|
||||
return _surfaceService.ActiveSurface.Devices.SelectMany(d => d.Leds).Where(led => led.AbsoluteRectangle.IntersectsWith(rect.ToSKRect())).ToList();
|
||||
return _rgbService.EnabledDevices.SelectMany(d => d.Leds).Where(led => led.AbsoluteRectangle.IntersectsWith(rect.ToSKRect())).ToList();
|
||||
}
|
||||
|
||||
#region Copy/paste
|
||||
@@ -424,7 +423,7 @@ namespace Artemis.UI.Shared.Services
|
||||
|
||||
if (pasted != null)
|
||||
{
|
||||
target.Profile.PopulateLeds(_surfaceService.ActiveSurface);
|
||||
target.Profile.PopulateLeds(_rgbService.EnabledDevices);
|
||||
UpdateSelectedProfile();
|
||||
ChangeSelectedProfileElement(pasted);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user