private void Construct(WindowPrototype prot) { string errorMessage = null; try { webBrowser = new WebView(); } catch (Exception) { errorMessage = "Failed to create a WebKit.WebView widget.\nMake sure that libwebkitgtk-1.0 is installed."; } //todo: remove windowHandle creation from here WindowHandle handle = new WindowHandle(this, this.webBrowser); this.Destroyed += (o, args) => { prot.OnClose(handle); }; VBox vbox = new VBox(false, 0); this.Add(vbox); if (prot.Menu != null && prot.Menu.Any()) { MenuBar menuBar = CreateMenu(handle, prot.Menu); vbox.PackStart(menuBar, false, false, 0); } if (webBrowser == null) { Label errorLabel = new Label(errorMessage); vbox.PackEnd(errorLabel, true, true, 0); } else { vbox.PackEnd(webBrowser, true, true, 0); webBrowser.TitleChanged += (o, args) => { string title = webBrowser.Title; Application.Invoke(delegate { this.Title = title; }); }; webBrowser.LoadUri(prot.Url); } //todo: bug, window cannot be resized to smaller size (seems related to https://bugs.webkit.org/show_bug.cgi?id=17154) Resize(prot.Width, prot.Height); vbox.ShowAll(); }
public WindowHandle ShowDialog(WindowHandle parent, WindowPrototype prototype) { Form parentForm = (Form)parent.NativeWindow; if (parentForm.InvokeRequired) { return((WindowHandle)parentForm.Invoke(new Func <WindowHandle, WindowPrototype, WindowHandle>(ShowDialog), parent, prototype)); } WindowHandle handle = ConstructDialog(prototype); Form window = (Form)handle.NativeWindow; window.Closed += (sender, args) => prototype.OnClose(handle); //todo: use ShowDialog when CefSharp 43 is released (now it freezes the application) window.Show(parentForm); //todo: this would conflict with window.ShowDialog return(handle); }