SimulatorIoDETMView.xaml.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using Aitex.Common.Util;
  2. using Aitex.Core.UI.MVVM;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Configuration;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. using Venus_Core;
  19. namespace Venus_Simulator.Views
  20. {
  21. /// <summary>
  22. /// SimulatorIoSETMView.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class SimulatorIoDETMView : UserControl
  25. {
  26. public SimulatorIoDETMView()
  27. {
  28. InitializeComponent();
  29. var section = ConfigurationManager.GetSection("customSettings") as System.Collections.Specialized.NameValueCollection;
  30. ConfigType type = (ConfigType)Convert.ToInt32(section["SimulatorType"]);
  31. if (type == ConfigType.VenusDE)
  32. DataContext = new IoViewModel(6834, "DETM.PLC", PathManager.GetCfgDir() + $"_ioDefineVenusDE_MF.xml", "DETM");
  33. else
  34. DataContext = new IoViewModel(6833, "DETM.PLC", PathManager.GetCfgDir() + $"_ioDefineVenusDE_MF.xml", "DETM");
  35. this.IsVisibleChanged += IOView_IsVisibleChanged;
  36. }
  37. private void IOView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  38. {
  39. if (this.DataContext == null)
  40. {
  41. }
  42. (DataContext as TimerViewModelBase).EnableTimer(IsVisible);
  43. }
  44. }
  45. }