| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 | using MECF.Framework.Common.CommonData.Reservoir;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.OperationCenter;using MECF.Framework.Common.Persistent.Reservoirs;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;using System.Text.RegularExpressions;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 CyberX8_Themes.UserControls{    /// <summary>    /// CountersControl.xaml 的交互逻辑    /// </summary>    public partial class CountersControl : UserControl    {        public CountersControl()        {            InitializeComponent();        }        public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(           "ModuleName", typeof(string), typeof(CountersControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 模块名称        /// </summary>        public string ModuleName        {            get            {                return (string)this.GetValue(ModuleNameProperty);            }            set            {                this.SetValue(ModuleNameProperty, value);            }        }        public static readonly DependencyProperty ReplenNumProperty = DependencyProperty.Register(           "ReplenNum", typeof(int), typeof(CountersControl), new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// Replen数量        /// </summary>        public int ReplenNum        {            get            {                return (int)this.GetValue(ReplenNumProperty);            }            set            {                this.SetValue(ReplenNumProperty, value);            }        }        public static readonly DependencyProperty ReplenDatasProperty = DependencyProperty.Register(           "ReplenDatas", typeof(ObservableCollection<ReplenData>), typeof(CountersControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// ReplenDatas        /// </summary>        public ObservableCollection<ReplenData> ReplenDatas        {            get            {                return (ObservableCollection<ReplenData>)this.GetValue(ReplenDatasProperty);            }            set            {                this.SetValue(ReplenDatasProperty, value);            }        }        public static readonly DependencyProperty ReplensPersistentCollectionProperty = DependencyProperty.Register(           "ReplensPersistentCollection", typeof(ObservableCollection<ReplenPersistentValue>), typeof(CountersControl), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// Replen Persistent数据集合        /// </summary>        public ObservableCollection<ReplenPersistentValue> ReplensPersistentCollection        {            get            {                return (ObservableCollection<ReplenPersistentValue>)this.GetValue(ReplensPersistentCollectionProperty);            }            set            {                this.SetValue(ReplensPersistentCollectionProperty, value);            }        }        public static readonly DependencyProperty IsManualorAutoProperty = DependencyProperty.Register(           "IsManualorAuto", typeof(bool), typeof(CountersControl), new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsManualorAuto        /// </summary>        public bool IsManualorAuto        {            get            {                return (bool)this.GetValue(IsManualorAutoProperty);            }            set            {                this.SetValue(IsManualorAutoProperty, value);            }        }        /// <summary>        /// Replen1 开始补液        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Replen1Start_Click(object sender, RoutedEventArgs e)        {            if(replen1Volume.Text != "")            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ManualDosing", "Replen1", double.Parse(replen1Volume.Text));            }                        }        /// <summary>        /// Replen1 停止补液        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Replen1Stop_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.StopManualDosing", "Replen1");        }        /// <summary>        /// Replen2 开始补液        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Replen2Start_Click(object sender, RoutedEventArgs e)        {            if (replen2Volume.Text != "")            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ManualDosing", "Replen2", double.Parse(replen2Volume.Text));            }                        }        /// <summary>        /// Replen2 停止补液        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Replen2Stop_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.StopManualDosing", "Replen2");        }        /// <summary>        /// Replen3 开始补液        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Replen3Start_Click(object sender, RoutedEventArgs e)        {            if (replen3Volume.Text != "")            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ManualDosing", "Replen3", double.Parse(replen1Volume.Text));            }        }        /// <summary>        /// Replen3 停止补液        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Replen3Stop_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.StopManualDosing", "Replen3");        }        /// <summary>        /// Replen4 开始补液        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Replen4Start_Click(object sender, RoutedEventArgs e)        {            if (replen4Volume.Text != "")            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ManualDosing", "Replen4", double.Parse(replen1Volume.Text));            }        }        /// <summary>        /// Replen4 停止补液        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void Replen4Stop_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.StopManualDosing", "Replen4");        }        /// <summary>        /// 输入符号限制(数字和.)        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)        {            e.Handled = !IsTextAllowed(e.Text, ((TextBox)sender).Text);        }        private bool IsTextAllowed(string key, string text)        {            Regex regex = new Regex(@"^[0-9\.]+$");            return regex.IsMatch(key);        }    }}
 |