protected void TakeScreenshotButtonClick( object sender, EventArgs e) { var gatewayUrl = GetIFrameGatewayUrl((sender as HtmlInputButton).Attributes["data-fid"]); if (!string.IsNullOrEmpty(gatewayUrl)) { var connectionId = GetIFrameConnectionId((sender as HtmlInputButton).Attributes["data-fid"]); if (connectionId != Guid.Empty) { var captureClient = new CaptureClient(string.Format("{0}/api/Capture/", gatewayUrl)); // retrieve screenshot data var screenshotBytes = captureClient.TakeScreenshot(connectionId); if (screenshotBytes != null && screenshotBytes.Length > 0) { // write it into the http response Response.Headers.Add("ContentType", "image/png"); Response.Headers.Add("Content-Disposition", "attachment; filename=screenshot.png;"); Response.Headers.Add("Content-Length", screenshotBytes.Length.ToString()); Response.OutputStream.Write(screenshotBytes, 0, screenshotBytes.Length); } } } }
protected void StopTakingScreenshotsButtonClick( object sender, EventArgs e) { var gatewayUrl = GetIFrameGatewayUrl((sender as HtmlInputButton).Attributes["data-fid"]); if (!string.IsNullOrEmpty(gatewayUrl)) { var connectionId = GetIFrameConnectionId((sender as HtmlInputButton).Attributes["data-fid"]); if (connectionId != Guid.Empty) { var captureClient = new CaptureClient(string.Format("{0}/api/Capture/", gatewayUrl)); captureClient.StopTakingScreenshots(connectionId); } } }
protected void SetScreenshotConfigButtonClick( object sender, EventArgs e) { var gatewayUrl = GetIFrameGatewayUrl((sender as HtmlInputButton).Attributes["data-fid"]); if (!string.IsNullOrEmpty(gatewayUrl)) { var connectionId = GetIFrameConnectionId((sender as HtmlInputButton).Attributes["data-fid"]); if (connectionId != Guid.Empty) { var captureClient = new CaptureClient(string.Format("{0}/api/Capture/", gatewayUrl)); captureClient.SetScreenshotConfig(connectionId, 10, CaptureFormat.PNG, @"C:\path\to\screenshots\"); } } }