From 53cb2c7577bd3bfc045c83266c42e0f7d8c53c07 Mon Sep 17 00:00:00 2001 From: cooolbros Date: Mon, 8 Jul 2024 17:25:47 +1000 Subject: [PATCH] Add QuitService --- src/HUDMerger.Core/Services/IQuitService.cs | 8 ++++++++ .../ViewModels/MainWindowViewModel.cs | 4 ++-- src/HUDMerger/App.xaml.cs | 1 + src/HUDMerger/Services/QuitService.cs | 13 +++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/HUDMerger.Core/Services/IQuitService.cs create mode 100644 src/HUDMerger/Services/QuitService.cs diff --git a/src/HUDMerger.Core/Services/IQuitService.cs b/src/HUDMerger.Core/Services/IQuitService.cs new file mode 100644 index 0000000..1a6e68e --- /dev/null +++ b/src/HUDMerger.Core/Services/IQuitService.cs @@ -0,0 +1,8 @@ +using System; + +namespace HUDMerger.Core.Services; + +public interface IQuitService +{ + public void Quit(); +} diff --git a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs index f0b822e..5c1f14e 100644 --- a/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs +++ b/src/HUDMerger.Core/ViewModels/MainWindowViewModel.cs @@ -86,7 +86,7 @@ public ViewModelBase TargetHUDPanelsListViewModel public MergeCommand MergeCommand { get; } - public MainWindowViewModel(ISettingsService settingsService, IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService, IMessageBoxService messageBoxService) + public MainWindowViewModel(ISettingsService settingsService, IFolderPickerService folderPickerService, ISettingsWindowService settingsWindowService, IAboutWindowService aboutWindowService, IQuitService quitService, IMessageBoxService messageBoxService) { SettingsService = settingsService; FolderPickerService = folderPickerService; @@ -96,7 +96,7 @@ public MainWindowViewModel(ISettingsService settingsService, IFolderPickerServic LoadSourceHUDCommand = new AsyncRelayCommand(LoadSourceHUD); LoadTargetHUDCommand = new AsyncRelayCommand(LoadTargetHUD); ShowSettingsWindowCommand = new RelayCommand(ShowSettingsWindow); - QuitCommand = new RelayCommand(Application.Current.Shutdown); + QuitCommand = new RelayCommand(quitService.Quit); ShowAboutWindowCommand = new RelayCommand(ShowAboutWindow); diff --git a/src/HUDMerger/App.xaml.cs b/src/HUDMerger/App.xaml.cs index c161d03..d40c1c5 100644 --- a/src/HUDMerger/App.xaml.cs +++ b/src/HUDMerger/App.xaml.cs @@ -34,6 +34,7 @@ protected override void OnStartup(StartupEventArgs e) new FolderPickerService(settingsService), new SettingsWindowService(), new AboutWindowService(), + new QuitService(), new MessageBoxService() ) }; diff --git a/src/HUDMerger/Services/QuitService.cs b/src/HUDMerger/Services/QuitService.cs new file mode 100644 index 0000000..c3283a4 --- /dev/null +++ b/src/HUDMerger/Services/QuitService.cs @@ -0,0 +1,13 @@ +using System; +using System.Windows; +using HUDMerger.Core.Services; + +namespace HUDMerger.Services; + +public class QuitService : IQuitService +{ + public void Quit() + { + Application.Current.Shutdown(); + } +}