终端一体化运控平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

142 linhas
4.1 KiB

  1. using BPASmartClient.Business;
  2. using BPA.Helper;
  3. using BPASmartClient.Model;
  4. using BPA.Helper;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Reflection;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Input;
  13. using System.Windows.Threading;
  14. using System.Windows.Controls;
  15. using System.Collections.Concurrent;
  16. namespace BPASmartClient.ViewModel
  17. {
  18. /// <summary>
  19. /// 主界面
  20. /// </summary>
  21. public class MainViewModel : NotifyBase
  22. {
  23. /// <summary>
  24. /// 网络连接状态
  25. /// </summary>
  26. private bool _NetworkConnectState = true;
  27. public bool NetworkConnectState
  28. {
  29. get
  30. {
  31. return _NetworkConnectState;
  32. }
  33. set
  34. {
  35. if (_NetworkConnectState == value)
  36. return;
  37. _NetworkConnectState = value;
  38. OnPropertyChanged("NetworkConnectState");
  39. }
  40. }
  41. /// <summary>
  42. /// 是否告警
  43. /// </summary>
  44. public AlarmModel IsAlarm { get; set; }
  45. public System.Windows.Window window;
  46. public DispatcherTimer dispatcherTimer;
  47. #region 单一
  48. private volatile static MainViewModel _Instance;
  49. public static MainViewModel GetInstance() => _Instance ?? (_Instance = new MainViewModel());
  50. #endregion
  51. #region 页面存储
  52. public ConcurrentDictionary<string, FrameworkElement> MenuItems = new ConcurrentDictionary<string, FrameworkElement>();
  53. #endregion
  54. public MainViewModel()
  55. {
  56. IsAlarm = new AlarmModel();
  57. FoodMenuViewModel.Init();
  58. //设备告警日志
  59. MessageLog.GetInstance.AlarmLogNotify = new Action(() =>
  60. {
  61. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  62. {
  63. IsAlarm.IsCheck = MessageLog.GetInstance.DPAlarmInfo.Count > 0;
  64. IsAlarm.ListNum = MessageLog.GetInstance.DPAlarmInfo.Count;
  65. }));
  66. });
  67. dispatcherTimer = new DispatcherTimer();
  68. dispatcherTimer.Tick += delegate
  69. {
  70. System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
  71. {
  72. NetworkConnectState = UniversalHelper.GetInstance().GetNetworkState();
  73. CurrentOrderCount = Json<KeepDataBase>.Data.orderLists.Count;
  74. }));
  75. };
  76. dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
  77. dispatcherTimer.Start();
  78. }
  79. public int CurrentOrderCount { get { return _mCurrentOrderCount; } set { _mCurrentOrderCount = value; OnPropertyChanged(); } }
  80. private int _mCurrentOrderCount;
  81. public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
  82. public bool IsVerty { get { return Json<KeepDataBase>.Data.IsVerify; } set { Json<KeepDataBase>.Data.IsVerify = value; OnPropertyChanged(); } }
  83. }
  84. public class AlarmModel : NotifyBase
  85. {
  86. /// <summary>
  87. /// 是否告警
  88. /// </summary>
  89. private bool _IsCheck = false;
  90. public bool IsCheck
  91. {
  92. get
  93. {
  94. return _IsCheck;
  95. }
  96. set
  97. {
  98. if (_IsCheck == value)
  99. return;
  100. _IsCheck = value;
  101. OnPropertyChanged("IsCheck");
  102. }
  103. }
  104. /// <summary>
  105. /// 告警数量
  106. /// </summary>
  107. private int _ListNum = 0;
  108. public int ListNum
  109. {
  110. get
  111. {
  112. return _ListNum;
  113. }
  114. set
  115. {
  116. if (_ListNum == value)
  117. return;
  118. _ListNum = value;
  119. OnPropertyChanged("ListNum");
  120. }
  121. }
  122. public AlarmModel()
  123. {
  124. }
  125. }
  126. }