mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Fixed freeze when changing active surface config
This commit is contained in:
parent
ce383468ea
commit
498b6a6111
@ -27,7 +27,7 @@ namespace Artemis.UI.ViewModels.Controls.SurfaceEditor
|
||||
}
|
||||
}
|
||||
|
||||
public SurfaceDeviceConfiguration DeviceConfiguration { get; }
|
||||
public SurfaceDeviceConfiguration DeviceConfiguration { get; set; }
|
||||
public SelectionStatus SelectionStatus { get; set; }
|
||||
public Cursor Cursor { get; set; }
|
||||
|
||||
|
||||
@ -8,18 +8,22 @@ namespace Artemis.UI.ViewModels.Controls.SurfaceEditor
|
||||
public SurfaceLedViewModel(Led led)
|
||||
{
|
||||
Led = led;
|
||||
ApplyLedToViewModel();
|
||||
}
|
||||
|
||||
public void ApplyLedToViewModel()
|
||||
{
|
||||
X = Led.LedRectangle.X;
|
||||
Y = Led.LedRectangle.Y;
|
||||
Width = Led.LedRectangle.Width;
|
||||
Height = Led.LedRectangle.Height;
|
||||
}
|
||||
|
||||
public Led Led { get; }
|
||||
public Led Led { get; set; }
|
||||
|
||||
public double X { get; }
|
||||
public double Y { get; }
|
||||
public double Width { get; }
|
||||
public double Height { get; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Height { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -89,18 +90,17 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
return;
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
// Make sure all devices have an up-to-date VM
|
||||
foreach (var surfaceDeviceConfiguration in SelectedSurfaceConfiguration.DeviceConfigurations)
|
||||
{
|
||||
// Create VMs for the new config outside the UI thread
|
||||
var viewModels = SelectedSurfaceConfiguration.DeviceConfigurations.Select(c => new SurfaceDeviceViewModel(c)).ToList();
|
||||
// Commit the VMs to the view
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
Devices.Clear();
|
||||
foreach (var viewModel in viewModels.OrderBy(v => v.ZIndex))
|
||||
Devices.Add(viewModel);
|
||||
});
|
||||
});
|
||||
// Create VMs for missing devices
|
||||
var viewModel = Devices.FirstOrDefault(vm => vm.DeviceConfiguration.Device == surfaceDeviceConfiguration.Device);
|
||||
if (viewModel == null)
|
||||
Execute.OnUIThread(() => Devices.Add(new SurfaceDeviceViewModel(surfaceDeviceConfiguration)));
|
||||
// Update existing devices
|
||||
else
|
||||
viewModel.DeviceConfiguration = surfaceDeviceConfiguration;
|
||||
}
|
||||
|
||||
_surfaceService.SetActiveSurfaceConfiguration(SelectedSurfaceConfiguration);
|
||||
}
|
||||
@ -122,7 +122,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
var result = await _dialogService.ShowConfirmDialogAt(
|
||||
"SurfaceListDialogHost",
|
||||
"Delete surface configuration",
|
||||
"Are you sure you want to delete this surface configuration?"
|
||||
"Are you sure you want to delete\nthis surface configuration?"
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user