1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Device properties - Repopulate LED tab each time it opens

Core - Save device before reloading provider for layout reset
This commit is contained in:
Robert 2021-06-13 10:37:18 +02:00
parent 10c80fb9c2
commit 6e197d725a
2 changed files with 8 additions and 6 deletions

View File

@ -386,6 +386,10 @@ namespace Artemis.Core.Services
private void ReloadDevice(ArtemisDevice device) private void ReloadDevice(ArtemisDevice device)
{ {
// Any pending changes are otherwise lost including DisableDefaultLayout
device.ApplyToEntity();
_deviceRepository.Save(device.DeviceEntity);
DeviceProvider deviceProvider = device.DeviceProvider; DeviceProvider deviceProvider = device.DeviceProvider;
// Feels bad but need to in order to get the initial LEDs back // Feels bad but need to in order to get the initial LEDs back

View File

@ -30,22 +30,20 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
#region Overrides of Screen #region Overrides of Screen
/// <inheritdoc /> protected override void OnActivate()
protected override void OnInitialActivate()
{ {
BindableCollection<ArtemisLed> selectedLeds = ((DeviceDialogViewModel) Parent).SelectedLeds; BindableCollection<ArtemisLed> selectedLeds = ((DeviceDialogViewModel) Parent).SelectedLeds;
LedViewModels.Clear(); LedViewModels.Clear();
LedViewModels.AddRange(Device.Leds.Select(l => new DeviceLedsTabLedViewModel(l, selectedLeds))); LedViewModels.AddRange(Device.Leds.Select(l => new DeviceLedsTabLedViewModel(l, selectedLeds)));
selectedLeds.CollectionChanged += SelectedLedsOnCollectionChanged; selectedLeds.CollectionChanged += SelectedLedsOnCollectionChanged;
base.OnInitialActivate(); base.OnActivate();
} }
/// <inheritdoc /> protected override void OnDeactivate()
protected override void OnClose()
{ {
((DeviceDialogViewModel) Parent).SelectedLeds.CollectionChanged -= SelectedLedsOnCollectionChanged; ((DeviceDialogViewModel) Parent).SelectedLeds.CollectionChanged -= SelectedLedsOnCollectionChanged;
base.OnClose(); base.OnDeactivate();
} }
#endregion #endregion