| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 | using Aitex.Core.UI.MVVM;using Aitex.Core.Utilities;using MECF.Framework.Common.OperationCenter;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{    /// <summary>    /// VPWMainVacuumPumpControl.xaml 的交互逻辑    /// </summary>    public partial class VPWMainVacuumPumpControl : UserControl    {        public VPWMainVacuumPumpControl()        {            KeyDownCommand = new DelegateCommand<object[]>(KeyDownAction);            InitializeComponent();                    }        #region 属性        public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(           "ModuleName", typeof(string), typeof(VPWMainVacuumPumpControl),           new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 模块名称        /// </summary>        public string ModuleName        {            get            {                return (string)this.GetValue(ModuleNameProperty);            }            set            {                this.SetValue(ModuleNameProperty, value);            }        }        public static readonly DependencyProperty InputPumpSpeedProperty = DependencyProperty.Register(        "InputPumpSpeed", typeof(short), typeof(VPWMainVacuumPumpControl), new FrameworkPropertyMetadata((short)0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// InputLowThreshold        /// </summary>        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(VPWMainVacuumPumpControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// PumpEnable        /// </summary>        public bool PumpEnable        {            get            {                return (bool)this.GetValue(PumpEnableProperty);            }            set            {                this.SetValue(PumpEnableProperty, value);            }        }        public static readonly DependencyProperty PumpPWREnableProperty = DependencyProperty.Register(            "PumpPWREnable", typeof(bool), typeof(VPWMainVacuumPumpControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// PumpPWREnable        /// </summary>        public bool PumpPWREnable        {            get            {                return (bool)this.GetValue(PumpPWREnableProperty);            }            set            {                this.SetValue(PumpPWREnableProperty, value);            }        }        public static readonly DependencyProperty PumpSpeedControlEnableProperty = DependencyProperty.Register(        "PumpSpeedControlEnable", typeof(bool), typeof(VPWMainVacuumPumpControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// PumpSpeedControlEnable        /// </summary>        public bool PumpSpeedControlEnable        {            get            {                return (bool)this.GetValue(PumpSpeedControlEnableProperty);            }            set            {                this.SetValue(PumpSpeedControlEnableProperty, value);            }        }        public static readonly DependencyProperty PumpPressureProperty = DependencyProperty.Register(        "PumpPressure", typeof(double), typeof(VPWMainVacuumPumpControl), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// PumpPressure        /// </summary>        public double PumpPressure        {            get            {                return (double)this.GetValue(PumpPressureProperty);            }            set            {                this.SetValue(PumpPressureProperty, 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 < 0 || paramValue > 10)                    {                        MessageBox.Show("qualified values 0 ~ 10", "Invalid Speed Input", MessageBoxButton.OK, MessageBoxImage.Error);                    }                    else                    {                        InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumPumpSpeed", paramValue);                    }                                        }            }        }        #region 按钮事件        #endregion        private void PumpPWROn_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumPumpPowerOn");        }        private void PumpPWROff_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumPumpPowerOff");        }        private void PumpEnableOn_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumPumpEnable");        }        private void PumpEnableOff_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumPumpDisable");        }        private void PumpControlOn_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumPumpSpeedEnable");        }        private void PumpControlOff_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.VacuumPumpSpeedDisable");        }    }}
 |