Esempio n. 1
0
        /// <summary>
        /// Make sure the selected value is different from value stored
        /// in this class before changing.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbCameras_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox combo = (ComboBox)sender;

            if (_webCam.GetCamera() != (Camera)combo.SelectedItem)
            {
                _mainForm._settings.SelectedCameraDisplayName = ((Camera)combo.SelectedItem).Name;

                // We have camera object and it is different than the current setting.
                //	Stop current streaming (if any) and set new camera.
                _webCam.Stop();
                _selectedCamera = (Camera)combo.SelectedItem;
                _webCam.SetCamera(_selectedCamera);
                _webCam.FlipImageHorizontally(_mainForm._settings.FlipImageHorizontally);

                // Set dirty flag.
                btnSaveSettings.Enabled = true;
            }
        }
Esempio n. 2
0
        private void TakePicture_Load(object sender, EventArgs e)
        {
            // Make sure there is a persisted camera.
            if (String.IsNullOrEmpty(_mainForm._settings.SelectedCameraDisplayName))
            {
                MessageBox.Show("Error: No camera name has been saved.  "
                                + "Select one with the command line '/config' option.",
                                "No camera name saved");
                return;
            }

            // Select the persisted camera from the available ones.
            bool foundCamera = false;

            foreach (Camera cam in _webCam.GetCameras())
            {
                if (cam.Name == _mainForm._settings.SelectedCameraDisplayName)
                {
                    _webCam.SetCamera(cam);
                    foundCamera = true;
                    break;
                }
            }

            // Return error if couldn't find one.
            if (!foundCamera)
            {
                MessageBox.Show("Could not find camera: " + _mainForm._settings.SelectedCameraDisplayName,
                                "Camera not found");
                return;
            }

            _webCam.Stop();

            // Enable GUI events now that all is set up.


            _webCam.Start();
            _webCam.FlipImageHorizontally(_mainForm._settings.FlipImageHorizontally);
        }