/// <summary> /// Create WinForms.ChromiumWebBrowser and navigate to the initial page /// </summary> public void LoadInitialPage() { if (Browser != null) { return; } string url = ""; if (RendererMode == KekuleJsControlMode.OffScreenBitmap) { url = ServicesIniFile.ReadWithException("KekuleJsRendererUrl"); } else if (RendererMode == KekuleJsControlMode.BrowserViewOnly) { url = ServicesIniFile.ReadWithException("KekuleJsRendererUrl"); } else if (RendererMode == KekuleJsControlMode.BrowserEditor) { url = ServicesIniFile.ReadWithException("KekuleJsEditorUrl"); } if (Debug) { DebugLog.Message("Loading initial " + RendererMode + " mode page: " + url + IdText); } Browser = new WebBrowser(); // create the browser Browser.Location = new Point(0, 0); Browser.Size = new Size(256, 256); Browser.Dock = DockStyle.None; Browser.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right); Browser.Name = "WebBrowser"; Browser.ScrollBarsEnabled = false; Browser.ScriptErrorsSuppressed = JavaScriptManager.SuppressJavaScriptErrors; Browser.ObjectForScripting = new JavaScriptManager(this); // create ScriptManager that can call back to this JavaScriptInterface instance from within web page JavaScript // The following three events are also in WebBrowserWrapper (not needed here) Browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Browser_DocumentCompleted); Browser.Navigated += new WebBrowserNavigatedEventHandler(this.WebBrowser_Navigated); Browser.Navigating += new WebBrowserNavigatingEventHandler(this.WebBrowser_Navigating); Browser.ProgressChanged += new WebBrowserProgressChangedEventHandler(Browser_ProgressChanged); Browser.StatusTextChanged += new EventHandler(WebBrowserStatusTextChanged); Browser.Resize += new EventHandler(WebBrowser_Resize); Browser.SizeChanged += new EventHandler(Browser_SizeChanged); if (ContainingControl != null) { Browser.Size = ContainingControl.Size; ContainingControl.Controls.Clear(); ContainingControl.Controls.Add(Browser); } else { Browser.Size = new Size(1024, 768); } BrowserWrapper = new WebBrowserWrapper(Browser); BrowserWrapper.NavigateAndWait(url); // navigate to the initial page ResizeRendering(); if (Debug) { DebugLog.Message("Browser created, initial page loaded" + IdText); } return; }