Example #1
0
        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;
            }

            TabPage page = bc.Tag as TabPage;

            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;
            }
        }
Example #2
0
        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 TabPage
            TabPage page = bc.Tag as TabPage;

            // 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));
            }
        }
Example #3
0
 private void PrintPreview()
 {
     Johnny.Controls.Windows.ExtendedWebBrowser.ExtendedWebBrowser brw = _windowManager.ActiveBrowser;
     if (brw != null)
     {
         brw.ShowPrintPreviewDialog();
     }
 }
        private void Print()
        {
            ExtendedWebBrowser brw = _windowManager.ActiveBrowser;

            if (brw != null)
            {
                brw.ShowPrintDialog();
            }
        }
 // File -> Open URL
 private void openUrlToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (OpenUrlForm ouf = new OpenUrlForm())
     {
         if (ouf.ShowDialog() == DialogResult.OK)
         {
             ExtendedWebBrowser brw = _windowManager.New(false);
             brw.Navigate(ouf.Url);
         }
     }
 }
Example #6
0
 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);
   this.containerPanel.Controls.Add(_browser);
   
   // Make the magenta color transparent on the go button
   Bitmap bmp = (Bitmap)goButton.Image;
   bmp.MakeTransparent(Color.Magenta);
 }
        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);
            this.containerPanel.Controls.Add(_browser);

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

            bmp.MakeTransparent(Color.Magenta);
        }
Example #8
0
        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 TabPage
            TabPage page = bc.Tag as TabPage;

            // 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;
        }
Example #9
0
        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);
        }
        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.
            MainWebForm mf = GetMainFormFromControl(sender as Control);

            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;
            }
        }
Example #11
0
 // File -> Open URL
 private void openUrlToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         using (OpenUrlForm ouf = new OpenUrlForm())
         {
             if (ouf.ShowDialog() == DialogResult.OK)
             {
                 Johnny.Controls.Windows.ExtendedWebBrowser.ExtendedWebBrowser brw = _windowManager.New(false);
                 brw.Navigate(ouf.Url);
             }
         }
     }
     catch (Exception ex)
     {
         Program.ShowMessageBox("FrmWebBrowser", ex);
     }
 }
Example #12
0
 public WebBrowserExtendedEvents(ExtendedWebBrowser browser) { _Browser = browser; }
Example #13
0
        public void Open(Uri url)
        {
            ExtendedWebBrowser browser = this.New(false);

            browser.Navigate(url);
        }
Example #14
0
    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;
    }
Example #15
0
 public WebBrowserExtendedEvents(ExtendedWebBrowser browser)
 {
     _Browser = browser;
 }