From 2785ce296cc6f7a54a64349b44c5dd4cd317c865 Mon Sep 17 00:00:00 2001 From: natsurainko Date: Sat, 11 Jan 2025 12:38:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E6=97=B6=E8=BF=94=E5=9B=9E=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=B4=A9=E6=BA=83=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Common/DeleteInstanceDialogViewModel.cs | 11 ++++++----- .../ViewModels/Cores/Manage/DefaultViewModel.cs | 7 +------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Natsurainko.FluentLauncher/ViewModels/Common/DeleteInstanceDialogViewModel.cs b/Natsurainko.FluentLauncher/ViewModels/Common/DeleteInstanceDialogViewModel.cs index 0e104cd6..139d7228 100644 --- a/Natsurainko.FluentLauncher/ViewModels/Common/DeleteInstanceDialogViewModel.cs +++ b/Natsurainko.FluentLauncher/ViewModels/Common/DeleteInstanceDialogViewModel.cs @@ -16,11 +16,11 @@ namespace Natsurainko.FluentLauncher.ViewModels.Common; internal partial class DeleteInstanceDialogViewModel : ObservableObject, IDialogParameterAware { - private readonly INavigationService _navigationService; private readonly NotificationService _notificationService; private readonly GameService _gameService; - private MinecraftInstance _minecraftInstance = null!; + private MinecraftInstance _minecraftInstance = null!; + private INavigationService _navigationService = null!; private ContentDialog _dialog = null!; // Set in LoadEvent public string Title => $"\"{_minecraftInstance.InstanceId}\""; @@ -29,18 +29,19 @@ internal partial class DeleteInstanceDialogViewModel : ObservableObject, IDialog public partial bool DeleteCoreSettings { get; set; } = true; public DeleteInstanceDialogViewModel( - INavigationService navigationService, NotificationService notificationService, GameService gameService) { - _navigationService = navigationService; _notificationService = notificationService; _gameService = gameService; } void IDialogParameterAware.HandleParameter(object param) { - _minecraftInstance = (MinecraftInstance)param; + var (instance, service) = ((MinecraftInstance, INavigationService))param; + + _navigationService = service; + _minecraftInstance = instance; } [RelayCommand] diff --git a/Natsurainko.FluentLauncher/ViewModels/Cores/Manage/DefaultViewModel.cs b/Natsurainko.FluentLauncher/ViewModels/Cores/Manage/DefaultViewModel.cs index 5c91c9da..1c5c6a62 100644 --- a/Natsurainko.FluentLauncher/ViewModels/Cores/Manage/DefaultViewModel.cs +++ b/Natsurainko.FluentLauncher/ViewModels/Cores/Manage/DefaultViewModel.cs @@ -7,8 +7,6 @@ using Natsurainko.FluentLauncher.Services.Launch; using Natsurainko.FluentLauncher.Services.UI; using Natsurainko.FluentLauncher.Utils.Extensions; -using Natsurainko.FluentLauncher.ViewModels.Common; -using Natsurainko.FluentLauncher.Views.Common; using Nrk.FluentCore.GameManagement; using Nrk.FluentCore.GameManagement.Instances; using System; @@ -23,7 +21,6 @@ namespace Natsurainko.FluentLauncher.ViewModels.Cores.Manage; internal partial class DefaultViewModel : ObservableObject, INavigationAware { private readonly INavigationService _navigationService; - private readonly GameService _gameService; private readonly NotificationService _notificationService; private readonly QuickLaunchService _quickLaunchService; private readonly IDialogActivationService _dialogs; @@ -36,13 +33,11 @@ internal partial class DefaultViewModel : ObservableObject, INavigationAware public partial InstanceConfig InstanceConfig { get; set; } public DefaultViewModel( - GameService gameService, INavigationService navigationService, NotificationService notificationService, QuickLaunchService quickLaunchService, IDialogActivationService dialogs) { - _gameService = gameService; _navigationService = navigationService; _notificationService = notificationService; _quickLaunchService = quickLaunchService; @@ -107,7 +102,7 @@ private void InstanceConfig_PropertyChanged(object sender, PropertyChangedEventA public async Task OpenVersionFolder() => await Launcher.LaunchFolderPathAsync(MinecraftInstance.GetGameDirectory()); [RelayCommand] - public async Task DeleteGame() => await _dialogs.ShowAsync("DeleteInstanceDialog", MinecraftInstance); + public async Task DeleteGame() => await _dialogs.ShowAsync("DeleteInstanceDialog", (MinecraftInstance, _navigationService)); protected override async void OnPropertyChanged(PropertyChangedEventArgs e) {