private void tabs_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Get the current browser.
            this.currentBrowser = this.tabs.SelectedWebBrowser;

            this.DisplayPageTitle();

            // Enable the Close Tab command if and only if there is more than one tab.
            if (this.tabs.TabCount == 1)
            {
                this.closeTabMenuItem.Enabled = false;
                this.closeTabButton.Enabled   = false;
            }
            else
            {
                this.closeTabMenuItem.Enabled = true;
                this.closeTabButton.Enabled   = true;
            }

            Uri url = this.currentBrowser.Url;

            if (url == null)
            {
                // There is no current address.
                this.addressCombo.Text = string.Empty;

                // The user cannot refresh a page that doesn't exist.
                this.refreshMenuItem.Enabled = false;
                this.refreshButton.Enabled   = false;
            }
            else
            {
                // Display the current page address in the address bar.
                this.addressCombo.Text = url.ToString();

                // Allow the user to refresh the current page.
                this.refreshMenuItem.Enabled = true;
                this.refreshButton.Enabled   = true;
            }

            // Display the current page's status text in the status bar.
            this.browserStatusTextLabel.Text = this.currentBrowser.StatusText;

            WebBrowserTabPage tab    = this.tabs.SelectedWebBrowserTagPage;
            long lastCurrentProgress = tab.LastCurrentProgress;
            long lastMaximumProgress = tab.LastMaximumProgress;

            if (lastMaximumProgress > 0L && lastCurrentProgress > 0L)
            {
                // Display the current progress.
                this.pageLoadProgress.Visible = true;
                this.pageLoadProgress.Value   = (int)Math.Round(((double)(100 * lastCurrentProgress / lastMaximumProgress)));
            }
            else
            {
                // Hide and reset the progress bar
                this.pageLoadProgress.Visible = false;
                this.pageLoadProgress.Value   = 0;
            }
        }
        /// <summary>
        /// Adds a new page to the tab control and navigates to the specified address.
        /// </summary>
        /// <param name="address">
        /// The address of the page to display in the new tab.
        /// </param>
        /// <returns>
        /// The <see cref="WebBrowserTabPage" /> that was added.
        /// </returns>
        public WebBrowserTabPage AddTab(string address)
        {
            WebBrowserTabPage tab = this.AddTab();

            tab.Browser.Navigate(address);
            return(tab);
        }
 /// <summary>
 /// Adds a new, empty page to the tab control.
 /// </summary>
 /// <returns> 
 /// The <see cref="WebBrowserTabPage" /> that was added.
 /// </returns>
 public WebBrowserTabPage AddTab()
 {
     WebBrowserTabPage tab = new WebBrowserTabPage();
     this.TabPages.Add(tab);
     this.SelectedTab = tab;
     return tab;
 }
        /// <summary>
        /// Adds a new, empty page to the tab control.
        /// </summary>
        /// <returns>
        /// The <see cref="WebBrowserTabPage" /> that was added.
        /// </returns>
        public WebBrowserTabPage AddTab()
        {
            WebBrowserTabPage tab = new WebBrowserTabPage();

            this.TabPages.Add(tab);
            this.SelectedTab = tab;
            return(tab);
        }
        /// <summary>
        /// Removes the currently selected tab from the tab control.
        /// </summary>
        /// <returns>
        /// <b>True</b> if the current tab was removed; otherwise, <b>False</b>.
        /// </returns>
        /// <remarks>
        /// There must always be at least one tab so the last tab cannot be removed.
        /// </remarks>
        public bool RemoveCurrentTab()
        {
            bool canRemove = this.TabCount > 1;

            if (canRemove)
            {
                WebBrowserTabPage tab = this.SelectedWebBrowserTagPage;
                this.TabPages.Remove(tab);
                tab.Dispose();
            }

            return(canRemove);
        }