From 76dcbaf6d7b0fb9aef2554c8beb0164e698572e9 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Fri, 4 Sep 2020 16:28:49 +0200 Subject: [PATCH] Effect/brush dialogs - Fixed window not closing on RequestClose(); --- .../LayerBrushSettingsWindowViewModel.cs | 12 ++++++++++-- .../LayerEffectSettingsWindowViewModel.cs | 12 ++++++++++-- .../Tabs/Plugins/PluginSettingsWindowViewModel.cs | 7 ++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerBrushSettingsWindowViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerBrushSettingsWindowViewModel.cs index 94e2bf4ba..bea20cbd8 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerBrushSettingsWindowViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerBrushSettingsWindowViewModel.cs @@ -1,4 +1,5 @@ -using Artemis.Core.LayerBrushes; +using System; +using Artemis.Core.LayerBrushes; using Stylet; namespace Artemis.UI.Screens.ProfileEditor @@ -7,7 +8,14 @@ namespace Artemis.UI.Screens.ProfileEditor { public LayerBrushSettingsWindowViewModel(BrushConfigurationViewModel configurationViewModel) { - ActiveItem = configurationViewModel; + ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel)); + ActiveItem.Closed += ActiveItemOnClosed; + } + + private void ActiveItemOnClosed(object sender, CloseEventArgs e) + { + ActiveItem.Closed -= ActiveItemOnClosed; + RequestClose(); } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerEffectSettingsWindowViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerEffectSettingsWindowViewModel.cs index cf23efa2e..d8e31a5a3 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerEffectSettingsWindowViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerEffectSettingsWindowViewModel.cs @@ -1,4 +1,5 @@ -using Artemis.Core.LayerEffects; +using System; +using Artemis.Core.LayerEffects; using Stylet; namespace Artemis.UI.Screens.ProfileEditor @@ -7,7 +8,14 @@ namespace Artemis.UI.Screens.ProfileEditor { public LayerEffectSettingsWindowViewModel(EffectConfigurationViewModel configurationViewModel) { - ActiveItem = configurationViewModel; + ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel)); + ActiveItem.Closed += ActiveItemOnClosed; + } + + private void ActiveItemOnClosed(object sender, CloseEventArgs e) + { + ActiveItem.Closed -= ActiveItemOnClosed; + RequestClose(); } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsWindowViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsWindowViewModel.cs index 5ad07c1f3..cb06d38c4 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsWindowViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/Plugins/PluginSettingsWindowViewModel.cs @@ -1,4 +1,5 @@ -using Artemis.Core; +using System; +using Artemis.Core; using MaterialDesignThemes.Wpf; using Stylet; @@ -9,14 +10,14 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins public PluginSettingsWindowViewModel(PluginConfigurationViewModel configurationViewModel, PackIconKind icon) { Icon = icon; - ActiveItem = configurationViewModel; + ActiveItem = configurationViewModel ?? throw new ArgumentNullException(nameof(configurationViewModel)); ActiveItem.Closed += ActiveItemOnClosed; } public PackIconKind Icon { get; } - private void ActiveItemOnClosed(object? sender, CloseEventArgs e) + private void ActiveItemOnClosed(object sender, CloseEventArgs e) { ActiveItem.Closed -= ActiveItemOnClosed; RequestClose();