using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Data; using System.Windows.Media.Imaging; using HMI.Core.Util; namespace HMI.UI.Converter { public class PathImageConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return null; string imagePath = Path.Combine(PathHelper.IconFolder, value.ToString()); if (!File.Exists(imagePath)) return null; return new BitmapImage(new Uri(imagePath)); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return value; } } }