| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TeamAAS_VP.Core;
- using TeamAAS_VP.Models;
- namespace TeamAAS_VP.ViewModels.Home
- {
- public class SetAlarmValueViewModel : BindableBase, IDialogAware
- {
- #region 属性
- private int _BitAlarmValue;
- public int BitAlarmValue
- {
- get { return _BitAlarmValue; }
- set { SetProperty(ref _BitAlarmValue, value); }
- }
- private int _NozzleAlarmValue;
- public int NozzleAlarmValue
- {
- get { return _NozzleAlarmValue; }
- set { SetProperty(ref _NozzleAlarmValue, value); }
- }
- private NumberStatistics _NumStatistics = new NumberStatistics();
- /// <summary>
- /// 数量(批头、吸嘴、供料器)
- /// </summary>
- public NumberStatistics NumStatistics
- {
- get { return _NumStatistics; }
- set { SetProperty(ref _NumStatistics, value); }
- }
- #endregion
- #region 命令
- private DelegateCommand _ConfirmCommand;
- public DelegateCommand ConfirmCommand =>
- _ConfirmCommand ?? (_ConfirmCommand = new DelegateCommand(ExecuteConfirmCommand));
- private DelegateCommand _CancelCommand;
- public DelegateCommand CancelCommand =>
- _CancelCommand ?? (_CancelCommand = new DelegateCommand(ExecuteCancelCommand));
- #endregion
- void ExecuteCancelCommand()
- {
- IDialogParameters parameters = new DialogParameters();
- RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel, parameters));
- }
- void ExecuteConfirmCommand()
- {
- NumStatistics.NozzleAlarmValue = NozzleAlarmValue;
- NumStatistics.HeaderAlarmValue = BitAlarmValue;
- FileHelper.WriteJsonFile(NumStatistics, FilePath.NumberStatisticsPath);
- IDialogParameters parameters = new DialogParameters();
- RequestClose?.Invoke(new DialogResult(ButtonResult.OK, parameters));
- }
- public string Title => "Set Bit/Nozzle Alarm Value";
- public event Action<IDialogResult> RequestClose;
- public bool CanCloseDialog()
- {
- return true;
- }
- public void OnDialogClosed()
- {
-
- }
- public void OnDialogOpened(IDialogParameters parameters)
- {
- try
- {
- var res = FileHelper.ReadJsonFile<NumberStatistics>(FilePath.NumberStatisticsPath);
- if (res != null)
- {
- BitAlarmValue = res.HeaderAlarmValue;
- NozzleAlarmValue = res.NozzleAlarmValue;
- }
- }
- catch (Exception)
- {
- }
- }
- }
- }
|