DeviceInfoPlot.xaml.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System.Globalization;
  2. using System.Windows;
  3. using System.Windows.Data;
  4. using System.Windows.Input;
  5. namespace DashBoard.Controls;
  6. /// <summary>
  7. /// Interaction logic for DeviceInfoPlot.xaml
  8. /// </summary>
  9. public partial class DeviceInfoPlot : UserControl
  10. {
  11. public DeviceInfoPlot()
  12. {
  13. InitializeComponent();
  14. }
  15. public DeviceData_VM DeviceData
  16. {
  17. get { return (DeviceData_VM)GetValue(DeviceDataProperty); }
  18. set { SetValue(DeviceDataProperty, value); }
  19. }
  20. public static readonly DependencyProperty DeviceDataProperty =
  21. DependencyProperty.Register("DeviceData", typeof(DeviceData_VM), typeof(DeviceInfoPlot), new PropertyMetadata(default));
  22. public DeviceInfo_VM DeviceInfo
  23. {
  24. get { return (DeviceInfo_VM)GetValue(DeviceInfoProperty); }
  25. set { SetValue(DeviceInfoProperty, value); }
  26. }
  27. public static readonly DependencyProperty DeviceInfoProperty =
  28. DependencyProperty.Register("DeviceInfo", typeof(DeviceInfo_VM), typeof(DeviceInfoPlot), new PropertyMetadata(default));
  29. public ICommand AlarmCommand
  30. {
  31. get { return (ICommand)GetValue(AlarmCommandProperty); }
  32. set { SetValue(AlarmCommandProperty, value); }
  33. }
  34. public static readonly DependencyProperty AlarmCommandProperty =
  35. DependencyProperty.Register("AlarmCommand", typeof(ICommand), typeof(DeviceInfoPlot), new PropertyMetadata(default));
  36. }
  37. public class NumberEnableConverter : IValueConverter
  38. {
  39. public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
  40. {
  41. if (value is not int count)
  42. return default;
  43. return count switch
  44. {
  45. 0 => false,
  46. _ => true
  47. };
  48. }
  49. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  50. {
  51. throw new NotImplementedException();
  52. }
  53. }
  54. public class NumberBrushConverter : IValueConverter
  55. {
  56. public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
  57. {
  58. if (value is not int count)
  59. return default;
  60. return count switch
  61. {
  62. 0 => Application.Current.Resources["DisableColor"],
  63. _ => Application.Current.Resources["EmergencyColor"]
  64. };
  65. }
  66. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  67. {
  68. throw new NotImplementedException();
  69. }
  70. }