SimulatorIoTMView.xaml.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections.ObjectModel;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Controls.Primitives;
  6. using System.Windows.Data;
  7. using Aitex.Common.Util;
  8. using Aitex.Core.UI.MVVM;
  9. using MECF.Framework.Common.IOCore;
  10. using Venus_Core;
  11. using Venus_Simulator.Instances;
  12. namespace Venus_Simulator.Views
  13. {
  14. /// <summary>
  15. /// IoView.xaml 的交互逻辑
  16. /// </summary>
  17. public partial class SimulatorIoTMView : UserControl
  18. {
  19. public SimulatorIoTMView()
  20. {
  21. InitializeComponent();
  22. int port = 6831;
  23. if (SimulatorJetTM.CurrentTM==JetTMType.VenusSE)
  24. {
  25. port = 6832;
  26. }
  27. DataContext = new IoViewModel(port, "TM.PLC", PathManager.GetCfgDir() + $"_ioDefine{SimulatorJetTM.CurrentTM}_MF.xml", "TM");
  28. this.IsVisibleChanged += IOView_IsVisibleChanged;
  29. }
  30. private void IOView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  31. {
  32. if (this.DataContext == null)
  33. {
  34. }
  35. (DataContext as TimerViewModelBase).EnableTimer(IsVisible);
  36. }
  37. }
  38. }