| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using Prism.Mvvm;
- using System.Linq;
- using SHJX.Service.Control.Interface;
- using SHJX.Service.Model.Dao;
- using System.Collections.ObjectModel;
- using Prism.Commands;
- using SHJX.Service.Control.Extends;
- using Prism.Events;
- using SHJX.Service.Common.Event;
- using SHJX.Service.Model.EventArgs;
- using SHJX.Service.Common.Constants;
- namespace SHJX.Service.Shell.ViewModels.Manual
- {
- public class OtherManualWindowViewModel : BindableBase
- {
- #region Fields
- private readonly IManualService _service;
- private readonly IEventAggregator _ea;
- #endregion
- #region Perproties
- private string _waveKeyItem;
- public string WaveKeyItem
- {
- get => _waveKeyItem;
- set => SetProperty(ref _waveKeyItem, value);
- }
- private double _currentKValue;
- public double CurrentKValue
- {
- get => _currentKValue;
- set => SetProperty(ref _currentKValue, value);
- }
- public ObservableCollection<string> Wavekeys { get; set; }
- #endregion
- public OtherManualWindowViewModel(IManualService service, IEventAggregator ea)
- {
- _ea = ea;
- _service = service;
- Wavekeys = new ObservableCollection<string>((from wavekey in _service.GetData<Wavekey>().ToList() orderby wavekey.WaveKey descending select wavekey.WaveKey).ToList());
- }
- #region Command
- private DelegateCommand _loadedCommand;
- public DelegateCommand LoadedCommand => _loadedCommand ??= new DelegateCommand(ExecuteLoadedCommand);
- private DelegateCommand _selectionChangedCommand;
- public DelegateCommand SelectionChangedCommand => _selectionChangedCommand ??= new DelegateCommand(ExecuteSelectionChangedCommand);
- private DelegateCommand _adjustCommand;
- public DelegateCommand AdjustCommand => _adjustCommand ??= new DelegateCommand(ExecuteAdjustCommand);
- #endregion
- #region Execute
- private void ExecuteLoadedCommand()
- {
- ChangeCurrentKValue();
- }
- private void ExecuteSelectionChangedCommand()
- {
- ChangeCurrentKValue();
- }
- private void ChangeCurrentKValue()
- {
- CurrentKValue = CalculationResult.CalculateType(WaveKeyItem, TaskTypeName.CALIBRATION_ZH, (arg) => 10 / arg);
- }
- private void ExecuteAdjustCommand()
- {
- AdjustResultArgs args = new()
- {
- Key = WaveKeyItem,
- Value = CurrentKValue
- };
- _ea.GetEvent<AdjustResultEvent>().Publish(args);
- }
- #endregion
- }
- }
|