Example #1
0
        /// <summary>
        /// Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
        /// window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media
        /// query results).
        /// </summary>
        /// <param name = "width">Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.</param>
        /// <param name = "height">Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.</param>
        /// <param name = "deviceScaleFactor">Overriding device scale factor value. 0 disables the override.</param>
        /// <param name = "mobile">Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text
        public async System.Threading.Tasks.Task <DevToolsMethodResponse> SetDeviceMetricsOverrideAsync(int width, int height, long deviceScaleFactor, bool mobile, long?scale = null, int?screenWidth = null, int?screenHeight = null, int?positionX = null, int?positionY = null, bool?dontSetVisibleSize = null, CefSharp.DevTools.Emulation.ScreenOrientation screenOrientation = null, CefSharp.DevTools.Page.Viewport viewport = null)
        {
            ValidateSetDeviceMetricsOverride(width, height, deviceScaleFactor, mobile, scale, screenWidth, screenHeight, positionX, positionY, dontSetVisibleSize, screenOrientation, viewport);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            dict.Add("width", width);
            dict.Add("height", height);
            dict.Add("deviceScaleFactor", deviceScaleFactor);
            dict.Add("mobile", mobile);
            if (scale.HasValue)
            {
                dict.Add("scale", scale.Value);
            }

            if (screenWidth.HasValue)
            {
                dict.Add("screenWidth", screenWidth.Value);
            }

            if (screenHeight.HasValue)
            {
                dict.Add("screenHeight", screenHeight.Value);
            }

            if (positionX.HasValue)
            {
                dict.Add("positionX", positionX.Value);
            }

            if (positionY.HasValue)
            {
                dict.Add("positionY", positionY.Value);
            }

            if (dontSetVisibleSize.HasValue)
            {
                dict.Add("dontSetVisibleSize", dontSetVisibleSize.Value);
            }

            if ((screenOrientation) != (null))
            {
                dict.Add("screenOrientation", screenOrientation.ToDictionary());
            }

            if ((viewport) != (null))
            {
                dict.Add("viewport", viewport.ToDictionary());
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Emulation.setDeviceMetricsOverride", dict);

            return(methodResult);
        }
Example #2
0
        /// <summary>
        /// Capture page screenshot.
        /// </summary>
        /// <param name = "format">Image compression format (defaults to png).</param>
        /// <param name = "quality">Compression quality from range [0..100] (jpeg only).</param>
        /// <param name = "clip">Capture the screenshot of a given region only.</param>
        /// <param name = "fromSurface">Capture the screenshot from the surface, rather than the view. Defaults to true.</param>
        /// <returns>returns System.Threading.Tasks.Task&lt;CaptureScreenshotResponse&gt;</returns>
        public async System.Threading.Tasks.Task <CaptureScreenshotResponse> CaptureScreenshotAsync(string format = null, int?quality = null, CefSharp.DevTools.Page.Viewport clip = null, bool?fromSurface = null)
        {
            ValidateCaptureScreenshot(format, quality, clip, fromSurface);
            var dict = new System.Collections.Generic.Dictionary <string, object>();

            if (!(string.IsNullOrEmpty(format)))
            {
                dict.Add("format", format);
            }

            if (quality.HasValue)
            {
                dict.Add("quality", quality.Value);
            }

            if ((clip) != (null))
            {
                dict.Add("clip", clip.ToDictionary());
            }

            if (fromSurface.HasValue)
            {
                dict.Add("fromSurface", fromSurface.Value);
            }

            var methodResult = await _client.ExecuteDevToolsMethodAsync("Page.captureScreenshot", dict);

            return(methodResult.DeserializeJson <CaptureScreenshotResponse>());
        }
Example #3
0
 partial void ValidateSetDeviceMetricsOverride(int width, int height, long deviceScaleFactor, bool mobile, long?scale = null, int?screenWidth = null, int?screenHeight = null, int?positionX = null, int?positionY = null, bool?dontSetVisibleSize = null, CefSharp.DevTools.Emulation.ScreenOrientation screenOrientation = null, CefSharp.DevTools.Page.Viewport viewport = null);
Example #4
0
 partial void ValidateCaptureScreenshot(string format = null, int?quality = null, CefSharp.DevTools.Page.Viewport clip = null, bool?fromSurface = null);