Example #1
0
        private static AppViewModel CreateViewModel()
        {
            SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());

            var sensor   = CreateAndOpenSensor();
            var engine   = new ScanningEngine(sensor, () => new ReconstructionController(sensor));
            var renderer = new KinectFrameRenderer(sensor, new DepthToColorConverter());
            var uis      = new UserInteractionService();

            return(new AppViewModel(engine, renderer, uis));
        }
        /// <summary>
        /// Checks all requirements for scan to start, checks the conditions to finish the scan. Updates the scan.
        /// </summary>
        /// <param name="engine">Engine that holds the scan data.</param>
        /// <param name="renderer">The main frame renderer.</param>
        /// <param name="uis">User Interaction service</param>
        public AppViewModel(ScanningEngine engine, KinectFrameRenderer renderer, UserInteractionService uis)
        {
            Contract.Requires(engine != null);
            Contract.Requires(renderer != null);

            this.engine   = engine;
            this.renderer = renderer;
            this.uis      = uis;

            // Delegate Command checks for a bool and execute an action. CanStartScanning is the bool and DoScanning is the action.
            startScanningCommand = new DelegateCommand(DoScanning, CanStartScanning);
            saveModelCommand     = new DelegateCommand(SaveBodyModel, () => engine.ScannedMesh != null);

            engine.ScanStarted += Engine_ScanStarted;
            engine.ScanUpdated += Engine_ScanUpdated;
        }
Example #3
0
        public AppViewModel(ScanningEngine engine, KinectFrameRenderer renderer, UserInteractionService uis)
        {
            Contract.Requires(engine != null);
            Contract.Requires(renderer != null);

            this.engine   = engine;
            this.renderer = renderer;
            this.uis      = uis;

            startScanningCommand = new DelegateCommand(DoScanning, CanStartScanning);

            Prompt          = Properties.Resources.PromptEnterName;
            ShowDepthBitmap = true;

            renderer.BitmapUpdated += Renderer_BitmapUpdated;
            engine.ScanStarted     += Engine_ScanStarted;
            engine.ScanUpdated     += Engine_ScanUpdated;
        }
        /// <summary>
        /// Creates a new view model.
        /// </summary>
        /// <returns>A new AppViewModel</returns>
        private static AppViewModel CreateViewModel()
        {
            SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());

            // Checks for the sensor then opens it.
            var sensor = CreateAndOpenSensor();

            // Creates a new ScanningEngine with the sensor that is created above.
            var engine = new ScanningEngine(sensor, () => new ReconstructionController(sensor));

            // Creates a new KinectFrameRenderer with the sensor that is created above.
            var renderer = new KinectFrameRenderer(sensor, new DepthToColorConverter());

            // Creates a new UserInteractionService object.
            var uis = new UserInteractionService();

            // A new AppViewModel
            return(new AppViewModel(engine, renderer, uis));
        }