| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using TeamAAS_VP.Enums;
- namespace TeamAAS_VP.ValueConverter
- {
- public class CameraMountConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value == null || !(value is CameraMount))
- return null;
- CameraMount enumValue = (CameraMount)value;
- string imageName = string.Empty;
- // 根据枚举值选择对应的图片资源名称
- switch (enumValue)
- {
- case CameraMount.FixedUp:
- imageName = "FixedUp.jpg";
- break;
- case CameraMount.FixedDown:
- imageName = "FixedDown.jpg";
- break;
- case CameraMount.MobileJ2:
- imageName = "MobileJ2.jpg";
- break;
- case CameraMount.MobileJ4:
- imageName = "MobileJ4.jpg";
- break;
- case CameraMount.MobileDown_XYPlatform:
- imageName = "MobileDown.png";
- break;
- case CameraMount.MobileDown_IndependentXYPlatform:
- imageName = "MobileDown_IndependentXYPlatform.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;
- }
- }
- }
|