mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 07:36:59 +00:00
rewrite EmbeddedAvaloniaResources
This commit is contained in:
parent
9dcb71e120
commit
c8c5b9bbfb
4 changed files with 36 additions and 35 deletions
|
|
@ -1,31 +0,0 @@
|
|||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Styling;
|
||||
using Gommon;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Ava.Common
|
||||
{
|
||||
public static class EmbeddedAvaloniaResources
|
||||
{
|
||||
public const string LogoPathFormat = "resm:Ryujinx.Assets.UIImages.Logo_{0}_{1}.png?assembly=Ryujinx";
|
||||
|
||||
public static Bitmap LoadBitmap(string uri)
|
||||
=> new(AssetLoader.Open(new Uri(uri)));
|
||||
|
||||
public static Bitmap GetIconByNameAndTheme(string iconName, bool isDarkTheme)
|
||||
{
|
||||
string themeName = isDarkTheme ? "Dark" : "Light";
|
||||
|
||||
return LoadBitmap(LogoPathFormat.Format(iconName, themeName));
|
||||
}
|
||||
|
||||
public static Bitmap GetIconByNameAndTheme(string iconName, string theme)
|
||||
{
|
||||
bool isDarkTheme = theme == "Dark" ||
|
||||
(theme == "Auto" && RyujinxApp.DetectSystemTheme() == ThemeVariant.Dark);
|
||||
|
||||
return GetIconByNameAndTheme(iconName, isDarkTheme);
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/Ryujinx/Common/UIImages.cs
Normal file
32
src/Ryujinx/Common/UIImages.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Gommon;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.Ava.Common
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
// UiImages is ugly, so no
|
||||
public static class UIImages
|
||||
{
|
||||
public const string LogoPathFormat = "resm:Ryujinx.Assets.UIImages.Logo_{0}_{1}.png?assembly=Ryujinx";
|
||||
public const string IconPathFormat = "resm:Ryujinx.Assets.UIImages.Icon_{0}.png?assembly=Ryujinx";
|
||||
|
||||
public static Bitmap LoadBitmap(string uri)
|
||||
=> new(AssetLoader.Open(new Uri(uri)));
|
||||
|
||||
public static Bitmap GetIconByName(string iconName)
|
||||
=> LoadBitmap(IconPathFormat.Format(iconName));
|
||||
|
||||
public static Bitmap GetLogoByNameAndTheme(string iconName, bool isDarkTheme) =>
|
||||
LoadBitmap(LogoPathFormat.Format(iconName,
|
||||
isDarkTheme
|
||||
? "Dark"
|
||||
: "Light"
|
||||
)
|
||||
);
|
||||
|
||||
public static Bitmap GetLogoByNameAndVariant(string iconName, string theme)
|
||||
=> LoadBitmap(LogoPathFormat.Format(iconName, theme));
|
||||
}
|
||||
}
|
||||
|
|
@ -109,8 +109,8 @@ namespace Ryujinx.Ava.UI.SetupWizard
|
|||
bool isDarkTheme = theme == "Dark" ||
|
||||
(theme == "Auto" && RyujinxApp.DetectSystemTheme() == ThemeVariant.Dark);
|
||||
|
||||
DiscordLogo = EmbeddedAvaloniaResources
|
||||
.GetIconByNameAndTheme("Discord", isDarkTheme)
|
||||
DiscordLogo = UIImages
|
||||
.GetLogoByNameAndTheme("Discord", isDarkTheme)
|
||||
.CreateScaledBitmap(new PixelSize(32, 24));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
bool isDarkTheme = theme == "Dark" ||
|
||||
(theme == "Auto" && RyujinxApp.DetectSystemTheme() == ThemeVariant.Dark);
|
||||
|
||||
DiscordLogo = EmbeddedAvaloniaResources.GetIconByNameAndTheme("Discord", isDarkTheme)
|
||||
DiscordLogo = UIImages.GetLogoByNameAndTheme("Discord", isDarkTheme)
|
||||
.CreateScaledBitmap(new PixelSize(32, 24));
|
||||
GitLabLogo = EmbeddedAvaloniaResources.GetIconByNameAndTheme("GitLab", isDarkTheme)
|
||||
GitLabLogo = UIImages.GetLogoByNameAndTheme("GitLab", isDarkTheme)
|
||||
.CreateScaledBitmap(new PixelSize(32, 31));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue