Exemple #1
0
        public BrowserControl(string name)
        {
            InitializeComponent();
            WebBrowser                    = new ExtendedWebBrowser(name);
            WebBrowser.Dock               = DockStyle.Fill;
            WebBrowser.DownloadComplete  += _browser_DownloadComplete;
            WebBrowser.Navigated         += _browser_Navigated;
            WebBrowser.StartNewWindow    += _browser_StartNewWindow;
            WebBrowser.DocumentCompleted += _browser_DocumentCompleted;
            containerPanel.Controls.Add(WebBrowser);

            // Make the magenta color transparent on the go button
            var bmp = (Bitmap)goButton.Image;

            bmp.MakeTransparent(Color.Magenta);
        }
        public ExtendedWebBrowser New(bool navigateHome, string title)
        {
            ExtendedWebBrowser webBrowser = null;


            _tabControl.InvokeIfRequired(tc =>
            {
                webBrowser     = new ExtendedWebBrowser(title);
                var tabControl = tc as TabControl;
                // Create a new tab page
                var page = new TabPage {
                    Text = title
                };


                // Create a new browser control
                var panel = new Panel();
                panel.Controls.Add(webBrowser);
                webBrowser.Dock = DockStyle.Fill;
                // Set the page as the Tag of the browser control, and vice-versa, this will come in handy later
                panel.Tag = page;
                page.Tag  = panel;
                // Dock the browser control
                panel.Dock = DockStyle.Fill;
                // Add the browser control to the tab page
                page.Controls.Add(panel);
                if (navigateHome)
                {
                    (panel.Controls[0] as ExtendedWebBrowser).GoHome();
                }
                // Wire some events
                (panel.Controls[0] as ExtendedWebBrowser).StatusTextChanged    += WebBrowser_StatusTextChanged;
                (panel.Controls[0] as ExtendedWebBrowser).DocumentTitleChanged += WebBrowser_DocumentTitleChanged;
                (panel.Controls[0] as ExtendedWebBrowser).DocumentCompleted    += WebBrowser_DocumentCompleted;
                (panel.Controls[0] as ExtendedWebBrowser).Quit += WebBrowser_Quit;

                // Add the new page to the tab control
                tabControl.TabPages.Add(page);
                tabControl.SelectedTab = page;
                tabControl.Visible     = true;

                webBrowser = panel.Controls[0] as ExtendedWebBrowser;
            });


            return(webBrowser);
        }
        public ExtendedWebBrowser New(bool navigateHome, string title)
        {
            ExtendedWebBrowser webBrowser = null;

            _tabControl.InvokeIfRequired(tc =>
            {
                var tabControl = tc as TabControl;
                // Create a new tab page
                var page = new TabPage {
                    Text = title
                };

                // Create a new browser control
                var browserControl       = new BrowserControl(title);
                browserControl.ErrorForm = _errorForm;
                // Set the page as the Tag of the browser control, and vice-versa, this will come in handy later
                browserControl.Tag = page;
                page.Tag           = browserControl;
                // Dock the browser control
                browserControl.Dock = DockStyle.Fill;
                // Add the browser control to the tab page
                page.Controls.Add(browserControl);
                if (navigateHome)
                {
                    browserControl.WebBrowser.GoHome();
                }
                // Wire some events
                browserControl.WebBrowser.StatusTextChanged    += WebBrowser_StatusTextChanged;
                browserControl.WebBrowser.DocumentTitleChanged += WebBrowser_DocumentTitleChanged;
                browserControl.WebBrowser.CanGoBackChanged     += WebBrowser_CanGoBackChanged;
                browserControl.WebBrowser.CanGoForwardChanged  += WebBrowser_CanGoForwardChanged;
                browserControl.WebBrowser.Navigated            += WebBrowser_Navigated;
                browserControl.WebBrowser.DocumentCompleted    += WebBrowser_DocumentCompleted;
                browserControl.WebBrowser.Quit += WebBrowser_Quit;

                // Add the new page to the tab control
                tabControl.TabPages.Add(page);
                tabControl.SelectedTab = page;
                tabControl.Visible     = true;

                webBrowser = browserControl.WebBrowser;
            });


            return(webBrowser);
        }
        private static Panel PanelFromBrowser(ExtendedWebBrowser browser)
        {
            // This is a little nasty. The Extended Web Browser is nested in 
            // a panel, wich is nested in the browser control

            // Since we want to avoid a NullReferenceException, do some checking

            // Check if we got a extended web browser
            if (browser == null)
                return null;

            // Check if it got a parent
            if (browser.Parent == null)
                return null;

            // Return the parent of the parent using a safe cast.
            return browser.Parent.Parent as Panel;
        }
        private static BrowserControl BrowserControlFromBrowser(ExtendedWebBrowser browser)
        {
            // This is a little nasty. The Extended Web Browser is nested in
            // a panel, wich is nested in the browser control

            // Since we want to avoid a NullReferenceException, do some checking

            // Check if we got a extended web browser
            if (browser == null)
            {
                return(null);
            }

            // Check if it got a parent
            if (browser.Parent == null)
            {
                return(null);
            }

            // Return the parent of the parent using a safe cast.
            return(browser.Parent.Parent as BrowserControl);
        }
 public WebBrowserExtendedEvents(ExtendedWebBrowser browser) 
 { _Browser = browser; }
        public ExtendedWebBrowser New(bool navigateHome, string title)
        {

            ExtendedWebBrowser webBrowser = null; 
           
          

            this._tabControl.InvokeIfRequired(tc =>
            {
                webBrowser = new ExtendedWebBrowser(title);
                TabControl tabControl = (tc as TabControl);
                // Create a new tab page
                TabPage page = new TabPage() { Text = title };



                // Create a new browser control
                Panel panel = new Panel();
                panel.Controls.Add(webBrowser);
                webBrowser.Dock = DockStyle.Fill;
                // Set the page as the Tag of the browser control, and vice-versa, this will come in handy later
                panel.Tag = page;
                page.Tag = panel;
                // Dock the browser control
                panel.Dock = DockStyle.Fill;
                // Add the browser control to the tab page
                page.Controls.Add(panel);
                if (navigateHome)
                {
                    // Navigate to the home page
                    (panel.Controls[0] as ExtendedWebBrowser).GoHome();
                }
                // Wire some events
                (panel.Controls[0] as ExtendedWebBrowser).StatusTextChanged += new EventHandler(WebBrowser_StatusTextChanged);
                (panel.Controls[0] as ExtendedWebBrowser).DocumentTitleChanged += new EventHandler(WebBrowser_DocumentTitleChanged);
                (panel.Controls[0] as ExtendedWebBrowser).DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted);
                (panel.Controls[0] as ExtendedWebBrowser).Quit += new EventHandler(WebBrowser_Quit);

                // Add the new page to the tab control
                tabControl.TabPages.Add(page);
                tabControl.SelectedTab = page;
                tabControl.Visible = true;

                webBrowser = (panel.Controls[0] as ExtendedWebBrowser);
            });


            return webBrowser;
        }
 public WebBrowserExtendedEvents(ExtendedWebBrowser browser)
 {
     _Browser = browser;
 }
        public BrowserControl(string name)
        {
            InitializeComponent();
            _browser = new ExtendedWebBrowser(name);
            _browser.Dock = DockStyle.Fill;
            _browser.DownloadComplete += new EventHandler(_browser_DownloadComplete);
            _browser.Navigated += new WebBrowserNavigatedEventHandler(_browser_Navigated);
            _browser.StartNewWindow += new StartNewWindowHandler(_browser_StartNewWindow);
            _browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(_browser_DocumentCompleted);
            this.containerPanel.Controls.Add(_browser);

            // Make the magenta color transparent on the go button
            Bitmap bmp = (Bitmap)goButton.Image;
            bmp.MakeTransparent(Color.Magenta);
        }