From af1920141c86380e7e66806b121b60dd8fa5a7e4 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 9 Jul 2023 08:29:54 +0200 Subject: [PATCH] Device visualizer - Clear device cache on UI thread on property change Surface editor - Don't quietly fail device updates --- src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs | 9 ++++++--- .../Screens/SurfaceEditor/SurfaceEditorViewModel.cs | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index 2b16bb769..6908fadd3 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -197,9 +197,12 @@ public class DeviceVisualizer : Control private void DevicePropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (Device != null) - BitmapCache.Remove(Device); - Dispatcher.UIThread.Invoke(SetupForDevice, DispatcherPriority.Background); + Dispatcher.UIThread.Invoke(async () => + { + if (Device != null) + BitmapCache.Remove(Device); + await SetupForDevice(); + }, DispatcherPriority.Background); } private void DeviceUpdated(object? sender, EventArgs e) diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs index e68d8e13a..a6e28ea39 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs @@ -136,6 +136,10 @@ public class SurfaceEditorViewModel : ActivatableViewModelBase, IMainScreenViewM _saving = true; _rgbService.SaveDevices(); } + catch (Exception e) + { + _windowService.ShowExceptionDialog("Failed to update device positions", e); + } finally { _saving = false;