mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Profile editor - Fix closing brush/effect config dialogs
This commit is contained in:
1 parent
eac08050bc
commit
3e1fc76bfe
5 files changed
+24
-13
No files matched your search
+1
@@ -24,6 +24,7 @@
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Tree/ContentDialogs/SidebarCategoryEditView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Tree/TreeGroupView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Tree/TreePropertyView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Windows/EffectConfigurationWindowView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Settings/Tabs/GeneralTabView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
<entry key="Avalonia/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugView.axaml" value="Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||
|
||||
+6
-3
@@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Windows;
|
||||
|
||||
public class BrushConfigurationWindowView : ReactiveCoreWindow<EffectConfigurationWindowViewModel>
|
||||
public class BrushConfigurationWindowView : ReactiveCoreWindow<BrushConfigurationWindowViewModel>
|
||||
{
|
||||
public BrushConfigurationWindowView()
|
||||
{
|
||||
@@ -20,8 +20,11 @@ public class BrushConfigurationWindowView : ReactiveCoreWindow<EffectConfigurati
|
||||
Closing += OnClosing;
|
||||
}
|
||||
|
||||
private void OnClosing(object? sender, CancelEventArgs e)
|
||||
private async void OnClosing(object? sender, CancelEventArgs e)
|
||||
{
|
||||
e.Cancel = ViewModel?.CanClose() ?? true;
|
||||
if (ViewModel == null)
|
||||
return;
|
||||
|
||||
e.Cancel = !await ViewModel.CanClose();
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.LayerBrushes;
|
||||
using Avalonia.Threading;
|
||||
@@ -18,14 +19,15 @@ public class BrushConfigurationWindowViewModel : DialogViewModelBase<object?>
|
||||
public BrushConfigurationViewModel ConfigurationViewModel { get; }
|
||||
public LayerBrushConfigurationDialog Configuration { get; }
|
||||
|
||||
public bool CanClose()
|
||||
public async Task<bool> CanClose()
|
||||
{
|
||||
return ConfigurationViewModel.CanClose() && Dispatcher.UIThread.InvokeAsync(async () => await ConfigurationViewModel.CanCloseAsync()).GetAwaiter().GetResult();
|
||||
// ReSharper disable once MethodHasAsyncOverload - Checking both in case the plugin developer only implemented CanClose
|
||||
return ConfigurationViewModel.CanClose() && await ConfigurationViewModel.CanCloseAsync();
|
||||
}
|
||||
|
||||
private void ConfigurationViewModelOnCloseRequested(object? sender, EventArgs e)
|
||||
private async void ConfigurationViewModelOnCloseRequested(object? sender, EventArgs e)
|
||||
{
|
||||
if (CanClose())
|
||||
if (await CanClose())
|
||||
Close(null);
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -20,8 +20,11 @@ public class EffectConfigurationWindowView : ReactiveCoreWindow<EffectConfigurat
|
||||
Closing += OnClosing;
|
||||
}
|
||||
|
||||
private void OnClosing(object? sender, CancelEventArgs e)
|
||||
private async void OnClosing(object? sender, CancelEventArgs e)
|
||||
{
|
||||
e.Cancel = ViewModel?.CanClose() ?? true;
|
||||
if (ViewModel == null)
|
||||
return;
|
||||
|
||||
e.Cancel = !await ViewModel.CanClose();
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.LayerEffects;
|
||||
using Avalonia.Threading;
|
||||
@@ -18,14 +19,15 @@ public class EffectConfigurationWindowViewModel : DialogViewModelBase<object?>
|
||||
public EffectConfigurationViewModel ConfigurationViewModel { get; }
|
||||
public LayerEffectConfigurationDialog Configuration { get; }
|
||||
|
||||
public bool CanClose()
|
||||
public async Task<bool> CanClose()
|
||||
{
|
||||
return ConfigurationViewModel.CanClose() && Dispatcher.UIThread.InvokeAsync(async () => await ConfigurationViewModel.CanCloseAsync()).GetAwaiter().GetResult();
|
||||
// ReSharper disable once MethodHasAsyncOverload - Checking both in case the plugin developer only implemented CanClose
|
||||
return ConfigurationViewModel.CanClose() && await ConfigurationViewModel.CanCloseAsync();
|
||||
}
|
||||
|
||||
private void ConfigurationViewModelOnCloseRequested(object? sender, EventArgs e)
|
||||
private async void ConfigurationViewModelOnCloseRequested(object? sender, EventArgs e)
|
||||
{
|
||||
if (CanClose())
|
||||
if (await CanClose())
|
||||
Close(null);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user