ImagePreviewWindowViewModel.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. using Cognex.VisionPro;
  2. using Cognex.VisionPro.MultiLineFinder.Implementation.Internal;
  3. using Prism.Commands;
  4. using Prism.Events;
  5. using Prism.Ioc;
  6. using Prism.Mvvm;
  7. using Prism.Regions;
  8. using Prism.Services.Dialogs;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using TeamAAS_VP.Core;
  15. using TeamAAS_VP.Models;
  16. using TeamAAS_VP.Models.Calibration;
  17. using TeamAAS_VP.Resources.Languages;
  18. using TeamAAS_VP.ViewModels.Calibration;
  19. namespace TeamAAS_VP.ViewModels.Home
  20. {
  21. public class ImagePreviewWindowViewModel : BindableBase, IDialogAware
  22. {
  23. #region 字段
  24. IRegionManager _regionManager;
  25. public IEventAggregator _eventAggregator;
  26. IContainerProvider _container;
  27. IDialogService _dialogService;
  28. #endregion
  29. #region 属性
  30. private Management _management;
  31. public Management management
  32. {
  33. get { return _management; }
  34. set { SetProperty(ref _management, value); }
  35. }
  36. #endregion
  37. #region 命令
  38. public Prism.Commands.DelegateCommand LoadedCommand { get; set; }
  39. #endregion
  40. public ImagePreviewWindowViewModel(IRegionManager regionManager, IEventAggregator ea, IContainerProvider container, IDialogService dialogService)
  41. {
  42. _regionManager = regionManager;
  43. _eventAggregator = ea;
  44. _container = container;
  45. _dialogService = dialogService;
  46. management = _container.Resolve<Management>();
  47. LoadedCommand = new Prism.Commands.DelegateCommand(OnLoad);
  48. }
  49. private CogRecordDisplay _CogDisp;
  50. public CogRecordDisplay CogDisp
  51. {
  52. get { return _CogDisp; }
  53. set { SetProperty(ref _CogDisp, value); }
  54. }
  55. private Cognex.VisionPro.ICogImage _Image;
  56. public Cognex.VisionPro.ICogImage Image
  57. {
  58. get { return _Image; }
  59. set { SetProperty(ref _Image, value); }
  60. }
  61. private Cognex.VisionPro.CogGraphicCollection _Graphic;
  62. public Cognex.VisionPro.CogGraphicCollection Graphic
  63. {
  64. get { return _Graphic; }
  65. set { SetProperty(ref _Graphic, value); }
  66. }
  67. private Cognex.VisionPro.ICogRecord _Record;
  68. public Cognex.VisionPro.ICogRecord Record
  69. {
  70. get { return _Record; }
  71. set { SetProperty(ref _Record, value); }
  72. }
  73. public string Title { get; set; }
  74. public event Action<IDialogResult> RequestClose;
  75. private void OnLoad()
  76. {
  77. Image = CogDisp.Image;
  78. Record = CogDisp.Record;
  79. }
  80. public bool CanCloseDialog()
  81. {
  82. return true;
  83. }
  84. public void OnDialogClosed()
  85. {
  86. }
  87. public void OnDialogOpened(IDialogParameters parameters)
  88. {
  89. CogDisp = parameters.GetValue<CogRecordDisplay>("Cog");
  90. }
  91. }
  92. }