AITBoostPump.xaml.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. using Aitex.Core.Common.DeviceData;
  15. using Aitex.Core.RT.Device;
  16. using Aitex.Core.RT.Device.Unit;
  17. namespace Aitex.Core.UI.DeviceControl
  18. {
  19. /// <summary>
  20. /// AITBoostPump.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class AITBoostPump : UserControl
  23. {
  24. public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
  25. "DeviceData", typeof(AITBoostPumpData), typeof(AITBoostPump),
  26. new FrameworkPropertyMetadata(new AITBoostPumpData(), FrameworkPropertyMetadataOptions.AffectsRender));
  27. public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
  28. "Command", typeof(ICommand), typeof(AITBoostPump),
  29. new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
  30. public ICommand Command
  31. {
  32. get
  33. {
  34. return (ICommand)this.GetValue(CommandProperty);
  35. }
  36. set
  37. {
  38. this.SetValue(CommandProperty, value);
  39. }
  40. }
  41. public AITBoostPumpData DeviceData
  42. {
  43. get
  44. {
  45. return (AITBoostPumpData)this.GetValue(DeviceDataProperty);
  46. }
  47. set
  48. {
  49. this.SetValue(DeviceDataProperty, value);
  50. }
  51. }
  52. private AITBoostPumpInputDialogBox _dialogBox;
  53. public Window AnalogOwner { get; set; }
  54. public AITBoostPump()
  55. {
  56. InitializeComponent();
  57. }
  58. protected override void OnRender(DrawingContext drawingContext)
  59. {
  60. base.OnRender(drawingContext);
  61. if (DeviceData == null)
  62. return;
  63. if (DeviceData.IsError)
  64. imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/boost_pump_error.png"));
  65. else if (DeviceData.IsRunning)
  66. imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/boost_pump_on.png"));
  67. else
  68. imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/boost_pump_off.png"));
  69. imagePictureEnable.Visibility = ((int)DeviceData.EnableSetPoint == (int)BoostPumpEnable.Enable) ? Visibility.Visible : Visibility.Hidden;
  70. LabelPressureSetPoint.Content = DeviceData.PressureSetPointDisplay;
  71. LabelFrequency.Content = DeviceData.FrequencyDisplay;
  72. if (_dialogBox != null)
  73. {
  74. _dialogBox.Frequency = DeviceData.InverterFrequency;
  75. }
  76. }
  77. private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  78. {
  79. if (DeviceData == null)
  80. return;
  81. _dialogBox = new AITBoostPumpInputDialogBox
  82. {
  83. SetPressureCommandDelegate = ExecuteSetPressure,
  84. DeviceName = DeviceData.DisplayName,
  85. DeviceId = DeviceData.DeviceSchematicId,
  86. Frequency = DeviceData.InverterFrequency,
  87. MaxValue = DeviceData.PressureSetPointMax,
  88. SetPoint = DeviceData.PressureSetPoint,
  89. RealValue = DeviceData.PressureSetPoint.ToString(),
  90. Unit = "mTorr",
  91. };
  92. if (AnalogOwner != null)
  93. _dialogBox.Owner = AnalogOwner;
  94. _dialogBox.Topmost = true;
  95. _dialogBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
  96. _dialogBox.FocasAll();
  97. _dialogBox.ShowDialog();
  98. _dialogBox = null;
  99. }
  100. private void ExecuteSetPressure(double pressure)
  101. {
  102. Command.Execute(new object[] { DeviceData.DeviceName, AITBoostPumpOperation.SetPressure.ToString(), pressure.ToString() });
  103. }
  104. }
  105. }