using System;
using CustomUI;
using Prism.Mvvm;
using System.Linq;
using Prism.Commands;
using System.Windows;
using System.Globalization;
using SHJX.Service.Model.Dao;
using System.Windows.Controls;
using SHJX.Service.Common.Utils;
using SHJX.Service.Model.Control;
using System.Collections.Generic;
using SHJX.Service.Common.ReadXML;
using System.Collections.ObjectModel;
using SHJX.Service.Common.UserDelegate;
using SHJX.Service.Common.ExtendElement;
using SHJX.Service.Control.ServiceController;
using SHJX.Service.Common.Logging;
using Microsoft.Extensions.Logging;
namespace SHJX.Service.ModelView
{
public class ManualViewModel : BindableBase
{
private static readonly ILogger logger = LogFactory.BuildLogger(typeof(ManualViewModel));
private readonly ManualController _controller;
public ManualViewModel(ReadConfigUtil config)
{
_controller = new ManualController(config);
RegisterMessage();
InitData();
}
///
/// 注册消息
///
private void RegisterMessage()
{
Messager.Register("ChangeTemperature", SetTemperature);
}
#region DataBind
private int _manualBarProcess;
public int ManualBarProcess
{
get => _manualBarProcess;
set
{
_manualBarProcess = value;
RaisePropertyChanged(nameof(ManualBarProcess));
}
}
private string _settingTemperatures;
public string SettingTemperature
{
get => _settingTemperatures;
set
{
_settingTemperatures = value;
RaisePropertyChanged(nameof(SettingTemperature));
}
}
private string _temperatureText;
public string CurrentTemperature
{
get => _temperatureText;
set
{
_temperatureText = value;
RaisePropertyChanged(nameof(CurrentTemperature));
}
}
public ObservableCollection Areas { get; set; }
public List AreaPoint { get; set; }
public EquipmentArea Area
{
get => Areas.FirstOrDefault(item => item.PointName.Equals(AreaCurrentPoint.Content));
set
{
Areas.Where(item => item.PointName.Equals(AreaCurrentPoint.Content)).ToArray()[0] = value;
RaisePropertyChanged(nameof(Area));
}
}
private ComboBoxItem _areaCurrentPoint;
public ComboBoxItem AreaCurrentPoint
{
get => _areaCurrentPoint;
set
{
_areaCurrentPoint = value;
RaisePropertyChanged(nameof(AreaCurrentPoint));
}
}
private bool _potassiumDichromateHighOutValue;
public bool PotassiumDichromateHighOutValue
{
get => _potassiumDichromateHighOutValue;
set
{
_potassiumDichromateHighOutValue = value;
RaisePropertyChanged(nameof(PotassiumDichromateHighOutValue));
}
}
private bool _potassiumDichromateHighInValue;
public bool PotassiumDichromateHighInValue
{
get => _potassiumDichromateHighInValue;
set
{
_potassiumDichromateHighInValue = value;
RaisePropertyChanged(nameof(PotassiumDichromateHighInValue));
}
}
private bool _potassiumDichromateLowOutValue;
public bool PotassiumDichromateLowOutValue
{
get => _potassiumDichromateLowOutValue;
set
{
_potassiumDichromateLowOutValue = value;
RaisePropertyChanged(nameof(PotassiumDichromateLowOutValue));
}
}
private bool _potassiumDichromateLowInValue;
public bool PotassiumDichromateLowInValue
{
get => _potassiumDichromateLowInValue;
set
{
_potassiumDichromateLowInValue = value;
RaisePropertyChanged(nameof(PotassiumDichromateLowInValue));
}
}
private void InitData()
{
PotassiumDichromateHighOutValue = false;
PotassiumDichromateHighInValue = false;
PotassiumDichromateLowOutValue = false;
PotassiumDichromateLowInValue = false;
ManualBarProcess = 0;
AreaPoint = new List();
Areas = new ObservableCollection(_controller.GetAreaInfo());
(from EquipmentArea item in Areas select item.PointName).ToList().ForEach(item =>
{
AreaPoint.Add(
new ComboBoxItem()
{
Foreground = "#99CCCC".ConvertToBrush(),
Content = item
}
);
});
AreaCurrentPoint = AreaPoint.FirstOrDefault();
}
#endregion
#region Command
private DelegateCommand