void WebBrowser_StatusTextChanged(object sender, EventArgs e) { // First, see if the active page is calling, or another page ExtendedWebBrowser ewb = sender as ExtendedWebBrowser; // Return if we got nothing (shouldn't happen) if (ewb == null) { return; } // This is a little nasty. The Extended Web Browser is nested in // a panel, wich is nested in the browser control BrowserControl bc = BrowserControlFromBrowser(ewb); // The Tag of the BrowserControl should point to the TabPageEx TabPageEx page = bc.Tag as TabPageEx; // If not, return if (page == null) { return; } // See if 'page' is the active page if (this._tabControl.SelectedTab == page) { // Yep, send the event that updates the status bar text OnStatusTextChanged(new TextChangedEventArgs(ewb.StatusText)); } }
void WebBrowser_Quit(object sender, EventArgs e) { // This event is launched when window.close() is called from script ExtendedWebBrowser brw = sender as ExtendedWebBrowser; if (brw == null) { return; } // See which page it was on... BrowserControl bc = BrowserControlFromBrowser(brw); if (bc == null) { return; } TabPageEx page = bc.Tag as TabPageEx; if (page == null) { return; } // We got a page, remove & dispose it. _tabControl.TabPages.Remove(page); page.Dispose(); if (_tabControl.TabPages.Count == 0) { _tabControl.Visible = false; } }
public void Open(Uri url) { try { ExtendedWebBrowser browser = this.New(false); browser.Navigate(url); } catch (Exception ex) { string error = ex.Message; } }
public void GoToURL(string URL, System.Windows.Forms.TextBox txtDisplay, ExtendedWebBrowser browser) { try { if (goToURLTimer.Tag == null) { goToURLTimer.Stop(); //this is how long before the link is clicked Random rnd = new Random(); double seconds = rnd.Next(7, 15); double percentage = rnd.Next(1, 100); if (percentage > 80) { seconds = seconds + (((rnd.Next(0, 12)))); } else if (percentage > 60) { seconds = seconds + ((rnd.Next(0, 10))); } else if (percentage > 30) { seconds = seconds + (((rnd.Next(0, 10)))); } TimerInfo_old timerInfo = new TimerInfo_old(); timerInfo.StartTime = DateTime.Now; timerInfo.UrlToGoTo = URL; timerInfo.Duration = TimeSpan.FromSeconds(seconds); timerInfo.TxtDisplay = txtDisplay; timerInfo.Browser = browser; goToURLTimer.Tag = timerInfo; goToURLTimer.Tick += Timer_Tick; goToURLTimer.Start(); //keepRunning_tour_Timer.Stop(); //keepRunning_tour_Timer.Tag = null; } } catch (Exception ex) { //Tools.WriteToFile(ex); throw; //Application.Restart(); } }
void WebBrowser_DocumentTitleChanged(object sender, EventArgs e) { // Update the title of the tab page of the control. ExtendedWebBrowser ewb = sender as ExtendedWebBrowser; // Return if we got nothing (shouldn't happen) if (ewb == null) { return; } // This is a little nasty. The Extended Web Browser is nested in // a panel, wich is nested in the browser control BrowserControl bc = BrowserControlFromBrowser(ewb); // If we got null, return if (bc == null) { return; } // The Tag of the BrowserControl should point to the TabPageEx TabPageEx page = bc.Tag as TabPageEx; // If not, return if (page == null) { return; } // Update the tabPage // Keep it user-friendly, don't do those awful long web page titles // in tabs and make sure the title is never empty string documentTitle = ewb.DocumentTitle; if (string.IsNullOrEmpty(documentTitle)) { documentTitle = Properties.Resources.DefaultBrowserTitle; } else if (documentTitle.Length > 30) { documentTitle = documentTitle.Substring(0, 30) + "..."; } page.Text = documentTitle; // Set the full title as a tooltip page.ToolTipText = ewb.DocumentTitle; }
public BrowserControl() { InitializeComponent(); _browser = new ExtendedWebBrowser(); _browser.Dock = DockStyle.Fill; _browser.DownloadComplete += new EventHandler(_browser_DownloadComplete); _browser.Navigated += new WebBrowserNavigatedEventHandler(_browser_Navigated); _browser.StartNewWindow += new EventHandler <BrowserExtendedNavigatingEventArgs>(_browser_StartNewWindow); _browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(_browser_DocumentCompleted); _browser.ScriptErrorsSuppressed = scriptErrorsSuppressed; this.containerPanel.Controls.Add(_browser); // Make the magenta color transparent on the go button Bitmap bmp = (Bitmap)goButton.Image; bmp.MakeTransparent(Color.Magenta); _browser.BringToFront(); _browser.Visible = false; }
public 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 void Open(Uri url) { ExtendedWebBrowser browser = this.New(false); browser.Navigate(url); }
void _browser_StartNewWindow(object sender, BrowserExtendedNavigatingEventArgs e) { // Here we do the pop-up blocker work // Note that in Windows 2000 or lower this event will fire, but the // event arguments will not contain any useful information // for blocking pop-ups. // There are 4 filter levels. // None: Allow all pop-ups // Low: Allow pop-ups from secure sites // Medium: Block most pop-ups // High: Block all pop-ups (Use Ctrl to override) // We need the instance of the main form, because this holds the instance // to the WindowManager. if (mf == null) { mf = GetMainFormFromControl(this); } if (mf == null) { return; } // Allow a popup when there is no information available or when the Ctrl key is pressed bool allowPopup = (e.NavigationContext == UrlContext.None) || ((e.NavigationContext & UrlContext.OverrideKey) == UrlContext.OverrideKey); if (!allowPopup) { // Give None, Low & Medium still a chance. //switch (SettingsHelper.Current.FilterLevel) //{ // case PopupBlockerFilterLevel.None: // allowPopup = true; // break; // case PopupBlockerFilterLevel.Low: // // See if this is a secure site // if (this.WebBrowser.EncryptionLevel != WebBrowserEncryptionLevel.Insecure) // allowPopup = true; // else // // Not a secure site, handle this like the medium filter // goto case PopupBlockerFilterLevel.Medium; // break; // case PopupBlockerFilterLevel.Medium: // // This is the most dificult one. // // Only when the user first inited and the new window is user inited // if ((e.NavigationContext & UrlContext.UserFirstInited) == UrlContext.UserFirstInited && (e.NavigationContext & UrlContext.UserInited) == UrlContext.UserInited) // allowPopup = true; // break; //} } if (allowPopup) { // Check wheter it's a HTML dialog box. If so, allow the popup but do not open a new tab if (!((e.NavigationContext & UrlContext.HtmlDialog) == UrlContext.HtmlDialog)) { ExtendedWebBrowser ewb = mf.WindowManager.New(false); // The (in)famous application object e.AutomationObject = ewb.Application; } } else { // Here you could notify the user that the pop-up was blocked e.Cancel = true; } }
public void GoToURL(string URL, int refreshSeconds, int plusMinusRefreshSeconds, System.Windows.Forms.TextBox txtDisplay, ExtendedWebBrowser browser) { try { if (goToURLTimer.Tag == null) { goToURLTimer.Stop(); //this is how long before the link is clicked TimerInfo timerInfo = new TimerInfo(); timerInfo.StartTime = DateTime.Now; timerInfo.UrlToGoTo = URL; timerInfo.Duration = TimeSpan.FromSeconds(randomSeconds(refreshSeconds, plusMinusRefreshSeconds)); timerInfo.TxtDisplay = txtDisplay; timerInfo.Browser = browser; goToURLTimer.Tag = timerInfo; goToURLTimer.Tick += Timer_Tick; goToURLTimer.Start(); } } catch (Exception ex) { //Tools.WriteToFile(ex); throw; //Application.Restart(); } }
public void GoToURL(string URL, int refreshSeconds, System.Windows.Forms.TextBox txtDisplay, ExtendedWebBrowser browser) { GoToURL(URL, refreshSeconds, (int)(refreshSeconds / 4), txtDisplay, browser); }
public void GoToURL(string URL, System.Windows.Forms.TextBox txtDisplay, ExtendedWebBrowser browser) { GoToURL(URL, 12, txtDisplay, browser); }
public WebBrowserExtendedEvents(ExtendedWebBrowser browser) { _Browser = browser; }