NewDevicePlot.xaml.cs 1.9 KB

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