public void NewTab(string url) { var state = new WebBrowserState(); var tabPage = new TabPage(url); var navBox = new WebNavigationBox(); navBox.Parent = tabPage; navBox.Dock = DockStyle.Top; navBox.Visible = true; navBox.HomeUrl = _application.HomeUrl; var browserCtl = new CefWebBrowser(); tabPage.Tag = browserCtl; browserCtl.Parent = tabPage; browserCtl.Dock = DockStyle.Fill; browserCtl.BringToFront(); var browser = browserCtl.WebBrowser; browser.StartUrl = url; navBox.Attach(browser); browser.TitleChanged += (s, e) => { state.Title = e.Title; _pUIThread.Post((_state) => { UpdateTitle(e.Title); }, null); }; browser.AddressChanged += (s, e) => { state.Title = e.Address; _pUIThread.Post((_state) => { navBox.Address = e.Address; }, null); }; browser.TargetUrlChanged += (s, e) => { state.TargetUrl = e.TargetUrl; // TODO: show targeturl in status bar // _pUIThread.Post((_state) => { UpdateTargetUrl(e.TargetUrl); }, null); }; browser.LoadingStateChanged += (s, e) => { _pUIThread.Post((_state) => { navBox.CanGoBack = e.CanGoBack; navBox.CanGoForward = e.CanGoForward; navBox.Loading = e.Loading; }, null); }; _tabs.TabPages.Add(tabPage); _tabs.SelectedTab = tabPage; }
public void NewTab(string url) { var state = new WebBrowserState(); var tabPage = new TabPage(url); var navBox = new WebNavigationBox(); navBox.Parent = tabPage; navBox.Dock = DockStyle.Top; navBox.Visible = true; navBox.HomeUrl = _application.HomeUrl; var browserCtl = new CefWebBrowser(); browserCtl.Parent = tabPage; browserCtl.Dock = DockStyle.Fill; browserCtl.BringToFront(); var browser = browserCtl.WebBrowser; browser.StartUrl = url; navBox.Attach(browser); browser.TitleChanged += (s, e) => { state.Title = e.Title; _pUIThread.Post((_state) => { UpdateTitle(e.Title); }, null); }; browser.AddressChanged += (s, e) => { state.Title = e.Address; _pUIThread.Post((_state) => { navBox.Address = e.Address; }, null); }; browser.TargetUrlChanged += (s, e) => { state.TargetUrl = e.TargetUrl; // TODO: show targeturl in status bar // _pUIThread.Post((_state) => { UpdateTargetUrl(e.TargetUrl); }, null); }; browser.LoadingStateChanged += (s, e) => { _pUIThread.Post((_state) => { navBox.CanGoBack = e.CanGoBack; navBox.CanGoForward = e.CanGoForward; navBox.Loading = e.Loading; }, null); }; _tabs.TabPages.Add(tabPage); _tabs.SelectedTab = tabPage; }
public void NewTab(string url) { var state = new WebBrowserState(); var label = new Label(url); var content = new VBox(true, 0); content.Homogeneous = false; var navBox = new WebNavigationBox(); content.Add(navBox); ((Box.BoxChild)content[navBox]).Expand = false; ((Box.BoxChild)content[navBox]).Fill = false; navBox.HomeUrl = _application.HomeUrl; var browserCtl = new CefWebBrowser(); content.Add(browserCtl); ((Box.BoxChild)content[browserCtl]).Expand = true; ((Box.BoxChild)content[browserCtl]).Fill = true; var browser = browserCtl.WebBrowser; browser.StartUrl = url; navBox.Attach(browser); browser.TitleChanged += (s, e) => { state.Title = e.Title; Application.Invoke((_s, _e) => { UpdateTitle(e.Title); }); }; browser.AddressChanged += (s, e) => { state.Title = e.Address; Application.Invoke((_s, _e) => { navBox.Address = e.Address; }); }; browser.TargetUrlChanged += (s, e) => { state.TargetUrl = e.TargetUrl; // TODO: show targeturl in status bar // Application.Invoke((_s, _e) => { UpdateTargetUrl(e.TargetUrl); }); }; browser.LoadingStateChanged += (s, e) => { Application.Invoke((_s, _e) => { navBox.CanGoBack = e.CanGoBack; navBox.CanGoForward = e.CanGoForward; navBox.Loading = e.Loading; }); }; _tabs.AppendPage(content, label); content.ShowAll(); _tabs.CurrentPage = _tabs.PageNum(content); }