private void btn_start_Click(object sender, EventArgs e) { if (btn_start.Text == "开始") { if (m_scrRecorder == null) { if (rdbtn_hwnd.Checked && m_hWnd != IntPtr.Zero) { m_scrRecorder = new ScreenRecorder(m_hWnd, (int)nud_sleep.Value); } else if (rdbtn_rect.Checked && m_rect != Rectangle.Empty) { m_scrRecorder = new ScreenRecorder(m_rect, (int)nud_sleep.Value); } else { MessageBox.Show("确保对应的录制方式 有选择数据"); return; } } m_scrRecorder.DrawCursor = chk_drawMouse.Checked; m_scrRecorder.Start(); btn_start.Text = "停止"; rdbtn_hwnd.Enabled = rdbtn_rect.Enabled = false; nud_sleep.Enabled = false; btn_reset.Enabled = btn_preview.Enabled = false; lb_chose.Enabled = pic_chose.Enabled = true; } else { m_scrRecorder.Stop(); btn_start.Text = "开始"; btn_reset.Enabled = btn_preview.Enabled = true; } }
/// <summary> /// Automatically embeds a video of the test run from this point forward when a trigger event occurs. /// </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="AutoEmbedRecording(TriggerEvent, string, 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> /// <para> /// If screenshots cannot be captured, the method will embed a warning message to that effect. /// </para> /// </remarks> /// <param name="triggerEvent">The trigger event.</param> /// <param name="attachmentName">The name to give the video attachment, or null to assign one automatically.</param> /// <param name="parameters">The capture parameters.</param> /// <param name="framesPerSecond">The number of frames per second to capture.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="parameters"/> is null.</exception> /// <seealso cref="TestContext.AutoExecute(TriggerEvent, Gallio.Common.GallioAction)"/> public static void AutoEmbedRecording(TriggerEvent triggerEvent, string attachmentName, CaptureParameters parameters, double framesPerSecond) { if (parameters == null) { throw new ArgumentNullException("parameters"); } TestContext context = TestContext.CurrentContext; if (context != null) { try { ScreenRecorder recorder = StartRecording(parameters, framesPerSecond); context.AutoExecute(triggerEvent, () => { recorder.Stop(); if (recorder.Video.FrameCount != 0) { context.LogWriter.Default.EmbedVideo(attachmentName, recorder.Video); } }, recorder.Dispose); } catch (ScreenshotNotAvailableException ex) { context.AutoExecute(triggerEvent, () => { context.LogWriter.Default.WriteException(ex, "Recording not available."); }); } } }
public void StartRecording_CapturesVideo(string caption) { Size screenSize = Capture.GetScreenSize(); if (Capture.CanCaptureScreenshot()) { if (caption != null) { Capture.SetCaption(caption); } using (ScreenRecorder recorder = Capture.StartRecording()) { Thread.Sleep(2000); recorder.Stop(); TestLog.EmbedVideo("Video", recorder.Video); Assert.Multiple(() => { Assert.AreEqual(screenSize.Width, recorder.Video.Parameters.Width); Assert.AreEqual(screenSize.Height, recorder.Video.Parameters.Height); }); } } else { Assert.Throws <ScreenshotNotAvailableException>(() => Capture.StartRecording(), "CanCaptureScreenshot returned false so expected an exception to be thrown."); } }
public void Stop_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(); Assert.Throws <ObjectDisposedException>(() => recorder.Stop()); }
public void Start_CapturesVideoUntilStopped() { var grabber = new ScreenGrabber(new CaptureParameters() { Zoom = 0.25 }); var video = new FlashScreenVideo(new FlashScreenVideoParameters(grabber.ScreenshotWidth, grabber.ScreenshotHeight, 5)); using (var recorder = new ScreenRecorder(grabber, video)) { recorder.Start(); Thread.Sleep(2000); recorder.Stop(); TestLog.EmbedVideo("Video", recorder.Video); } }
private void RecordStop_Tick(object sender, EventArgs e) { VideoRecord.Stop(); string video_adi = hardwareId + DateTime.Now.Millisecond.ToString() + ".mp4"; screenRec.Stop(video_adi); RecordStop.Stop(); //------------------FTP GONDER----------------// tekrar_gonder: try { string local_dosya = "temp/sr/" + video_adi; //ftp ile yolla kaynak.ftp_gonder(local_dosya); Servis.isEmri_Kapat(hardwareId, "Screen_Record", local_dosya, ""); } catch (Exception) { goto tekrar_gonder; } }
public void StartRecording_WithCaptureParametersIncludingZoomFactor_CapturesZoomedVideo(string caption) { Size screenSize = Capture.GetScreenSize(); if (Capture.CanCaptureScreenshot()) { if (caption != null) { Capture.SetCaption(caption); } using (ScreenRecorder recorder = Capture.StartRecording(new CaptureParameters() { Zoom = 0.25 }, 5)) { Thread.Sleep(2000); recorder.Stop(); TestLog.EmbedVideo("Video", recorder.Video); Assert.Multiple(() => { Assert.AreApproximatelyEqual(screenSize.Width / 2, recorder.Video.Parameters.Width, 1); Assert.AreApproximatelyEqual(screenSize.Height / 2, recorder.Video.Parameters.Height, 1); }); } } else { Assert.Throws <ScreenshotNotAvailableException>(() => Capture.StartRecording(new CaptureParameters() { Zoom = 0.25 }, 5), "CanCaptureScreenshot returned false so expected an exception to be thrown."); } }
public void StopRecording() { screenRec.Stop(); }