alielie
2025-11-24 9211ec11c112e18cd99e77f889a01110a70031ce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
        }
    }
}