| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | using Aitex.Common.Util;using Aitex.Core.UI.MVVM;using System.Windows;using System.Windows.Controls;namespace FurnaceSimulator.Views{    /// <summary>    /// SimulatorPlcInt16IOView.xaml 的交互逻辑    /// </summary>    public partial class SimulatorPlcInt16IOView : UserControl    {        public static readonly DependencyProperty PortProperty = DependencyProperty.Register(             "Port", typeof(int), typeof(SimulatorPlcInt16IOView),             new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsRender));        public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(             "Source", typeof(string), typeof(SimulatorPlcInt16IOView),             new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        public static readonly DependencyProperty ModuleProperty = DependencyProperty.Register(             "Module", typeof(string), typeof(SimulatorPlcInt16IOView),             new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        public static readonly DependencyProperty IoMapFileProperty = DependencyProperty.Register(             "IoMapFile", typeof(string), typeof(SimulatorPlcInt16IOView),             new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.AffectsRender));        public int Port        {            get            {                return (int)this.GetValue(PortProperty);            }            set            {                this.SetValue(PortProperty, value);            }        }        public string Source        {            get            {                return (string)this.GetValue(SourceProperty);            }            set            {                this.SetValue(SourceProperty, value);            }        }        public string Module        {            get            {                return (string)this.GetValue(ModuleProperty);            }            set            {                this.SetValue(ModuleProperty, value);            }        }        public string IoMapFile        {            get            {                return (string)this.GetValue(IoMapFileProperty);            }            set            {                this.SetValue(IoMapFileProperty, value);            }        }        private void OnViewLoaded(object sender, RoutedEventArgs e)        {            if (DataContext == null)            {                DataContext = new IoViewModel(Port, Source, $"{PathManager.GetCfgDir()}{IoMapFile}", Module);                (DataContext as TimerViewModelBase).Start();            }        }        public SimulatorPlcInt16IOView()        {            InitializeComponent();            this.Loaded += OnViewLoaded;        }    }}
 |