Ejemplo n.º 1
0
        public ConfigurationViewModel(IItemInteractionService manipulationService)
        {
            Messenger.Default.Register <string>(this, (message) =>
            {
                //Debug.WriteLine("CVM msg recieved: " + message);
                switch (message.ToUpper())
                {
                case "STARTCALIBRATION":
                    this.Start();
                    break;

                case "STOPCALIBRATION":
                    this.Stop();
                    break;
                }
            });
            _manipulationService = manipulationService as ObjectDetectionService;

            _manipulationService.IsWindowVisible = true;

            this.SaveCalibration = new RelayCommand(() =>
            {
                if (_manipulationService.IsCalibrating || _manipulationService.ObjectCount == 0)
                {
                    MessageBox.Show("Please complete calibration and ensure that the 'Calibrate' setting is unchecked and at least one Object is Detected before Saving Calibration.");
                }
                else
                {
                    MessageBox.Show(_manipulationService.SaveCalibration());
                }
            });

            this.LoadCalibration = new RelayCommand(() =>
            {
                _manipulationService.LoadCalibration();
            });

            this.CloseCommand = new RelayCommand <Window>(
                (window) =>
            {
                _manipulationService.IsWindowVisible = false;
                _manipulationService.IsCalibrating   = false;
                window.Close();
                var mainWindow = Application.Current.Windows.Cast <Window>().SingleOrDefault(w => w.Name == "MainWindow");
                if (mainWindow != null)
                {
                    mainWindow.Show();
                }
            },
                (window) => window != null
                );

            this.StartService = new RelayCommand(() => { _manipulationService.Start(); });
            this.StopService  = new RelayCommand(() => { _manipulationService.Stop(); });

            this._manipulationService.PropertyChanged += _manipulationService_PropertyChanged;
        }
Ejemplo n.º 2
0
        public ConfigurationViewModel(IItemInteractionService manipulationService)
        {
            Messenger.Default.Register<string>(this, (message) =>
            {
                //Debug.WriteLine("CVM msg recieved: " + message);
                switch (message.ToUpper())
                {
                    case "STARTCALIBRATION":
                        this.Start();
                        break;
                    case "STOPCALIBRATION":
                        this.Stop();
                        break;
                }
            });
            _manipulationService = manipulationService as ObjectDetectionService;

            _manipulationService.IsWindowVisible = true; 

            this.SaveCalibration = new RelayCommand(() =>
            {
                if (_manipulationService.IsCalibrating || _manipulationService.ObjectCount == 0)
                    MessageBox.Show("Please complete calibration and ensure that the 'Calibrate' setting is unchecked and at least one Object is Detected before Saving Calibration.");
                else
                    MessageBox.Show(_manipulationService.SaveCalibration());
            });

            this.LoadCalibration = new RelayCommand(() =>
            {
                _manipulationService.LoadCalibration();
            });

            this.CloseCommand = new RelayCommand<Window>(
                (window) => 
                    {
                        _manipulationService.IsWindowVisible = false;
                        _manipulationService.IsCalibrating = false;
                        window.Close();
                        var mainWindow = Application.Current.Windows.Cast<Window>().SingleOrDefault(w => w.Name == "MainWindow");
                        if (mainWindow != null)
                        {
                            mainWindow.Show();
                        }
                    },
                (window) =>  window != null
                );

            this.StartService = new RelayCommand(() => { _manipulationService.Start(); });
            this.StopService = new RelayCommand(() => { _manipulationService.Stop(); });

            this._manipulationService.PropertyChanged += _manipulationService_PropertyChanged;

        }
Ejemplo n.º 3
0
 public void Stop()
 {
     _manipulationService.Stop();
 }