123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- namespace Aitex.Core.UI.DeviceControl
- {
- /// <summary>
- /// AITBoostPump.xaml 的交互逻辑
- /// </summary>
- public partial class AITBoostPump : UserControl
- {
- public static readonly DependencyProperty DeviceDataProperty = DependencyProperty.Register(
- "DeviceData", typeof(AITBoostPumpData), typeof(AITBoostPump),
- new FrameworkPropertyMetadata(new AITBoostPumpData(), FrameworkPropertyMetadataOptions.AffectsRender));
- public static readonly DependencyProperty CommandProperty = DependencyProperty.Register(
- "Command", typeof(ICommand), typeof(AITBoostPump),
- new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
-
- public ICommand Command
- {
- get
- {
- return (ICommand)this.GetValue(CommandProperty);
- }
- set
- {
- this.SetValue(CommandProperty, value);
- }
- }
- public AITBoostPumpData DeviceData
- {
- get
- {
- return (AITBoostPumpData)this.GetValue(DeviceDataProperty);
- }
- set
- {
- this.SetValue(DeviceDataProperty, value);
- }
- }
- private AITBoostPumpInputDialogBox _dialogBox;
- public Window AnalogOwner { get; set; }
- public AITBoostPump()
- {
- InitializeComponent();
- }
- protected override void OnRender(DrawingContext drawingContext)
- {
- base.OnRender(drawingContext);
- if (DeviceData == null)
- return;
- if (DeviceData.IsError)
- imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/boost_pump_error.png"));
- else if (DeviceData.IsRunning)
- imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/boost_pump_on.png"));
- else
- imagePicture.Source = new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/Pump/boost_pump_off.png"));
- imagePictureEnable.Visibility = ((int)DeviceData.EnableSetPoint == (int)BoostPumpEnable.Enable) ? Visibility.Visible : Visibility.Hidden;
- LabelPressureSetPoint.Content = DeviceData.PressureSetPointDisplay;
- LabelFrequency.Content = DeviceData.FrequencyDisplay;
- if (_dialogBox != null)
- {
- _dialogBox.Frequency = DeviceData.InverterFrequency;
- }
- }
- private void Grid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
- {
- if (DeviceData == null)
- return;
- _dialogBox = new AITBoostPumpInputDialogBox
- {
- SetPressureCommandDelegate = ExecuteSetPressure,
- DeviceName = DeviceData.DisplayName,
- DeviceId = DeviceData.DeviceSchematicId,
-
- Frequency = DeviceData.InverterFrequency,
- MaxValue = DeviceData.PressureSetPointMax,
- SetPoint = DeviceData.PressureSetPoint,
- RealValue = DeviceData.PressureSetPoint.ToString(),
- Unit = "mTorr",
- };
- if (AnalogOwner != null)
- _dialogBox.Owner = AnalogOwner;
- _dialogBox.Topmost = true;
- _dialogBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
- _dialogBox.FocasAll();
- _dialogBox.ShowDialog();
- _dialogBox = null;
- }
- private void ExecuteSetPressure(double pressure)
- {
- Command.Execute(new object[] { DeviceData.DeviceName, AITBoostPumpOperation.SetPressure.ToString(), pressure.ToString() });
- }
- }
- }
|