终端一体化运控平台
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

125 行
3.3 KiB

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