SelectCameraBrandViewModel.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using MvCamCtrl.NET;
  2. using Prism.Commands;
  3. using Prism.Mvvm;
  4. using Prism.Services.Dialogs;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using TeamAAS_VP.Enums;
  10. using TeamAAS_VP.Models;
  11. using TeamAAS_VP.Resources.Languages;
  12. namespace TeamAAS_VP.ViewModels.Setting
  13. {
  14. public class SelectCameraBrandViewModel : BindableBase, IDialogAware
  15. {
  16. private CameraBrand _CameraBrand;
  17. /// <summary>
  18. /// 相机品牌
  19. /// </summary>
  20. public CameraBrand CameraBrand
  21. {
  22. get { return _CameraBrand; }
  23. set { SetProperty(ref _CameraBrand, value); }
  24. }
  25. private DelegateCommand _ConfirmCommand;
  26. public DelegateCommand ConfirmCommand =>
  27. _ConfirmCommand ?? (_ConfirmCommand = new DelegateCommand(ExecuteConfirmCommand));
  28. void ExecuteConfirmCommand()
  29. {
  30. IDialogParameters parameters = new DialogParameters();
  31. parameters.Add("CameraBrand", CameraBrand);
  32. RequestClose?.Invoke(new DialogResult(ButtonResult.OK, parameters));
  33. }
  34. private DelegateCommand _CancelCommand;
  35. public DelegateCommand CancelCommand =>
  36. _CancelCommand ?? (_CancelCommand = new DelegateCommand(ExecuteCancelCommand));
  37. void ExecuteCancelCommand()
  38. {
  39. IDialogParameters parameters = new DialogParameters();
  40. parameters.Add("CameraBrand", CameraBrand);
  41. RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel, parameters));
  42. }
  43. public SelectCameraBrandViewModel()
  44. {
  45. }
  46. public string Title { get; set; } = "Select Camera Brand";
  47. public event Action<IDialogResult> RequestClose;
  48. public bool CanCloseDialog()
  49. {
  50. return true;
  51. }
  52. public void OnDialogClosed()
  53. {
  54. }
  55. public void OnDialogOpened(IDialogParameters parameters)
  56. {
  57. Title = Lang.添加相机;
  58. if (parameters.TryGetValue<CameraBrand>("CameraBrand",out CameraBrand brand))
  59. {
  60. CameraBrand = brand;
  61. }
  62. else
  63. {
  64. CameraBrand = CameraBrand.HikRobot_MVS;
  65. }
  66. }
  67. }
  68. }