Load() public method

Loads the specified URL.
public Load ( string url ) : void
url string The URL to be loaded.
return void
Ejemplo n.º 1
0
        public void TakeScreenshotOffscreen(string url, string filename)
        {
            var offscreenBrowser = new CefSharp.OffScreen.ChromiumWebBrowser();

            offscreenBrowser.BrowserInitialized += (o, args) =>
            {
                offscreenBrowser.Load(url);
                offscreenBrowser.FrameLoadEnd += async(sender1, eventArgs) =>
                {
                    if (eventArgs.Frame.IsMain)
                    {
                        var sizes = await offscreenBrowser.EvaluateScriptAsync(JavascriptQueries.RequestForMaxSize);

                        var widthAndHeight = (List <object>)sizes.Result;

                        var screenshotSize = new System.Drawing.Size((int)widthAndHeight[0], (int)widthAndHeight[1]);
                        offscreenBrowser.Size = screenshotSize;

                        await Task.Delay(500);

                        var bitmap = await offscreenBrowser.ScreenshotAsync(false, PopupBlending.Main);

                        bitmap.Save(filename, ImageFormat.Png);
                        offscreenBrowser.Dispose();
                        Process.Start(new System.Diagnostics.ProcessStartInfo
                        {
                            UseShellExecute = true,
                            FileName        = filename
                        });
                    }
                };
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Navigate to a URL and wait for page loading to complete
        /// </summary>
        /// <param name="url"></param>

        public void NavigateTo(string url)
        {
            if (Debug)
            {
                DebugLog.Message("Loading page: " + url);
            }

            //WebBrowser.Size = new Size((int)(800 + 1.25), (int)(400 * 1.25));

            PageLoadedEvent.Reset();
            OffScreenBrowser.Load(url);

            PageLoadedEvent.WaitOne();     // wait for page to complete loading

            Thread.Sleep(500);             // Give the browser a little time to render

            if (Debug)
            {
                DebugLog.Message("Loading complete");
            }

            return;
        }