mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 10:54:55 +08:00
30 lines
849 B
C#
30 lines
849 B
C#
using BetterLyrics.WinUI3.Helper;
|
|
using Microsoft.UI.Xaml.Data;
|
|
using Microsoft.UI.Xaml.Media.Imaging;
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace BetterLyrics.WinUI3.Converter
|
|
{
|
|
public partial class PathToImageConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|
{
|
|
string targetPath = PathHelper.AlbumArtPlaceholderPath;
|
|
if (value is string path)
|
|
{
|
|
if (File.Exists(path))
|
|
{
|
|
targetPath = path;
|
|
}
|
|
}
|
|
return new BitmapImage(new Uri(targetPath));
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|