|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using BPASmartClient.Business;
- using BPA.Helper;
-
- using BPASmartClient.Model;
- using BPA.Helper;
-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Threading;
-
- namespace BPASmartClient.ViewModel
- {
- /// <summary>
- /// 主界面
- /// </summary>
- public class MainViewModel : NotifyBase
- {
- /// <summary>
- /// 网络连接状态
- /// </summary>
- private bool _NetworkConnectState = true;
- public bool NetworkConnectState
- {
- get
- {
- return _NetworkConnectState;
- }
- set
- {
- if (_NetworkConnectState == value)
- return;
- _NetworkConnectState = value;
- OnPropertyChanged("NetworkConnectState");
- }
- }
- /// <summary>
- /// 是否告警
- /// </summary>
- public AlarmModel IsAlarm { get; set; }
- public System.Windows.Window window;
- public DispatcherTimer dispatcherTimer;
- #region 单一
- private volatile static MainViewModel _Instance;
- public static MainViewModel GetInstance => _Instance ?? (_Instance = new MainViewModel());
-
- #endregion
-
- public MainViewModel()
- {
- IsAlarm = new AlarmModel();
- OrderStatusViewModel.Init();
- //设备告警日志
- //MessageLog.GetInstance.AlarmLogNotify = new Action(() =>
- //{
- // System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
- // {
- // IsAlarm.IsCheck = MessageLog.GetInstance.DPAlarmInfo.Count > 0;
- // IsAlarm.ListNum = MessageLog.GetInstance.DPAlarmInfo.Count;
- // }));
- //});
-
-
- dispatcherTimer = new DispatcherTimer();
- dispatcherTimer.Tick += delegate
- {
- System.Windows.Application.Current?.Dispatcher.Invoke((Action)(() =>
- {
- NetworkConnectState = UniversalHelper.GetInstance.GetNetworkState();
- CurrentOrderCount = Json<KeepDataBase>.Data.orderLists.Count;
- }));
- };
- dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
- dispatcherTimer.Start();
-
- }
-
-
- public int CurrentOrderCount { get { return _mCurrentOrderCount; } set { _mCurrentOrderCount = value; OnPropertyChanged(); } }
- private int _mCurrentOrderCount;
-
- public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
-
- public bool IsVerty { get { return Json<KeepDataBase>.Data.IsVerify; } set { Json<KeepDataBase>.Data.IsVerify = value; OnPropertyChanged(); } }
-
- }
-
- public class AlarmModel : NotifyBase
- {
- /// <summary>
- /// 是否告警
- /// </summary>
- private bool _IsCheck = false;
- public bool IsCheck
- {
- get
- {
- return _IsCheck;
- }
- set
- {
- if (_IsCheck == value)
- return;
- _IsCheck = value;
- OnPropertyChanged("IsCheck");
- }
- }
- /// <summary>
- /// 告警数量
- /// </summary>
- private int _ListNum = 0;
- public int ListNum
- {
- get
- {
- return _ListNum;
- }
- set
- {
- if (_ListNum == value)
- return;
- _ListNum = value;
- OnPropertyChanged("ListNum");
- }
- }
-
- public AlarmModel()
- {
-
- }
- }
- }
|