Skip to content

Commit

Permalink
一点修补工作
Browse files Browse the repository at this point in the history
  • Loading branch information
natsurainko committed Jul 16, 2024
1 parent 3b1885a commit 7ec645d
Show file tree
Hide file tree
Showing 26 changed files with 97 additions and 126 deletions.
3 changes: 1 addition & 2 deletions Natsurainko.FluentLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ public static void ShowErrorMessage(string errorMessage)
{
try
{
var dialog = new ExceptionDialog(errorMessage) { XamlRoot = MainWindow.Content.XamlRoot };
await dialog.ShowAsync();
await new ExceptionDialog(errorMessage).ShowAsync();
}
catch
{
Expand Down
6 changes: 6 additions & 0 deletions Natsurainko.FluentLauncher/Natsurainko.FluentLauncher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="cd ..&#xD;&#xA;pwsh ./update-localization.ps1" />
</Target>
<ItemGroup>
<CustomAdditionalCompileInputs Remove="Views\Settings\SkinPage.xaml" />
</ItemGroup>
<ItemGroup>
<Resource Remove="Views\Settings\SkinPage.xaml" />
</ItemGroup>

<!-- Multilingual App Toolkit
<PropertyGroup Label="MultilingualAppToolkit">
Expand Down
3 changes: 2 additions & 1 deletion Natsurainko.FluentLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
pages.WithPage<Views.Settings.AccountPage, ViewModels.Settings.AccountViewModel>("Settings/Account");
pages.WithPage<Views.Settings.DownloadPage, ViewModels.Settings.DownloadViewModel>("Settings/Download");
pages.WithPage<Views.Settings.AppearancePage, ViewModels.Settings.AppearanceViewModel>("Settings/Appearance");
pages.WithPage<Views.Settings.AboutPage, ViewModels.Settings.AboutViewModel>("Settings/About"); ;
pages.WithPage<Views.Settings.AboutPage, ViewModels.Settings.AboutViewModel>("Settings/About");
pages.WithPage<Views.Settings.SkinPage>("Settings/Account/Skin");

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Natsurainko.FluentLauncher.Utils;
using System;

#nullable disable
namespace Natsurainko.FluentLauncher.ViewModels.Common;

internal partial class AddVmArgumentDialogViewModel : ObservableObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Natsurainko.FluentLauncher.Services.Launch;
using Natsurainko.FluentLauncher.Utils.Extensions;
using Natsurainko.FluentLauncher.ViewModels.Common;
using Natsurainko.FluentLauncher.Views;
using Natsurainko.FluentLauncher.Views.Common;
using Nrk.FluentCore.Authentication;
using Nrk.FluentCore.Management;
Expand All @@ -15,7 +14,9 @@
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

#nullable disable
namespace Natsurainko.FluentLauncher.ViewModels.Cores.Manage;

internal partial class CoreSettingsViewModel : ObservableObject, INavigationAware
Expand Down Expand Up @@ -60,12 +61,11 @@ void INavigationAware.OnNavigatedTo(object? parameter)
}

[RelayCommand]
public void AddArgument()
public async Task AddArgument()
{
_ = new AddVmArgumentDialog()
await new AddVmArgumentDialog()
{
XamlRoot = MainWindow.XamlRoot,
DataContext = new AddVmArgumentDialogViewModel(arg => VmArguments.Add(arg))
DataContext = new AddVmArgumentDialogViewModel(VmArguments.Add)
}.ShowAsync();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
using Microsoft.UI.Xaml.Controls;
using Natsurainko.FluentLauncher.Utils;
using Natsurainko.FluentLauncher.ViewModels.Common;
using Natsurainko.FluentLauncher.Views;
using Natsurainko.FluentLauncher.Views.Common;
using Nrk.FluentCore.Management;
using System;
using System.Threading.Tasks;

#nullable disable
namespace Natsurainko.FluentLauncher.ViewModels.Cores;

internal partial class ManageNavigationViewModel : ObservableObject, INavigationAware
Expand All @@ -34,7 +35,7 @@ void BreadcrumbBarClicked(object args)
}

[RelayCommand]
void DeleteGame() => _ = new DeleteGameDialog() { XamlRoot = MainWindow.XamlRoot, DataContext = new DeleteGameDialogViewModel(_gameInfo, _navigationService) }.ShowAsync();
async Task DeleteGame() => await new DeleteGameDialog() { DataContext = new DeleteGameDialogViewModel(_gameInfo, _navigationService) }.ShowAsync();

#region Navigation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
using Natsurainko.FluentLauncher.Services.Storage;
using Natsurainko.FluentLauncher.Utils;
using Natsurainko.FluentLauncher.ViewModels.Common;
using Natsurainko.FluentLauncher.Views;
using Natsurainko.FluentLauncher.Views.Common;
using Nrk.FluentCore.Resources;
using System;
using System.Linq;
using System.Reflection.Metadata;
using System.Threading.Tasks;
using static HelixToolkit.WinUI.ViewportCommands;

#nullable disable
namespace Natsurainko.FluentLauncher.ViewModels.Downloads;

internal partial class ResourceItemViewModel : ObservableObject, INavigationAware
Expand All @@ -28,10 +27,10 @@ public ResourceItemViewModel(INavigationService navigationService, InterfaceCach
}

[ObservableProperty]
private Visibility descriptionBorderVisbility = Visibility.Collapsed;
private Visibility descriptionBorderVisibility = Visibility.Collapsed;

[ObservableProperty]
private Visibility screenshotsBorderVisbility = Visibility.Collapsed;
private Visibility screenshotsBorderVisibility = Visibility.Collapsed;

[ObservableProperty]
private object resource;
Expand All @@ -45,15 +44,14 @@ void INavigationAware.OnNavigatedTo(object? parameter)
var urls = isCurse ? ((CurseForgeResource)parameter).ScreenshotUrls : ((ModrinthResource)parameter).ScreenshotUrls;

if (urls.Any())
ScreenshotsBorderVisbility = Visibility.Visible;
ScreenshotsBorderVisibility = Visibility.Visible;
}

[RelayCommand]
public void Download()
public async Task Download()
{
_ = new ResourceItemFilesDialog()
await new ResourceItemFilesDialog()
{
XamlRoot = MainWindow.XamlRoot,
DataContext = new ResourceItemFilesDialogViewModel(Resource, _navigationService)
}.ShowAsync();
}
Expand Down Expand Up @@ -83,7 +81,7 @@ public void LoadedEvent(object args)
{
sender.Config = new MarkdownConfig();
sender.Text = markdown;
DescriptionBorderVisbility = Visibility.Visible;
DescriptionBorderVisibility = Visibility.Visible;
});
});
}
Expand Down
9 changes: 4 additions & 5 deletions Natsurainko.FluentLauncher/ViewModels/OOBE/OOBEViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using FluentLauncher.Infra.Settings.Mvvm;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using FluentLauncher.Infra.Settings.Mvvm;
using FluentLauncher.Infra.UI.Navigation;
using Microsoft.UI.Xaml.Controls;
using Natsurainko.FluentLauncher.Services.Accounts;
using Natsurainko.FluentLauncher.Services.Launch;
using Natsurainko.FluentLauncher.Services.Settings;
using Natsurainko.FluentLauncher.Services.UI;
using Natsurainko.FluentLauncher.Services.UI.Messaging;

using Natsurainko.FluentLauncher.Utils;
using Natsurainko.FluentLauncher.Views.Common;
using Nrk.FluentCore.Authentication;
Expand Down Expand Up @@ -305,9 +302,11 @@ public void RemoveJava(string java)
ActiveJavaRuntime = JavaRuntimes.Any() ? JavaRuntimes[0] : null;
}

/*
[RelayCommand]
public void OpenJavaMirrorsDialog(HyperlinkButton parameter)
=> _ = new JavaMirrorsDialog { XamlRoot = parameter.XamlRoot }.ShowAsync();
*/

#endregion

Expand Down
13 changes: 10 additions & 3 deletions Natsurainko.FluentLauncher/ViewModels/Settings/AccountViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using FluentLauncher.Infra.Settings.Mvvm;
using FluentLauncher.Infra.UI.Navigation;
using Microsoft.Extensions.DependencyInjection;
using Natsurainko.FluentLauncher.Services.Accounts;
using Natsurainko.FluentLauncher.Services.Settings;
Expand All @@ -17,6 +18,7 @@
using System.IO;
using System.Threading.Tasks;

#nullable disable
namespace Natsurainko.FluentLauncher.ViewModels.Settings;

internal partial class AccountViewModel : SettingsViewModelBase, ISettingsViewModel
Expand All @@ -27,19 +29,22 @@ internal partial class AccountViewModel : SettingsViewModelBase, ISettingsViewMo
private readonly AuthenticationService _authenticationService;
private readonly NotificationService _notificationService;
private readonly SkinCacheService _skinCacheService;
private readonly INavigationService _navigationService;

public AccountViewModel(
SettingsService settingsService,
AccountService accountService,
AuthenticationService authenticationService,
NotificationService notificationService,
SkinCacheService skinCacheService)
SkinCacheService skinCacheService,
INavigationService navigationService)
{
_settingsService = settingsService;
_accountService = accountService;
_authenticationService = authenticationService;
_notificationService = notificationService;
_skinCacheService = skinCacheService;
_navigationService = navigationService;

Accounts = accountService.Accounts;
ActiveAccount = accountService.ActiveAccount;
Expand Down Expand Up @@ -72,7 +77,7 @@ partial void OnActiveAccountChanged(Account value)
}

[RelayCommand]
public void Login() => _ = new AuthenticationWizardDialog { XamlRoot = MainWindow.XamlRoot }.ShowAsync();
public async Task Login() => await new AuthenticationWizardDialog().ShowAsync();

[RelayCommand]
public async Task Refresh()
Expand All @@ -92,7 +97,6 @@ public void Switch()
{
var switchAccountDialog = new SwitchAccountDialog
{
XamlRoot = Views.MainWindow.XamlRoot,
DataContext = App.Services.GetService<SwitchAccountDialogViewModel>()
};
_ = switchAccountDialog.ShowAsync();
Expand All @@ -106,4 +110,7 @@ public void OpenSkinFile()

using var process = Process.Start(new ProcessStartInfo("explorer.exe", $"/select,{SkinFile}"));
}

[RelayCommand]
public void GoToSkinPage() => _navigationService.NavigateTo("Settings/Account/Skin");
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.UI.Xaml.Controls;
using Natsurainko.FluentLauncher.Utils;
using System.Collections.ObjectModel;
using System.Linq;

#nullable disable
namespace Natsurainko.FluentLauncher.ViewModels.Settings;
Expand Down Expand Up @@ -47,6 +48,6 @@ public void ItemClickedEvent(object args)

if (breadcrumbBarItemClickedEventArgs.Item.ToString() == "Settings")
NavigateTo("Settings/Default");
else NavigateTo(string.Join('/', Routes));
else NavigateTo(string.Join('/', Routes.ToArray()[..^1]));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public sealed partial class AddVmArgumentDialog : ContentDialog
{
public AddVmArgumentDialog()
{
this.XamlRoot = MainWindow.XamlRoot;

this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public sealed partial class AuthenticationWizardDialog : ContentDialog
{
public AuthenticationWizardDialog()
{
this.XamlRoot = MainWindow.XamlRoot;

this.InitializeComponent();
DataContext = new AuthenticationWizardDialogViewModel(
App.GetService<AccountService>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public sealed partial class DeleteGameDialog : ContentDialog
{
public DeleteGameDialog()
{
this.XamlRoot = MainWindow.XamlRoot;

this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public sealed partial class ExceptionDialog : ContentDialog
{
public ExceptionDialog(string errorMessage = "")
{
this.XamlRoot = MainWindow.XamlRoot;

InitializeComponent();
DataContext = new ExceptionDialogViewModel(errorMessage);
}
Expand Down
40 changes: 0 additions & 40 deletions Natsurainko.FluentLauncher/Views/Common/JavaMirrorsDialog.xaml

This file was deleted.

41 changes: 0 additions & 41 deletions Natsurainko.FluentLauncher/Views/Common/JavaMirrorsDialog.xaml.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public sealed partial class ResourceItemFilesDialog : ContentDialog
{
public ResourceItemFilesDialog()
{
this.XamlRoot = MainWindow.XamlRoot;

this.InitializeComponent();
}
}
Loading

0 comments on commit 7ec645d

Please sign in to comment.