Exemple #1
0
        private void InitializeCamera()
        {
            System.Windows.Input.Cursor originalCursor = this.Cursor;
            try
            {
                this.Cursor       = Cursors.Wait;
                this.initializing = true;
                CommandManager.InvalidateRequerySuggested();
                this.CloseCamera();

                this.camera = new PhotoBoothCamera();
                if (this.camera.Initialize())
                {
                    this.cameraSettingsGrid.DataContext = this.camera.Camera;
                }
                else
                {
                    MessageBox.Show(this.camera.InitializationLog);
                    this.CloseCamera();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Caught an exception during camera initialization: " + ex.Message);
            }
            finally
            {
                this.initializing = false;
                CommandManager.InvalidateRequerySuggested();
                this.Cursor = originalCursor;
            }
        }
Exemple #2
0
 private void CloseCamera()
 {
     if (this.camera != null)
     {
         this.camera.Dispose();
         this.camera = null;
     }
 }
        private static void EventThreadProc(object stateInfo)
        {
            PhotoBoothCamera camera = stateInfo as PhotoBoothCamera;

            if (camera.CaptureComplete != null)
            {
                camera.CaptureComplete(camera, EventArgs.Empty);
            }
        }
        private static void PictureThreadProc(object stateInfo)
        {
            PhotoBoothCamera camera = stateInfo as PhotoBoothCamera;

            if (camera != null)
            {
                camera.TakePictureSet();
            }
        }
        private void camera_CaptureComplete(object sender, EventArgs e)
        {
            PhotoBoothCamera camera = sender as PhotoBoothCamera;

            if (camera != null)
            {
                if (this.Dispatcher.CheckAccess())
                {
                    // The calling thread owns the dispatcher, and hence the UI element
                    this.UpdateImageDisplay();
                }
                else
                {
                    // Invokation required
                    this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(this.UpdateImageDisplay));
                }
            }
        }
        private void camera_CameraDisconnected(object sender, EventArgs e)
        {
            PhotoBoothCamera eCamera = sender as PhotoBoothCamera;

            if (eCamera != null)
            {
                this.ClosedAbnormally = true;
                if (this.Dispatcher.CheckAccess())
                {
                    // The calling thread owns the dispatcher, and hence the UI element
                    this.Close();
                }
                else
                {
                    // Invokation required
                    this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(this.Close));
                }
            }
        }
 private void Capture()
 {
     try
     {
         PhotoBoothCamera.WaitForReady(ServiceProvider.DeviceManager.SelectedCameraDevice);
         this.imageCaptured = false;
         //if (this.NoAutofocus && ServiceProvider.DeviceManager.SelectedCameraDevice.GetCapability(CapabilityEnum.CaptureNoAf))
         if (this.NoAutoFocus)
         {
             ServiceProvider.DeviceManager.SelectedCameraDevice.CapturePhotoNoAf();
         }
         else
         {
             ServiceProvider.DeviceManager.SelectedCameraDevice.CapturePhoto();
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("Capture exception: {0}", ex);
     }
 }
 protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
 {
     base.OnClosing(e);
     this.Camera = null;
 }
 protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
 {
     base.OnClosing(e);
     this.Camera = null;
 }
 private void CloseCamera()
 {
     if (this.camera != null)
     {
         this.camera.Dispose();
         this.camera = null;
     }
 }
        private void InitializeCamera()
        {
            System.Windows.Input.Cursor originalCursor = this.Cursor;
            try
            {
                this.Cursor = Cursors.Wait;
                this.initializing = true;
                CommandManager.InvalidateRequerySuggested();
                this.CloseCamera();

                this.camera = new PhotoBoothCamera();
                if (this.camera.Initialize())
                {
                    this.cameraSettingsGrid.DataContext = this.camera.Camera;
                }
                else
                {
                    MessageBox.Show(this.camera.InitializationLog);
                    this.CloseCamera();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Caught an exception during camera initialization: " + ex.Message);
            }
            finally
            {
                this.initializing = false;
                CommandManager.InvalidateRequerySuggested();
                this.Cursor = originalCursor;
            }
        }