public void Grabber_WhenDisposed_Throws()
        {
            var grabber = new ScreenGrabber(new CaptureParameters());
            var video = new FlashScreenVideo(new FlashScreenVideoParameters(grabber.ScreenshotWidth, grabber.ScreenshotHeight, 5));
            var recorder = new ScreenRecorder(grabber, video);
            recorder.Dispose();

            ScreenGrabber x;
            Assert.Throws<ObjectDisposedException>(() => x = recorder.Grabber);
        }
Esempio n. 2
0
        /// <summary>
        /// Starts recording a screen capture video of the entire desktop.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Recording a screen capture video can be very CPU and space intensive particularly
        /// when running tests on a single-core CPU.  We recommend calling
        /// <see cref="StartRecording(CaptureParameters, double)" /> with
        /// a <see cref="CaptureParameters.Zoom" /> factor of 0.25 or less and a frame rate
        /// of no more than 5 to 10 frames per second.
        /// </para>
        /// </remarks>
        /// <param name="parameters">The capture parameters.</param>
        /// <param name="framesPerSecond">The number of frames per second to capture.</param>
        /// <returns>The recorder.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="parameters"/> is null.</exception>
        /// <exception cref="ScreenshotNotAvailableException">Thrown if a screenshot cannot be captured at this time.</exception>
        public static ScreenRecorder StartRecording(CaptureParameters parameters, double framesPerSecond)
        {
            if (parameters == null)
                throw new ArgumentNullException("parameters");

            ScreenGrabber.ThrowIfScreenshotNotAvailable();

            ScreenGrabber grabber = new ScreenGrabber(parameters);
            try
            {
                FlashScreenVideo video = new FlashScreenVideo(new FlashScreenVideoParameters(
                    grabber.ScreenshotWidth, grabber.ScreenshotHeight, framesPerSecond));

                ScreenRecorder recorder = new ScreenRecorder(grabber, video);
                try
                {
                    recorder.OverlayManager.AddOverlay(GetOverlayManager().ToOverlay());

                    recorder.Start();
                    return recorder;
                }
                catch
                {
                    recorder.Dispose();
                    throw;
                }
            }
            catch
            {
                grabber.Dispose();
                throw;
            }
        }