using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace PDF_Office.DataConvert
{
    /// <summary>
    /// 文件绝对路径 转ImageSource  转换器
    /// </summary>
    public class FileToImageSourceConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if(!string.IsNullOrEmpty((string)value)&&System.IO.File.Exists((string)value))
            {
                return new BitmapImage(new Uri((string)value, UriKind.Relative));
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}