/// <summary>
        /// Creates a new photo capture based on the <paramref name="captureMode"/> specified.
        /// </summary>
        /// <param name="captureMode">Capture mode to create photo capture for.</param>
        /// <returns>Photo capture created.</returns>
        /// <exception cref="InvalidOperationException"><paramref name="captureMode"/> is not supported.</exception>
        private IPhotoCapture CreatePhotoCapture(CaptureMode captureMode)
        {
            Tracing.Trace("PhotoCamera: Creating new capture {0}", captureMode);

            IPhotoCapture capture;

            switch (captureMode)
            {
            case CaptureMode.LowLag:
                capture = new LowLagCapture(this.CameraController);
                break;

            case CaptureMode.Variable:
                // VPS may not be supported on the current device.
                if (!this.CameraController.MediaCapture.VideoDeviceController.VariablePhotoSequenceController.Supported)
                {
                    throw new NotSupportedException("VPS is not supported.");
                }

                capture = new VariablePhotoCapture(this.CameraController);
                break;

            default:
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Capture mode {0} is not supported.", captureMode));
            }

            this.captureStarted = false;
            this.SubscribeToCaptureEvents(capture);

            return(capture);
        }
        /// <summary>
        /// Unsubscribes from the <paramref name="capture"/> events.
        /// </summary>
        /// <param name="capture">Photo capture.</param>
        private void UnsubscribeFromCaptureEvents(IPhotoCapture capture)
        {
            Tracing.Trace("PhotoCamera: Unsubscribing from capture events.");

            capture.Started -= this.CaptureOnStarted;
            capture.Stopped -= this.CaptureOnStopped;

            LowLagCapture lowLagCapture = capture as LowLagCapture;

            if (lowLagCapture != null)
            {
                lowLagCapture.PhotoCaptured -= this.LowLagCaptureOnPhotoCaptured;
                return;
            }

            VariablePhotoCapture variableCapture = capture as VariablePhotoCapture;

            if (variableCapture != null)
            {
                variableCapture.PhotoCaptured -= this.VariableCaptureOnPhotoCaptured;
            }
        }
        /// <summary>
        /// Subscribes to the <paramref name="capture"/> events.
        /// </summary>
        /// <param name="capture">Photo capture.</param>
        private void SubscribeToCaptureEvents(IPhotoCapture capture)
        {
            Tracing.Trace("PhotoCamera: Subscribing to capture events.");

            capture.Started += this.CaptureOnStarted;
            capture.Stopped += this.CaptureOnStopped;

            // Subscribe to a specific capture events.
            // See IPhotoCapture remarks section for details.
            LowLagCapture lowLagCapture = capture as LowLagCapture;

            if (lowLagCapture != null)
            {
                lowLagCapture.PhotoCaptured += this.LowLagCaptureOnPhotoCaptured;
                return;
            }

            VariablePhotoCapture variableCapture = capture as VariablePhotoCapture;

            if (variableCapture != null)
            {
                variableCapture.PhotoCaptured += this.VariableCaptureOnPhotoCaptured;
            }
        }