using Aitex.Core.UI.MVVM; using Aitex.Core.Utilities; using MECF.Framework.Common.CommonData.Prewet; using MECF.Framework.Common.OperationCenter; using MECF.Framework.Common.Persistent.Prewet; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; 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; namespace PunkHPX8_Themes.UserControls { /// /// VPWBoosterPumpControl.xaml 的交互逻辑 /// public partial class VPWBoosterPumpControl : UserControl { public VPWBoosterPumpControl() { KeyDownCommand = new DelegateCommand(KeyDownAction); InitializeComponent(); } #region 属性 public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register( "ModuleName", typeof(string), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender)); /// /// 模块名称 /// public string ModuleName { get { return (string)this.GetValue(ModuleNameProperty); } set { this.SetValue(ModuleNameProperty, value); } } public static readonly DependencyProperty StatusValueProperty = DependencyProperty.Register( "StatusValue", typeof(string), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender)); /// /// StatusValue /// public string StatusValue { get { return (string)this.GetValue(StatusValueProperty); } set { this.SetValue(StatusValueProperty, value); } } public static readonly DependencyProperty InputPumpSpeedProperty = DependencyProperty.Register( "InputPumpSpeed", typeof(short), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata((short)300, FrameworkPropertyMetadataOptions.AffectsRender)); /// /// InputLowThreshold /// public short InputPumpSpeed { get { return (short)this.GetValue(InputPumpSpeedProperty); } set { this.SetValue(InputPumpSpeedProperty, value); } } public static readonly DependencyProperty PumpEnableProperty = DependencyProperty.Register( "PumpEnable", typeof(bool), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)); /// /// PumpEnable /// public bool PumpEnable { get { return (bool)this.GetValue(PumpEnableProperty); } set { this.SetValue(PumpEnableProperty, value); } } public static readonly DependencyProperty PumpSpeedAutoProperty = DependencyProperty.Register( "PumpSpeedAuto", typeof(bool), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender)); /// /// PumpSpeedAuto /// public bool PumpSpeedAuto { get { return (bool)this.GetValue(PumpSpeedAutoProperty); } set { this.SetValue(PumpSpeedAutoProperty, value); } } public static readonly DependencyProperty PressureCurrentProperty = DependencyProperty.Register( "PressureCurrent", typeof(double), typeof(VPWBoosterPumpControl), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender)); /// /// "PressureCurrent /// public double PressureCurrent { get { return (double)this.GetValue(PressureCurrentProperty); } set { this.SetValue(PressureCurrentProperty, value); } } #endregion [IgnorePropertyChange] public ICommand KeyDownCommand { get; private set; } private void KeyDownAction(object[] param) { if (param.Length >= 1) { if (short.TryParse(param[1].ToString(), out short paramValue)) { if (paramValue < 300 || paramValue > 7300) { MessageBox.Show("qualified values 300 ~ 7300", "Invalid Speed Input", MessageBoxButton.OK, MessageBoxImage.Error); } else { InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpSpeed", paramValue); } } } } #region 按钮事件 private void PumpOff_Click(object sender, RoutedEventArgs e) { InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpDisable"); } private void PumpOn_Click(object sender, RoutedEventArgs e) { InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpEnable"); } private void Auto_Click(object sender, RoutedEventArgs e) { InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpSpeedAuto"); } private void Manual_Click(object sender, RoutedEventArgs e) { InvokeClient.Instance.Service.DoOperation($"{ModuleName}.BoosterPumpSpeedManual"); } #endregion } }