From 17a0c5d0835d4ec9ddf290a0c5034007a6cc257e Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 9 Oct 2023 00:13:40 -0400 Subject: [PATCH] Remove more Windows from MainViewModel --- CHANGELIST.md | 1 + MPF.UI.Core/ViewModels/MainViewModel.cs | 16 ++++------------ MPF.UI.Core/Windows/MainWindow.xaml.cs | 4 ++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index fef40f90..96e44784 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -46,6 +46,7 @@ - Use callback for logging, fix Options window - Remove WinForms from MainViewModel - Remove some message boxes from MainViewModel +- Remove more Windows from MainViewModel ### 2.6.6 (2023-10-04) diff --git a/MPF.UI.Core/ViewModels/MainViewModel.cs b/MPF.UI.Core/ViewModels/MainViewModel.cs index 8197f80e..748a439d 100644 --- a/MPF.UI.Core/ViewModels/MainViewModel.cs +++ b/MPF.UI.Core/ViewModels/MainViewModel.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; +using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; using BurnOutSharp; using MPF.Core; using MPF.Core.Converters; @@ -12,7 +12,6 @@ using MPF.Core.Data; using MPF.Core.Utilities; using MPF.Core.UI.ComboBoxItems; using SabreTools.RedumpLib.Data; -using System.Threading.Tasks; using WPFCustomMessageBox; namespace MPF.UI.Core.ViewModels @@ -628,7 +627,7 @@ namespace MPF.UI.Core.ViewModels CanExecuteSelectionChanged = true; // Force an update of the media type - this.ChangeMediaType(null); + this.ChangeMediaType(null, null); } /// @@ -671,13 +670,11 @@ namespace MPF.UI.Core.ViewModels /// /// Change the currently selected media type /// - public void ChangeMediaType(SelectionChangedEventArgs e) + public void ChangeMediaType(System.Collections.IList removedItems, System.Collections.IList addedItems) { // Only change the media type if the selection and not the list has changed - if (e == null || (e.RemovedItems.Count == 1 && e.AddedItems.Count == 1)) - { + if ((removedItems == null && addedItems == null) || (removedItems.Count == 1 && addedItems.Count == 1)) SetSupportedDriveSpeed(); - } GetOutputNames(false); EnsureDiscInformation(); @@ -875,11 +872,6 @@ namespace MPF.UI.Core.ViewModels }; } - /// - /// Shutdown the current application - /// - public static void ExitApplication() => Application.Current.Shutdown(); - /// /// Toggle the Start/Stop button /// diff --git a/MPF.UI.Core/Windows/MainWindow.xaml.cs b/MPF.UI.Core/Windows/MainWindow.xaml.cs index 4d3983ca..19773513 100644 --- a/MPF.UI.Core/Windows/MainWindow.xaml.cs +++ b/MPF.UI.Core/Windows/MainWindow.xaml.cs @@ -215,7 +215,7 @@ namespace MPF.UI.Core.Windows /// Handler for AppExitMenuItem Click event /// public void AppExitClick(object sender, RoutedEventArgs e) => - MainViewModel.ExitApplication(); + Application.Current.Shutdown(); /// /// Handler for CheckForUpdatesMenuItem Click event @@ -303,7 +303,7 @@ namespace MPF.UI.Core.Windows public void MediaTypeComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e) { if (MainViewModel.CanExecuteSelectionChanged) - MainViewModel.ChangeMediaType(e); + MainViewModel.ChangeMediaType(e.RemovedItems, e.AddedItems); } ///