|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using BPASmartClient.Business;
- using BPASmartClient.Helper;
- using BPASmartClient.Message;
- using Microsoft.Toolkit.Mvvm.ComponentModel;
- using Microsoft.Toolkit.Mvvm.Input;
- 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 : ObservableObject
- {
- /// <summary>
- /// 网络连接状态
- /// </summary>
- private bool _NetworkConnectState = true;
- public bool NetworkConnectState
- {
- get
- {
- return _NetworkConnectState;
- }
- set
- {
- if (_NetworkConnectState == value)
- return;
- _NetworkConnectState = value;
- OnPropertyChanged("NetworkConnectState");
- }
- }
- //状态隐藏
- public Visibility VsMenuItem { get { return _vsMenuItem; } set { _vsMenuItem = value; OnPropertyChanged(); } }
- private Visibility _vsMenuItem;
-
- public RelayCommand LogoutCommand { get; set; }
-
- /// <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();
- }));
- };
- dispatcherTimer.Interval = TimeSpan.FromSeconds(1);
- dispatcherTimer.Start();
- ActionManage.GetInstance.Register(new Action(() =>
- {
- VsMenuItem = Visibility.Hidden;
- }),"Lonin");
- LogoutCommand = new RelayCommand(() =>
- {
- VsMenuItem = Visibility.Visible;
- });
-
-
- }
-
-
- public bool AutoStart { get { return SystemHelper.GetInstance.IsAutoStart(); } set { SystemHelper.GetInstance.AutoStart(value); OnPropertyChanged(); } }
-
-
-
- }
-
- public class AlarmModel : ObservableObject
- {
- /// <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()
- {
-
- }
- }
- }
|