DevicePlot.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Globalization;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. using System.Windows.Data;
  5. using System.Windows.Input;
  6. using System.Windows.Media.Imaging;
  7. namespace DeviceManagement.Controls;
  8. public partial class DevicePlot : UserControl
  9. {
  10. public DevicePlot()
  11. {
  12. InitializeComponent();
  13. }
  14. public DeviceInfo_VM DeviceInfo
  15. {
  16. get { return (DeviceInfo_VM)GetValue(DeviceInfoProperty); }
  17. set { SetValue(DeviceInfoProperty, value); }
  18. }
  19. public static readonly DependencyProperty DeviceInfoProperty =
  20. DependencyProperty.Register("DeviceInfo", typeof(DeviceInfo_VM), typeof(DevicePlot), new PropertyMetadata(default));
  21. public ICommand SettingCommand
  22. {
  23. get { return (ICommand)GetValue(SettingCommandProperty); }
  24. set { SetValue(SettingCommandProperty, value); }
  25. }
  26. public static readonly DependencyProperty SettingCommandProperty =
  27. DependencyProperty.Register("SettingCommand", typeof(ICommand), typeof(DevicePlot), new PropertyMetadata(default));
  28. public ICommand DetailCommand
  29. {
  30. get { return (ICommand)GetValue(DetailCommandProperty); }
  31. set { SetValue(DetailCommandProperty, value); }
  32. }
  33. public static readonly DependencyProperty DetailCommandProperty =
  34. DependencyProperty.Register("DetailCommand", typeof(ICommand), typeof(DevicePlot), new PropertyMetadata(default));
  35. }
  36. internal class DeviceImageConverter : IValueConverter
  37. {
  38. public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
  39. {
  40. if (value is not DeviceModel deviceModel)
  41. return null;
  42. return deviceModel switch
  43. {
  44. DeviceModel.JetKepler => new BitmapImage(new Uri("/DeviceManagement;component/Resources/Kepler.png", UriKind.Relative)),
  45. DeviceModel.Proxima => new BitmapImage(new Uri("/DeviceManagement;component/Resources/Furnace.png", UriKind.Relative)),
  46. _ => null
  47. };
  48. }
  49. public object? ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  50. {
  51. return null;
  52. }
  53. }