示例#1
0
 private void DoToggleBundleAdjust(bool enable)
 {
     if (enable)
     {
         MultipleViewsService.StartBundleAdjustTask();
     }
     else
     {
         MultipleViewsService.CancelBundleTask();
     }
     _camerasModel.BundleAdjusting = enable;
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the AllCamerasViewModel class.
        /// </summary>
        public CamerasViewModel()
        {
            CamerasModel.Name = "all";
            CamerasModel.Cameras = new ObservableCollection<CameraModel>();
            CamerasModel.Controllers = new ObservableCollection<MotionControllerModel>();
            Refresh();
            MultipleViewsService = new MultipleViewsService();
            MultipleViewsService.Initialize(_camerasModel, CameraViewModels.Select(camera => camera.TrackerService).ToList());

            Messenger.Default.Register<AddCameraMessage>(this, message =>
            {
                CameraViewModel cvm = SimpleIoc.Default.GetInstance<CameraViewModel>(message.Camera.GUID);
                CameraViewModels.Add(cvm);
                CamerasModel.Cameras.Add(cvm.Camera);
                MultipleViewsService.TrackerServices.Add(cvm.TrackerService);
            });

            Messenger.Default.Register<RemoveCameraMessage>(this, message =>
            {
                if(SimpleIoc.Default.ContainsCreated<CameraViewModel>(message.Camera.GUID))
                {
                    CameraViewModel cvm = SimpleIoc.Default.GetInstance<CameraViewModel>(message.Camera.GUID);
                    CameraViewModels.Remove(cvm);
                    CamerasModel.Cameras.Remove(cvm.Camera);
                    MultipleViewsService.TrackerServices.Remove(cvm.TrackerService);
                }
            });

            Messenger.Default.Register<AddMotionControllerMessage>(this,
            message =>
            {
                CamerasModel.Controllers.Add(message.MotionController);
            });

            Messenger.Default.Register<RemoveMotionControllerMessage>(this,
            message =>
            {
                CamerasModel.Controllers.Remove(message.MotionController);
            });

            if(IsInDesignMode)
            {
                CamerasModel.Cameras.Add(new CameraViewModel().Camera);
                CamerasModel.Cameras.Add(new CameraViewModel().Camera);
                CamerasModel.Cameras.Add(new CameraViewModel().Camera);
                CamerasModel.Cameras.Add(new CameraViewModel().Camera);
                CamerasModel.Controllers.Add(new MotionControllerModel());
                CamerasModel.Controllers.Add(new MotionControllerModel());
            }
            else
            {
                if (SimpleIoc.Default.GetInstance<SettingsViewModel>().Settings.LoadCamerasOnStartup)
                {
                    AddAvailableCameras();
                }
                if(SimpleIoc.Default.GetInstance<SettingsViewModel>().Settings.Debug)
                {
                    new CameraViewModel();
                    new CameraViewModel();
                    new CameraViewModel();
                    new CameraViewModel();
                }
            }
        }