2014-02-19 22:50:15 +08:00
|
|
|
using System;
|
2014-07-16 18:52:00 +08:00
|
|
|
using System.Diagnostics;
|
2014-02-19 22:50:15 +08:00
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
2014-07-16 18:52:00 +08:00
|
|
|
using System.Windows;
|
2014-02-19 22:50:15 +08:00
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
2014-07-14 19:03:52 +08:00
|
|
|
using Wox.Helper;
|
2014-02-19 22:50:15 +08:00
|
|
|
|
2014-05-24 14:06:09 +06:00
|
|
|
namespace Wox.Converters
|
2014-02-19 22:50:15 +08:00
|
|
|
{
|
2014-07-16 18:52:00 +08:00
|
|
|
public class ImagePathConverter : IValueConverter
|
2014-02-19 22:50:15 +08:00
|
|
|
{
|
2014-07-16 18:52:00 +08:00
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
2014-02-19 22:50:15 +08:00
|
|
|
{
|
2014-07-16 18:52:00 +08:00
|
|
|
if (value == null || value == DependencyProperty.UnsetValue) return null;
|
2014-02-20 09:34:30 +08:00
|
|
|
|
2014-07-16 18:52:00 +08:00
|
|
|
string fullPath = value.ToString();
|
2014-02-20 18:26:01 +08:00
|
|
|
|
2014-07-16 18:52:00 +08:00
|
|
|
if (fullPath.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
|
2014-02-28 23:21:01 +08:00
|
|
|
{
|
2014-07-16 18:52:00 +08:00
|
|
|
return new BitmapImage(new Uri(fullPath));
|
2014-02-28 23:21:01 +08:00
|
|
|
}
|
2014-07-16 18:52:00 +08:00
|
|
|
|
|
|
|
|
|
2014-07-14 19:03:52 +08:00
|
|
|
return ImageLoader.Load(fullPath);
|
2014-02-19 22:50:15 +08:00
|
|
|
}
|
|
|
|
|
|
2014-07-16 18:52:00 +08:00
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
2014-02-19 22:50:15 +08:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|