SimulatorIoTMView.xaml.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Collections.ObjectModel;
  3. using System.Configuration;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Controls.Primitives;
  7. using System.Windows.Data;
  8. using Aitex.Common.Util;
  9. using Aitex.Core.UI.MVVM;
  10. using MECF.Framework.Common.IOCore;
  11. using Venus_Core;
  12. using Venus_Simulator.Instances;
  13. namespace Venus_Simulator.Views
  14. {
  15. /// <summary>
  16. /// IoView.xaml 的交互逻辑
  17. /// </summary>
  18. public partial class SimulatorIoTMView : UserControl
  19. {
  20. public SimulatorIoTMView()
  21. {
  22. InitializeComponent();
  23. //if (SimulatorJetTM.CurrentTM==JetTMType.VenusSE)
  24. //{
  25. // port = 6831;
  26. //}
  27. var section = ConfigurationManager.GetSection("customSettings") as System.Collections.Specialized.NameValueCollection;
  28. ConfigType type = (ConfigType)Convert.ToInt32(section["SimulatorType"]);
  29. if (type == ConfigType.Kepler2200 || type == ConfigType.Kepler2300)
  30. DataContext = new IoViewModel(6834, "TM.PLC", PathManager.GetCfgDir() + $"_ioDefineVenus_MF.xml", "TM");
  31. else
  32. DataContext = new IoViewModel(6831, "TM.PLC", PathManager.GetCfgDir() + $"_ioDefineVenus_MF.xml", "TM");
  33. this.IsVisibleChanged += IOView_IsVisibleChanged;
  34. }
  35. private void IOView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  36. {
  37. if (this.DataContext == null)
  38. {
  39. }
  40. (DataContext as TimerViewModelBase).EnableTimer(IsVisible);
  41. }
  42. }
  43. }