mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-03-15 04:14:47 +00:00
misc: chore: Optimize AboutWindowViewModel resource disposal
This commit is contained in:
parent
ad89cf39b6
commit
43f7b000ca
2 changed files with 14 additions and 8 deletions
|
@ -2,6 +2,7 @@ using Avalonia.Media.Imaging;
|
|||
using Avalonia.Styling;
|
||||
using Avalonia.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Gommon;
|
||||
using Ryujinx.Ava.Common;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.Utilities.Configuration;
|
||||
|
@ -32,15 +33,16 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value));
|
||||
}
|
||||
|
||||
private const string LogoPathFormat = "resm:Ryujinx.Assets.UIImages.Logo_{0}_{1}.png?assembly=Ryujinx";
|
||||
|
||||
private void UpdateLogoTheme(string theme)
|
||||
{
|
||||
bool isDarkTheme = theme == "Dark" || (theme == "Auto" && RyujinxApp.DetectSystemTheme() == ThemeVariant.Dark);
|
||||
|
||||
string themeName = isDarkTheme ? "Dark" : "Light";
|
||||
|
||||
string basePath = "resm:Ryujinx.Assets.UIImages.";
|
||||
string themeSuffix = isDarkTheme ? "Dark.png" : "Light.png";
|
||||
|
||||
GithubLogo = LoadBitmap($"{basePath}Logo_GitHub_{themeSuffix}?assembly=Ryujinx");
|
||||
DiscordLogo = LoadBitmap($"{basePath}Logo_Discord_{themeSuffix}?assembly=Ryujinx");
|
||||
GithubLogo = LoadBitmap(LogoPathFormat.Format("GitHub", themeName));
|
||||
DiscordLogo = LoadBitmap(LogoPathFormat.Format("Discord", themeName));
|
||||
}
|
||||
|
||||
private static Bitmap LoadBitmap(string uri) => new(Avalonia.Platform.AssetLoader.Open(new Uri(uri)));
|
||||
|
@ -48,6 +50,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
public void Dispose()
|
||||
{
|
||||
ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged;
|
||||
|
||||
GithubLogo.Dispose();
|
||||
DiscordLogo.Dispose();
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
{
|
||||
public AboutWindow()
|
||||
{
|
||||
DataContext = new AboutWindowViewModel();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
GitHubRepoButton.Tag =
|
||||
|
@ -28,12 +26,14 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
public static async Task Show()
|
||||
{
|
||||
using AboutWindowViewModel viewModel = new();
|
||||
|
||||
ContentDialog contentDialog = new()
|
||||
{
|
||||
PrimaryButtonText = string.Empty,
|
||||
SecondaryButtonText = string.Empty,
|
||||
CloseButtonText = LocaleManager.Instance[LocaleKeys.UserProfilesClose],
|
||||
Content = new AboutWindow()
|
||||
Content = new AboutWindow { DataContext = viewModel }
|
||||
};
|
||||
|
||||
Style closeButton = new(x => x.Name("CloseButton"));
|
||||
|
|
Loading…
Add table
Reference in a new issue