2025-07-14 10:06:38 +03:00
|
|
|
using System;
|
2024-12-21 13:11:30 +03:00
|
|
|
using Avalonia.Data.Converters;
|
|
|
|
|
using Avalonia.Media;
|
2025-07-14 10:06:38 +03:00
|
|
|
using Avalonia.Platform;
|
2024-12-21 13:11:30 +03:00
|
|
|
|
|
|
|
|
namespace Nebula.Launcher.Converters;
|
|
|
|
|
|
2025-07-14 10:06:38 +03:00
|
|
|
public static class TypeConverters
|
2024-12-21 13:11:30 +03:00
|
|
|
{
|
2025-01-18 18:20:11 +03:00
|
|
|
public static FuncValueConverter<string, string?> IconConverter { get; } =
|
2024-12-21 13:11:30 +03:00
|
|
|
new(iconKey =>
|
|
|
|
|
{
|
2025-01-18 18:20:11 +03:00
|
|
|
if (iconKey == null) return null;
|
|
|
|
|
return $"/Assets/svg/{iconKey}.svg";
|
2024-12-21 13:11:30 +03:00
|
|
|
});
|
2025-07-14 10:06:38 +03:00
|
|
|
|
|
|
|
|
public static FuncValueConverter<string, IImage?> ImageConverter { get; } =
|
|
|
|
|
new(iconKey =>
|
|
|
|
|
{
|
|
|
|
|
if (iconKey == null) return null;
|
|
|
|
|
return new Avalonia.Media.Imaging.Bitmap(AssetLoader.Open(new Uri($"avares://Nebula.Launcher/Assets/error_presentation/{iconKey}.png")));
|
|
|
|
|
});
|
2024-12-21 13:11:30 +03:00
|
|
|
}
|