using System; using System.Collections.Generic; using System.Linq; using System.Text; using Prism.Mvvm; using System.Threading.Tasks; using Prism.Commands; using Prism.Events; using Prism.Ioc; using Prism.Regions; using System.Windows.Controls; using LampInspectionMachine.Core; using OpenCvSharp.Flann; using System.Windows.Forms; namespace LampInspectionMachine.ViewModels { public class MenuViewModel:BindableBase, IConfirmNavigationRequest { private IContainerProvider _container; private IEventAggregator _eventAggregator; private IRegionManager _regionManager; private Management management; private DelegateCommand _OpenCameraViewCommand; public DelegateCommand OpenCameraViewCommand => _OpenCameraViewCommand ?? ( _OpenCameraViewCommand = new DelegateCommand(CameraViewShow) ); private DelegateCommand _OpenVisionProViewCommand; public DelegateCommand OpenVisionProViewCommand => _OpenVisionProViewCommand ?? ( _OpenVisionProViewCommand = new DelegateCommand(VisionProViewShow) ); public DelegateCommand LoadedCommand { get; set; } public Management Management { get => management; set { SetProperty(ref management, value); } } private bool IsLoad=false; public MenuViewModel(IContainerProvider container, IRegionManager regionManager, IEventAggregator eventAggregator) { _container = container; _eventAggregator = eventAggregator; _regionManager = regionManager; Management=container.Resolve(); LoadedCommand = new DelegateCommand(OnLoad); } private async void OnLoad() { NavigationParameters paras = new NavigationParameters(); paras.Add("Index",0); //键值对 _regionManager.Regions[ "MenuRegionContent" ].RequestNavigate("CameraView", paras); IsLoad = true; } void CameraViewShow(string index) { NavigationParameters paras = new NavigationParameters(); paras.Add("Index", Convert.ToInt32(index)); //键值对 _regionManager.Regions[ "MenuRegionContent" ].RequestNavigate("CameraView", paras); } void VisionProViewShow(string index) { NavigationParameters paras = new NavigationParameters(); paras.Add("Index", Convert.ToInt32(index)); //键值对 _regionManager.Regions[ "MenuRegionContent" ].RequestNavigate("VisionProView", paras); } public void ConfirmNavigationRequest(NavigationContext navigationContext, Action continuationCallback) { continuationCallback(IsLoad); } public void OnNavigatedTo(NavigationContext navigationContext) { } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } } }