| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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;
- using TeamAAS_VP.Enums;
- namespace TeamAAS_VP.ValueConverter
- {
- public class PickPlaceModelConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value == null || !(value is PickPlaceModel))
- return null;
- PickPlaceModel enumValue = (PickPlaceModel)value;
- string imageName = string.Empty;
- // 根据枚举值选择对应的图片资源名称
- switch (enumValue)
- {
- case PickPlaceModel.Inhal:
- imageName = "Inhal.png";
- break;
- case PickPlaceModel.Clamp:
- imageName = "Clamp.png";
- break;
- default:
- break;
- }
- // 返回图片资源的URI
- return new BitmapImage(new Uri($"/Resources/Images/{imageName}", UriKind.Relative));
- //return new BitmapImage(new Uri($"{imageName}"));
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return null;
- }
- }
- }
|