From 91e1e9ae6cd62491e67eb04644212c2b192dec93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20ANDRE=20=28E104915=29?= Date: Sat, 21 Dec 2024 08:23:04 +0100 Subject: [PATCH] feat: Removed FileMenuViewModel from MainWindowViewModelBase. Introduced MainWindowWithFileMenuViewModel to handle FileMenuViewModel. BREAKING CHANGE: Removed FileMenuViewModel from MainWindowViewModelBase. --- .../Shell/MainWindowViewModelBase.cs | 5 ---- .../Shell/MainWindowWithFileMenuViewModel.cs | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 src/MyNet.UI/ViewModels/Shell/MainWindowWithFileMenuViewModel.cs diff --git a/src/MyNet.UI/ViewModels/Shell/MainWindowViewModelBase.cs b/src/MyNet.UI/ViewModels/Shell/MainWindowViewModelBase.cs index 910eab2..7f0533c 100644 --- a/src/MyNet.UI/ViewModels/Shell/MainWindowViewModelBase.cs +++ b/src/MyNet.UI/ViewModels/Shell/MainWindowViewModelBase.cs @@ -55,12 +55,9 @@ public class MainWindowViewModelBase : LocalizableObject public NotificationsViewModel NotificationsViewModel { get; } - public FileMenuViewModelBase FileMenuViewModel { get; } - public IBusyService BusyService { get; } public MainWindowViewModelBase( - FileMenuViewModelBase fileMenuViewModel, INotificationsManager notificationsManager, IAppCommandsService appCommandsService, IBusyService mainBusyService) @@ -70,7 +67,6 @@ public MainWindowViewModelBase( #endif NotificationsViewModel = new(notificationsManager); - FileMenuViewModel = fileMenuViewModel; BusyService = mainBusyService; ToggleNotificationsCommand = CommandsManager.Create(() => Messenger.Default.Send(new UpdateNotificationsVisibilityRequestedMessage(VisibilityAction.Toggle)), () => !DialogManager.HasOpenedDialogs && NotificationsViewModel.Notifications.Count != 0); @@ -171,7 +167,6 @@ protected override void Cleanup() { Messenger.Default.Unregister(this); NotificationsViewModel.Dispose(); - FileMenuViewModel.Dispose(); ThemeManager.ThemeChanged -= ThemeService_ThemeChanged; base.Cleanup(); } diff --git a/src/MyNet.UI/ViewModels/Shell/MainWindowWithFileMenuViewModel.cs b/src/MyNet.UI/ViewModels/Shell/MainWindowWithFileMenuViewModel.cs new file mode 100644 index 0000000..047477a --- /dev/null +++ b/src/MyNet.UI/ViewModels/Shell/MainWindowWithFileMenuViewModel.cs @@ -0,0 +1,27 @@ +// Copyright (c) Stéphane ANDRE. All Right Reserved. +// See the LICENSE file in the project root for more information. + +using MyNet.UI.Busy; +using MyNet.UI.Notifications; +using MyNet.UI.Services; + +namespace MyNet.UI.ViewModels.Shell +{ + public class MainWindowWithFileMenuViewModel : MainWindowViewModelBase + { + public FileMenuViewModelBase FileMenuViewModel { get; } + + public MainWindowWithFileMenuViewModel( + FileMenuViewModelBase fileMenuViewModel, + INotificationsManager notificationsManager, + IAppCommandsService appCommandsService, + IBusyService mainBusyService) + : base(notificationsManager, appCommandsService, mainBusyService) => FileMenuViewModel = fileMenuViewModel; + + protected override void Cleanup() + { + FileMenuViewModel.Dispose(); + base.Cleanup(); + } + } +}