WaveShowBoxViewModel.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Linq;
  2. using Prism.Mvvm;
  3. using Prism.Events;
  4. using Prism.Commands;
  5. using SHJX.Service.Model.Dao;
  6. using SHJX.Service.Common.Event;
  7. using SHJX.Service.Control.Interface;
  8. using System.Collections.ObjectModel;
  9. namespace SHJX.Service.Library.ViewModels
  10. {
  11. public class WaveShowBoxViewModel : BindableBase
  12. {
  13. #region Fields
  14. private readonly IEventAggregator _ea;
  15. private readonly IMainService _service;
  16. #endregion
  17. #region Properties
  18. private string _waveKeyItem;
  19. public string WaveKeyItem
  20. {
  21. get => _waveKeyItem;
  22. set => SetProperty(ref _waveKeyItem, value);
  23. }
  24. private bool? _dialogResult;
  25. public bool? DialogResult
  26. {
  27. get { return _dialogResult; }
  28. set => SetProperty(ref _dialogResult, value);
  29. }
  30. public ObservableCollection<string> Wavekeys { get; set; }
  31. #endregion
  32. public WaveShowBoxViewModel(IEventAggregator ea, IMainService service)
  33. {
  34. _ea = ea;
  35. _service = service;
  36. Wavekeys = new ObservableCollection<string>((from wavekey in _service.GetData<Wavekey>().ToList() orderby wavekey.WaveKey descending select wavekey.WaveKey).ToList());
  37. }
  38. #region Commands
  39. private DelegateCommand _waveKeyCommand;
  40. public DelegateCommand WaveKeyCommand => _waveKeyCommand ?? new DelegateCommand(ExecuteWaveKeyCommand);
  41. #endregion
  42. #region Execute
  43. private void ExecuteWaveKeyCommand()
  44. {
  45. _ea.GetEvent<TransmitWavekeyEvent>().Publish(WaveKeyItem);
  46. DialogResult = true;
  47. }
  48. #endregion
  49. }
  50. }