| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 | 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 CyberX8_Themes.UserControls{    /// <summary>    /// RecipeModeControl.xaml 的交互逻辑    /// </summary>    public partial class RecipeModeControl : UserControl    {        public RecipeModeControl()        {            InitializeComponent();        }        public static readonly DependencyProperty ModuleNameProperty = DependencyProperty.Register(         "ModuleName", typeof(string), typeof(RecipeModeControl), new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// 模块名称        /// </summary>        public string ModuleName        {            get            {                return (string)this.GetValue(ModuleNameProperty);            }            set            {                this.SetValue(ModuleNameProperty, value);            }        }        public static readonly DependencyProperty IsEngineeringProperty = DependencyProperty.Register(           "IsEngineering", typeof(bool), typeof(RecipeModeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsEngineering        /// </summary>        public bool IsEngineering        {            get            {                return (bool)this.GetValue(IsEngineeringProperty);            }            set            {                this.SetValue(IsEngineeringProperty, value);            }        }        public static readonly DependencyProperty IsProductionProperty = DependencyProperty.Register(            "IsProduction", typeof(bool), typeof(RecipeModeControl), new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsRender));        /// <summary>        /// IsProduction        /// </summary>        public bool IsProduction        {            get            {                return (bool)this.GetValue(IsProductionProperty);            }            set            {                this.SetValue(IsProductionProperty, value);            }        }        public static readonly DependencyProperty RecipeModeValueProperty = DependencyProperty.Register(           "RecipeModeValue", typeof(string), typeof(RecipeModeControl), new FrameworkPropertyMetadata("", new PropertyChangedCallback(OnItemsSourceChanged)));        /// <summary>        /// OpertationModeValue        /// </summary>        public string RecipeModeValue        {            get            {                return (string)this.GetValue(RecipeModeValueProperty);            }            set            {                this.SetValue(RecipeModeValueProperty, value);            }        }        private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)        {            if (e.NewValue != null)            {                string currentMode = (string)e.NewValue;                switch (currentMode)                {                    case "Engineering":                        d.SetValue(IsEngineeringProperty, true);                        d.SetValue(IsProductionProperty, false);                         break;                    case "Production":                        d.SetValue(IsEngineeringProperty, false);                        d.SetValue(IsProductionProperty, true);                         break;                    default:                        break;                }            }        }        private void Engineering_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.EngineeringModeAction");        }        private void Production_Click(object sender, RoutedEventArgs e)        {            InvokeClient.Instance.Service.DoOperation($"{ModuleName}.ProductionModeAction");        }    }}
 |