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 { /// /// AITBoostPump.xaml 的交互逻辑 /// 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() }); } } }