コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: medfki/myrtille
        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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Default.aspx.cs プロジェクト: medfki/myrtille
        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);
                }
            }
        }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: medfki/myrtille
        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\");
                }
            }
        }