Core - Split up RGBService into RenderService and DeviceService

Core - Removed rendering from CoreService
Core - Store and restore original device LEDs when applying/clearing layouts
This commit is contained in:
Robert committed 2023-10-05 20:38:07 +02:00
1 parent 919199a8d0
commit 2a0a0f3cfd
43 files changed
+1363 -1189

No files matched your search

@@ -15,12 +15,12 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.Dialogs;
public class LayerHintsDialogViewModel : DialogViewModelBase<bool>
{
private readonly IRgbService _rgbService;
private readonly IDeviceService _deviceService;
private readonly ILayerHintVmFactory _vmFactory;
public LayerHintsDialogViewModel(Layer layer, IRgbService rgbService, ILayerHintVmFactory vmFactory)
public LayerHintsDialogViewModel(Layer layer, IDeviceService deviceService, ILayerHintVmFactory vmFactory)
{
_rgbService = rgbService;
_deviceService = deviceService;
_vmFactory = vmFactory;
Layer = layer;
@@ -49,7 +49,7 @@ public class LayerHintsDialogViewModel : DialogViewModelBase<bool>
public void AutoDetermineHints()
{
Layer.Adapter.DetermineHints(_rgbService.EnabledDevices);
Layer.Adapter.DetermineHints(_deviceService.EnabledDevices);
}
public void AddCategoryHint()
@@ -14,17 +14,17 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
public class FolderTreeItemViewModel : TreeItemViewModel
{
private readonly IRgbService _rgbService;
private readonly IDeviceService _deviceService;
public FolderTreeItemViewModel(TreeItemViewModel? parent,
Folder folder,
IWindowService windowService,
IDeviceService deviceService,
IProfileEditorService profileEditorService,
IRgbService rgbService,
IProfileEditorVmFactory profileEditorVmFactory)
: base(parent, folder, windowService, rgbService, profileEditorService, profileEditorVmFactory)
: base(parent, folder, windowService, deviceService, profileEditorService, profileEditorVmFactory)
{
_rgbService = rgbService;
_deviceService = deviceService;
Folder = folder;
}
@@ -63,7 +63,7 @@ public class FolderTreeItemViewModel : TreeItemViewModel
pasted.Name = parent.GetNewFolderName(pasted.Name + " - copy");
ProfileEditorService.ExecuteCommand(new AddProfileElement(pasted, parent, Folder.Order - 1));
Folder.Profile.PopulateLeds(_rgbService.EnabledDevices);
Folder.Profile.PopulateLeds(_deviceService.EnabledDevices);
}
private async Task ExecutePasteInto()
@@ -14,17 +14,17 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree;
public class LayerTreeItemViewModel : TreeItemViewModel
{
private readonly IRgbService _rgbService;
private readonly IDeviceService _deviceService;
public LayerTreeItemViewModel(TreeItemViewModel? parent,
Layer layer,
IWindowService windowService,
IProfileEditorService profileEditorService,
IRgbService rgbService,
IDeviceService deviceService,
IProfileEditorVmFactory profileEditorVmFactory)
: base(parent, layer, windowService, rgbService, profileEditorService, profileEditorVmFactory)
: base(parent, layer, windowService, deviceService, profileEditorService, profileEditorVmFactory)
{
_rgbService = rgbService;
_deviceService = deviceService;
Layer = layer;
}
@@ -43,7 +43,7 @@ public class LayerTreeItemViewModel : TreeItemViewModel
Layer copied = new(Layer.Profile, Layer.Parent, copy, true);
ProfileEditorService.ExecuteCommand(new AddProfileElement(copied, Layer.Parent, Layer.Order - 1));
Layer.Profile.PopulateLeds(_rgbService.EnabledDevices);
Layer.Profile.PopulateLeds(_deviceService.EnabledDevices);
}
protected override async Task ExecuteCopy()
@@ -65,7 +65,7 @@ public class LayerTreeItemViewModel : TreeItemViewModel
pasted.Name = parent.GetNewLayerName(pasted.Name + " - copy");
ProfileEditorService.ExecuteCommand(new AddProfileElement(pasted, parent, Layer.Order - 1));
Layer.Profile.PopulateLeds(_rgbService.EnabledDevices);
Layer.Profile.PopulateLeds(_deviceService.EnabledDevices);
}
/// <inheritdoc />
@@ -23,8 +23,8 @@ public class ProfileTreeViewModel : TreeItemViewModel
private ObservableAsPropertyHelper<bool>? _keyBindingsEnabled;
private TreeItemViewModel? _selectedChild;
public ProfileTreeViewModel(IWindowService windowService, IRgbService rgbService, IProfileEditorService profileEditorService, IProfileEditorVmFactory profileEditorVmFactory)
: base(null, null, windowService, rgbService, profileEditorService, profileEditorVmFactory)
public ProfileTreeViewModel(IWindowService windowService, IDeviceService deviceService, IProfileEditorService profileEditorService, IProfileEditorVmFactory profileEditorVmFactory)
: base(null, null, windowService, deviceService, profileEditorService, profileEditorVmFactory)
{
this.WhenActivated(d =>
{
@@ -28,7 +28,7 @@ public abstract class TreeItemViewModel : ActivatableViewModelBase
{
private readonly IProfileEditorVmFactory _profileEditorVmFactory;
private readonly IWindowService _windowService;
private readonly IRgbService _rgbService;
private readonly IDeviceService _deviceService;
protected readonly IProfileEditorService ProfileEditorService;
private bool _canPaste;
private RenderProfileElement? _currentProfileElement;
@@ -41,13 +41,13 @@ public abstract class TreeItemViewModel : ActivatableViewModelBase
protected TreeItemViewModel(TreeItemViewModel? parent,
ProfileElement? profileElement,
IWindowService windowService,
IRgbService rgbService,
IDeviceService deviceService,
IProfileEditorService profileEditorService,
IProfileEditorVmFactory profileEditorVmFactory)
{
ProfileEditorService = profileEditorService;
_windowService = windowService;
_rgbService = rgbService;
_deviceService = deviceService;
_profileEditorVmFactory = profileEditorVmFactory;
Parent = parent;
@@ -267,7 +267,7 @@ public abstract class TreeItemViewModel : ActivatableViewModelBase
if (ProfileElement is not Layer layer)
return;
ProfileEditorService.ExecuteCommand(new ApplyAdaptionHints(layer, _rgbService.EnabledDevices.ToList()));
ProfileEditorService.ExecuteCommand(new ApplyAdaptionHints(layer, _deviceService.EnabledDevices.ToList()));
}
private async void UpdateCanPaste(bool isFlyoutOpen)
@@ -17,14 +17,14 @@ public class SelectionAddToolViewModel : ToolViewModel
{
private readonly ObservableAsPropertyHelper<bool>? _isEnabled;
private readonly IProfileEditorService _profileEditorService;
private readonly IRgbService _rgbService;
private readonly IDeviceService _deviceService;
private Layer? _layer;
/// <inheritdoc />
public SelectionAddToolViewModel(IProfileEditorService profileEditorService, IRgbService rgbService)
public SelectionAddToolViewModel(IProfileEditorService profileEditorService, IDeviceService deviceService)
{
_profileEditorService = profileEditorService;
_rgbService = rgbService;
_deviceService = deviceService;
// Not disposed when deactivated but when really disposed
_isEnabled = profileEditorService.ProfileElement.Select(p => p is Layer).ToProperty(this, vm => vm.IsEnabled);
@@ -57,7 +57,7 @@ public class SelectionAddToolViewModel : ToolViewModel
if (inverse)
{
List<ArtemisLed> toRemove = _layer.Leds.Where(l => l.AbsoluteRectangle.IntersectsWith(rect)).ToList();
List<ArtemisLed> toAdd = _rgbService.EnabledDevices.SelectMany(d => d.Leds).Where(l => l.AbsoluteRectangle.IntersectsWith(rect)).Except(toRemove).ToList();
List<ArtemisLed> toAdd = _deviceService.EnabledDevices.SelectMany(d => d.Leds).Where(l => l.AbsoluteRectangle.IntersectsWith(rect)).Except(toRemove).ToList();
List<ArtemisLed> leds = _layer.Leds.Except(toRemove).ToList();
leds.AddRange(toAdd);
@@ -65,7 +65,7 @@ public class SelectionAddToolViewModel : ToolViewModel
}
else
{
List<ArtemisLed> leds = _rgbService.EnabledDevices.SelectMany(d => d.Leds).Where(l => l.AbsoluteRectangle.IntersectsWith(rect)).ToList();
List<ArtemisLed> leds = _deviceService.EnabledDevices.SelectMany(d => d.Leds).Where(l => l.AbsoluteRectangle.IntersectsWith(rect)).ToList();
if (expand)
leds.AddRange(_layer.Leds);
_profileEditorService.ExecuteCommand(new ChangeLayerLeds(_layer, leds.Distinct().ToList()));
@@ -25,7 +25,7 @@ public class VisualEditorViewModel : ActivatableViewModelBase
private ObservableAsPropertyHelper<bool>? _suspendedEditing;
private ReadOnlyObservableCollection<IToolViewModel>? _tools;
public VisualEditorViewModel(IProfileEditorService profileEditorService, IRgbService rgbService, IProfileEditorVmFactory vmFactory)
public VisualEditorViewModel(IProfileEditorService profileEditorService, IDeviceService deviceService, IProfileEditorVmFactory vmFactory)
{
_vmFactory = vmFactory;
_visualizers = new SourceList<IVisualizerViewModel>();
@@ -34,7 +34,7 @@ public class VisualEditorViewModel : ActivatableViewModelBase
.Bind(out ReadOnlyObservableCollection<IVisualizerViewModel> visualizers)
.Subscribe();
Devices = new ObservableCollection<ArtemisDevice>(rgbService.EnabledDevices.OrderBy(d => d.ZIndex));
Devices = new ObservableCollection<ArtemisDevice>(deviceService.EnabledDevices.OrderBy(d => d.ZIndex));
Visualizers = visualizers;
this.WhenActivated(d =>