| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- using System;
- using Prism.Events;
- using Prism.Mvvm;
- using System.Windows.Media;
- using SHJX.Service.Common.Event;
- namespace SHJX.Service.Main.ViewModels
- {
- public class MainFormBottomViewModel : BindableBase
- {
- #region Peoperties
- private SolidColorBrush _lockDesktopDisplay;
- public SolidColorBrush LockDesktopDisplay
- {
- get => _lockDesktopDisplay;
- set => SetProperty(ref _lockDesktopDisplay, value);
- }
- private bool _lockDesktopState;
- public bool LockDesktopState
- {
- get => _lockDesktopState;
- set => SetProperty(ref _lockDesktopState, value);
- }
- private SolidColorBrush _heatingDisplay;
- public SolidColorBrush HeatingDisplay
- {
- get => _heatingDisplay;
- set => SetProperty(ref _heatingDisplay, value);
- }
- private bool _heatingState;
- public bool HeatingState
- {
- get => _heatingState;
- set => SetProperty(ref _heatingState, value);
- }
- private SolidColorBrush _portClientDisplay;
- public SolidColorBrush PortClientDisplay
- {
- get => _portClientDisplay;
- set => SetProperty(ref _portClientDisplay, value);
- }
- private bool _portClientState;
- public bool PortClientState
- {
- get => _portClientState;
- set => SetProperty(ref _portClientState, value);
- }
- private SolidColorBrush _cameraClientDisplay;
- public SolidColorBrush CameraClientDisplay
- {
- get => _cameraClientDisplay;
- set => SetProperty(ref _cameraClientDisplay, value);
- }
- private bool _cameraClientState;
- public bool CameraClientState
- {
- get => _cameraClientState;
- set => SetProperty(ref _cameraClientState, value);
- }
- private SolidColorBrush _cameraClientDisplay2;
- public SolidColorBrush CameraClientDisplay2
- {
- get => _cameraClientDisplay2;
- set => SetProperty(ref _cameraClientDisplay2, value);
- }
- private bool _cameraClientState2;
- public bool CameraClientState2
- {
- get => _cameraClientState2;
- set => SetProperty(ref _cameraClientState2, value);
- }
- private double _temperatureValue;
- public double TemperatureValue
- {
- get => _temperatureValue;
- set => SetProperty(ref _temperatureValue, value);
- }
- private double _kValue;
- public double KValue
- {
- get => _kValue;
- set => SetProperty(ref _kValue, value);
- }
- private double _tempeValue;
- public double TempValue
- {
- get => _tempeValue;
- set => SetProperty(ref _tempeValue, value);
- }
- private double _humidValue;
- public double HumidValue
- {
- get => _humidValue;
- set => SetProperty(ref _humidValue, value);
- }
- private double _taskNeedTime;
- public double TaskNeedTime
- {
- get => _taskNeedTime;
- set => SetProperty(ref _taskNeedTime, value);
- }
- #endregion
- public MainFormBottomViewModel(IEventAggregator ea)
- {
- TempValue = 18.3;
- HumidValue = 22.6;
- LockDesktopDisplay = Brushes.LightGreen;
- LockDesktopState = false;
- HeatingDisplay = Brushes.Red;
- HeatingState = true;
- PortClientDisplay = Brushes.Red;
- PortClientState = true;
- CameraClientDisplay = Brushes.Red;
- CameraClientState = true;
- CameraClientDisplay2 = Brushes.Red;
- CameraClientState2 = true;
- TaskNeedTime = 0;
- ea.GetEvent<LockDesktopEvent>().Subscribe((bl) =>
- {
- LockDesktopDisplay = bl ? Brushes.Red : Brushes.LightGreen;
- LockDesktopState = bl;
- });
- ea.GetEvent<HeatingStateEvent>().Subscribe((bl) =>
- {
- HeatingDisplay = bl ? Brushes.LightGreen : Brushes.Red;
- HeatingState = !bl;
- });
- ea.GetEvent<ClientCameraEvent>().Subscribe(SettingCameraState);
- ea.GetEvent<ClientCameraEvent2>().Subscribe(SettingCameraState2);
- ea.GetEvent<ClientResponseEvent>().Subscribe(SettingPortState);
- ea.GetEvent<DissolveCurrentHeatingValueEvent>().Subscribe(args =>
- {
- TemperatureValue = args.CurrentTemperature;
- });
- ea.GetEvent<NoticeKValueEvent>().Subscribe(value =>
- {
- KValue = Math.Round(value, 4);
- });
- ea.GetEvent<NoticeHumitureEvent>().Subscribe(args =>
- {
- TempValue = args.Temperature;
- HumidValue = args.Humidity;
- });
- ea.GetEvent<CalExecuteTaskNeedTimeEvent>().Subscribe(canExecuteTaskCount =>
- {
- if (canExecuteTaskCount == 0)
- {
- TaskNeedTime = 0;
- }
- if (canExecuteTaskCount > 0)
- {
- TaskNeedTime = (30 + 6 * canExecuteTaskCount) / 60.0;
- }
- });
- }
- private void SettingCameraState(bool state)
- {
- CameraClientDisplay = state ? Brushes.LightGreen : Brushes.Red;
- CameraClientState = !state;
- }
- private void SettingCameraState2(bool state)
- {
- CameraClientDisplay2 = state ? Brushes.LightGreen : Brushes.Red;
- CameraClientState2 = !state;
- }
- private void SettingPortState((string portName, bool clientState) obj)
- {
- PortClientState = !obj.clientState;
- PortClientDisplay = obj.clientState ? Brushes.LightGreen : Brushes.Red;
- }
- }
- }
|