| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 | using Aitex.Core.UI.MVVM;using Aitex.Core.Utilities;using MECF.Framework.Common.Equipment;using MECF.Framework.Common.OperationCenter;using MECF.Framework.Common.Persistent.Prewet;using MECF.Framework.Common.Persistent.SRD;using Microsoft.Win32;using System;using System.Collections.Generic;using System.Diagnostics;using System.Linq;using System.Reflection;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 CyberX8_Themes.UserControls{    /// <summary>    /// OperatingModeControl.xaml 的交互逻辑    /// </summary>    public partial class OperatingModeControl : UserControl    {        public OperatingModeControl()        {            InitializeComponent();        }        public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(          "ModuleName", typeof(string), typeof(OperatingModeControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 模块名称        /// </summary>        public string ModuleName        {            get            {                return (string)this.GetValue(ModuleNameProperty);            }            set            {                this.SetValue(ModuleNameProperty, value);            }        }        public static readonly DependencyProperty SubModuleNameProperty = DependencyProperty.Register(           "SubModuleName", typeof(string), typeof(OperatingModeControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// SubModuleName        /// </summary>        public string SubModuleName        {            get            {                return (string)this.GetValue(SubModuleNameProperty);            }            set            {                this.SetValue(SubModuleNameProperty, value);            }        }        public static readonly DependencyProperty IsDisabledProperty = DependencyProperty.Register(            "IsDisabled", typeof(bool), typeof(OperatingModeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsDisabled        /// </summary>        public bool IsDisabled        {            get            {                return (bool)this.GetValue(IsDisabledProperty);            }            set            {                this.SetValue(IsDisabledProperty, value);            }        }        public static readonly DependencyProperty IsManualProperty = DependencyProperty.Register(            "IsManual", typeof(bool), typeof(OperatingModeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsManual        /// </summary>        public bool IsManual        {            get            {                return (bool)this.GetValue(IsManualProperty);            }            set            {                this.SetValue(IsManualProperty, value);            }        }        public static readonly DependencyProperty IsAutoProperty = DependencyProperty.Register(            "IsAuto", typeof(bool), typeof(OperatingModeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsAuto        /// </summary>        public bool IsAuto        {            get            {                return (bool)this.GetValue(IsAutoProperty);            }            set            {                this.SetValue(IsAutoProperty, value);            }        }        public static readonly DependencyProperty OperationModeValueProperty = DependencyProperty.Register(           "OperationModeValue", typeof(string), typeof(OperatingModeControl), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnItemsSourceChanged)));        /// <summary>        /// OpertationModeValue        /// </summary>        public string OperationModeValue        {            get            {                return (string)this.GetValue(OperationModeValueProperty);            }            set            {                this.SetValue(OperationModeValueProperty, value);            }        }        private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)        {            string moduleName = (string)d.GetValue(ModuleNameProperty);            OperatingModeControl control = (OperatingModeControl)d;            if (e.NewValue != null)            {                string currentMode = (string)e.NewValue;                switch (currentMode)                {                    case "Disabled":                        d.SetValue(IsDisabledProperty, true);                        d.SetValue(IsManualProperty, false);                        d.SetValue(IsAutoProperty, false); break;                    case "Manual":                        d.SetValue(IsDisabledProperty, false);                        d.SetValue(IsManualProperty, true);                        d.SetValue(IsAutoProperty, false); break;                    case "Auto":                        d.SetValue(IsDisabledProperty, false);                        d.SetValue(IsManualProperty, false);                        d.SetValue(IsAutoProperty, true); break;                    default:                        break;                }                                    }        }        private void Disabled_Click(object sender, RoutedEventArgs e)        {            if (SubModuleName == "DosingSystem")            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.DisabledAction", true);            }            else            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.DisabledAction");            }                        }        private void Manual_Click(object sender, RoutedEventArgs e)        {            if(SubModuleName == "DosingSystem")            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ManualAction", true);            }            else            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ManualAction");            }                    }        private void Automatic_Click(object sender, RoutedEventArgs e)        {            if (SubModuleName == "DosingSystem")            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.AutoAction", true);            }            else            {                InvokeClient.Instance.Service.DoOperation($"{ModuleName}.AutoAction");            }                       }          }}
 |