mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-15 03:59:15 +08:00
32 lines
982 B
C#
32 lines
982 B
C#
using System;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Windows.Data;
|
|
using System.Windows.Media.Imaging;
|
|
using Wox.Helper;
|
|
|
|
namespace Wox.Converters
|
|
{
|
|
public class ImagePathConverter : IMultiValueConverter
|
|
{
|
|
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (values[0] == null) return null;
|
|
|
|
string relativePath = values[0].ToString();
|
|
string pluginDirectory = values[1].ToString();
|
|
string fullPath = Path.Combine(pluginDirectory, relativePath);
|
|
|
|
if (relativePath.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return new BitmapImage(new Uri(relativePath));
|
|
}
|
|
return ImageLoader.Load(fullPath);
|
|
}
|
|
|
|
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
} |