mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-26 23:19:15 +00:00
ui: show icon preview next to name during icon selection
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
using Avalonia.Media.Imaging;
|
||||||
|
using Ryujinx.Ava.UI.Controls;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Common.Models
|
namespace Ryujinx.Ava.Common.Models
|
||||||
{
|
{
|
||||||
public class ApplicationIcon
|
public class ApplicationIcon
|
||||||
@@ -8,5 +11,13 @@ namespace Ryujinx.Ava.Common.Models
|
|||||||
{
|
{
|
||||||
get => $"Ryujinx/Assets/Icons/AppIcons/{Filename}";
|
get => $"Ryujinx/Assets/Icons/AppIcons/{Filename}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Bitmap Icon
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return RyujinxLogo.GetBitmapForLogo(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -60,15 +60,10 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
Stream activeIconStream = EmbeddedResources.GetStream(selectedIcon.FullPath);
|
Stream activeIconStream = EmbeddedResources.GetStream(selectedIcon.FullPath);
|
||||||
if (activeIconStream != null)
|
if (activeIconStream != null)
|
||||||
{
|
{
|
||||||
// SVG files need to be converted to an image first
|
Bitmap logoBitmap = GetBitmapForLogo(selectedIcon);
|
||||||
if (selectedIcon.FullPath.EndsWith(".svg", StringComparison.OrdinalIgnoreCase))
|
if (logoBitmap != null)
|
||||||
{
|
{
|
||||||
Stream pngStream = ConvertSvgToPng(activeIconStream);
|
CurrentLogoBitmap.Value = logoBitmap;
|
||||||
CurrentLogoBitmap.Value = new Bitmap(pngStream);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CurrentLogoBitmap.Value = new Bitmap(activeIconStream);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,6 +77,24 @@ namespace Ryujinx.Ava.UI.Controls
|
|||||||
|
|
||||||
private void WindowIconChanged_Event(object _, ReactiveEventArgs<string> rArgs) => SetNewAppIcon(rArgs.NewValue);
|
private void WindowIconChanged_Event(object _, ReactiveEventArgs<string> rArgs) => SetNewAppIcon(rArgs.NewValue);
|
||||||
|
|
||||||
|
public static Bitmap GetBitmapForLogo(ApplicationIcon icon)
|
||||||
|
{
|
||||||
|
Stream activeIconStream = EmbeddedResources.GetStream(icon.FullPath);
|
||||||
|
if (activeIconStream == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// SVG files need to be converted to an image first
|
||||||
|
if (icon.FullPath.EndsWith(".svg", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
Stream pngStream = ConvertSvgToPng(activeIconStream);
|
||||||
|
return new Bitmap(pngStream);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Bitmap(activeIconStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Stream ConvertSvgToPng(Stream svgStream)
|
private static Stream ConvertSvgToPng(Stream svgStream)
|
||||||
{
|
{
|
||||||
int width = 256;
|
int width = 256;
|
||||||
|
|||||||
@@ -173,7 +173,10 @@
|
|||||||
SelectedIndex="{Binding AppIconSelectedIndex}">
|
SelectedIndex="{Binding AppIconSelectedIndex}">
|
||||||
<ComboBox.ItemTemplate>
|
<ComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock Text="{Binding Name}" />
|
<StackPanel Orientation="Horizontal" >
|
||||||
|
<Image Source="{Binding Icon}" Width="24" Height="24" Margin="0,0,8,0" />
|
||||||
|
<TextBlock Text="{Binding Name}" />
|
||||||
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ComboBox.ItemTemplate>
|
</ComboBox.ItemTemplate>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
|||||||
Reference in New Issue
Block a user