/// <summary> /// Creates a new instance of the <see cref="WebBrowserTabPage" /> class and displays the specified <b>WebBrowser</b> control. /// </summary> /// <param name="browser"> /// The <b>WebBrowser</b> control to display on the page. /// </param> public WebBrowserTabPage(WebBrowserCore browser) { browser.Dock = DockStyle.Fill; this.Controls.Add(browser); this._browser = browser; this.DisplayPageTitle(); this._browser.DocumentTitleChanged += new EventHandler(_browser_DocumentTitleChanged); this._browser.ProgressChanged += new WebBrowserProgressChangedEventHandler(_browser_ProgressChanged); }
private void tabs_SelectedIndexChanged(object sender, EventArgs e) { // Get the current browser. this.currentBrowser = this.tabs.SelectedWebBrowser; this.DisplayPageTitle(); CheckIfCanGoBack(); CheckIfCanGoForward(); // Enable the Close Tab command if and only if there is more than one tab. if (this.tabs.TabCount == 2) { this.closeTabButton.Enabled = false; closeTabTSMI.Enabled = false; } else { this.closeTabButton.Enabled = true; closeTabTSMI.Enabled = true; } Uri url = this.currentBrowser.Url; if (url == null) { // There is no current address. this.addressTextBox.Text = string.Empty; // The user cannot refresh a page that doesn't exist. this.refreshButton.Enabled = false; refreshTSMI.Enabled = false; } else { // Display the current page address in the address bar. this.addressTextBox.Text = url.ToString(); // Allow the user to refresh the current page. this.refreshButton.Enabled = true; refreshTSMI.Enabled = true; if (url.OriginalString.StartsWith("https://")) { showCertTSMI.Visible = true; } else { showCertTSMI.Visible = false; } } }
private void NewTab() { // Add the default Tab tabs.AddTab(); this.currentBrowser = this.tabs.SelectedWebBrowser; this.currentBrowser.StatusTextChanged += new EventHandler(currentBrowser_StatusTextChanged); this.currentBrowser.DocumentTitleChanged += new EventHandler(currentBrowser_DocumentTitleChanged); this.currentBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(currentBrowser_DocumentCompleted); this.currentBrowser.ProgressChanged += new WebBrowserProgressChangedEventHandler(currentBrowser_ProgressChanged); currentBrowser.NewWindow += new CancelEventHandler(currentBrowser_NewWindow); currentBrowser.Navigating += new WebBrowserNavigatingEventHandler(currentBrowser_Navigating); currentBrowser.Document.ContextMenuShowing += new HtmlElementEventHandler(Document_ContextMenuShowing); currentBrowser.CanGoBackChanged += new EventHandler(currentBrowser_CanGoBackChanged); currentBrowser.CanGoForwardChanged += new EventHandler(currentBrowser_CanGoForwardChanged); }