using Aitex.Common.Util; using Aitex.Core.UI.MVVM; using System.Windows; using System.Windows.Controls; namespace FurnaceSimulator.Views { /// /// SimulatorPlcInt16IOView.xaml 的交互逻辑 /// 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; } } }