public ExtendedTenDayBrowser New(bool navigateHome, IEItem ieItem)
        {
            TabPage page = new TabPage();
            ExtendedTenDayBrowser browser = new ExtendedTenDayBrowser();

            if (ieItem != null)
            {
                ieItem.AddBrowser(browser);
            }
            page.Text                     = "新建窗口";
            page.Tag                      = browser;
            browser.Tag                   = page;
            browser.Dock                  = DockStyle.Fill;
            browser.DownloadComplete     += new EventHandler(this._browser_DownloadComplete);
            browser.StartNavigate        += new EventHandler <BrowserExtendedNavigatingEventArgs>(this._browser_StartNavigate);
            browser.StartNewWindow       += new EventHandler <BrowserExtendedNavigatingEventArgs>(this._browser_StartNewWindow);
            browser.DocumentCompleted    += new WebBrowserDocumentCompletedEventHandler(this._browser_DocumentCompleted);
            browser.StatusTextChanged    += new EventHandler(this._browser_StatusTextChanged);
            browser.DocumentTitleChanged += new EventHandler(this.TenDayBrowser_DocumentTitleChanged);
            browser.Quit                 += new EventHandler(this.TenDayBrowser_Quit);
            page.Controls.Add(browser);
            if (navigateHome)
            {
                browser.GoHome();
            }
            this.tabControl.TabPages.Add(page);
            this.tabControl.SelectedTab = page;
            return(browser);
        }
        private void TenDayBrowser_DocumentTitleChanged(object sender, EventArgs e)
        {
            ExtendedTenDayBrowser browser = sender as ExtendedTenDayBrowser;

            if (browser != null)
            {
                TabPage tag = browser.Tag as TabPage;
                if (tag != null)
                {
                    try
                    {
                        string documentTitle = browser.DocumentTitle;
                        if (string.IsNullOrEmpty(documentTitle))
                        {
                            documentTitle = "新建窗口";
                        }
                        else if (documentTitle.Length > 30)
                        {
                            documentTitle = documentTitle.Substring(0, 30) + "...";
                        }
                        tag.Text        = documentTitle;
                        tag.ToolTipText = browser.DocumentTitle;
                    }
                    catch
                    {
                    }
                }
            }
        }
        public void TenDayBrowser_Quit(object sender, EventArgs e)
        {
            ExtendedTenDayBrowser browser = sender as ExtendedTenDayBrowser;

            if (browser != null)
            {
                this.Remove(browser);
            }
        }
 public void Remove(ExtendedTenDayBrowser browser)
 {
     if (browser != null)
     {
         TabPage tag = browser.Tag as TabPage;
         if (tag != null)
         {
             this.tabControl.TabPages.Remove(tag);
             tag.Dispose();
         }
     }
 }
 private void _browser_StatusTextChanged(object sender, EventArgs ex)
 {
     try
     {
         ExtendedTenDayBrowser browser = sender as ExtendedTenDayBrowser;
         if (browser != null)
         {
             this.ShowTip3(browser.StatusText);
         }
     }
     catch
     {
     }
 }
 private IEItem GetIEItem(ExtendedTenDayBrowser TenDayBrowser)
 {
     if ((TenDayBrowser != null) && (this._ieItem != null))
     {
         foreach (ExtendedTenDayBrowser browser in this._ieItem.Browsers)
         {
             if (browser.Equals(TenDayBrowser))
             {
                 return(this._ieItem);
             }
         }
     }
     return(null);
 }
        private void _browser_StartNavigate(object sender, BrowserExtendedNavigatingEventArgs ev)
        {
            ExtendedTenDayBrowser TenDayBrowser = sender as ExtendedTenDayBrowser;

            if (!string.IsNullOrEmpty(TenDayBrowser.Referer))
            {
                LoadTempHtml.SetIEConnectionMode(true);
            }
            IEItem iEItem = this.GetIEItem(TenDayBrowser);

            if (iEItem != null)
            {
                iEItem.SetDocCompleted(false);
            }
        }
 public void UpdateAddressBox()
 {
     try
     {
         ExtendedTenDayBrowser activeBrowser = this.ActiveBrowser;
         if (((activeBrowser != null) && (activeBrowser.Document != null)) && (activeBrowser.Document.Url != null))
         {
             string str = activeBrowser.Document.Url.ToString();
             this.ShowUrl(str);
         }
     }
     catch
     {
     }
 }
        private void TabControlDoubleClick(object sender, MouseEventArgs e)
        {
            TabControl control = sender as TabControl;

            if (control != null)
            {
                TabPage selectedTab = control.SelectedTab;
                if (selectedTab != null)
                {
                    ExtendedTenDayBrowser tag = selectedTab.Tag as ExtendedTenDayBrowser;
                    if (tag != null)
                    {
                        this.Remove(tag);
                    }
                }
            }
        }
 private void _browser_StartNewWindow(object sender, BrowserExtendedNavigatingEventArgs ev)
 {
     try
     {
         if ((ev.NavigationContext & UrlContext.HtmlDialog) != UrlContext.HtmlDialog)
         {
             IEItem iEItem = this.GetIEItem(sender as ExtendedTenDayBrowser);
             ExtendedTenDayBrowser browser = this.New(false, null);
             if (iEItem != null)
             {
                 iEItem.AddBrowser(browser);
             }
             iEItem = null;
             ev.AutomationObject = browser.Application;
         }
     }
     catch (Exception)
     {
     }
 }
 private void _browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs ev)
 {
     try
     {
         ExtendedTenDayBrowser TenDayBrowser = sender as ExtendedTenDayBrowser;
         if (TenDayBrowser != null)
         {
             if (ev.Url.Equals(TenDayBrowser.Url))
             {
                 IEItem iEItem = this.GetIEItem(TenDayBrowser);
                 if (iEItem != null)
                 {
                     iEItem.SetDocCompleted(true);
                 }
             }
             this.UpdateAddressBox();
         }
     }
     catch
     {
     }
 }
 private void _browser_DownloadComplete(object sender, EventArgs ex)
 {
     try
     {
         ExtendedTenDayBrowser browser = sender as ExtendedTenDayBrowser;
         if (browser != null)
         {
             if (!string.IsNullOrEmpty(browser.Referer))
             {
                 LoadTempHtml.SetIEConnectionMode(false);
                 browser.Referer = string.Empty;
             }
             if (browser.Document != null)
             {
                 browser.Document.Window.Error += new HtmlElementErrorEventHandler(this.Window_Error);
                 this.UpdateAddressBox();
             }
         }
     }
     catch
     {
     }
 }
 public TenDayBrowserExtendedEvents(ExtendedTenDayBrowser browser)
 {
     this._Browser = browser;
 }
Exemple #14
0
        public bool VisitCompare(TenDayBrowser parent, string compareTime, string compareIndex, string tagStr, string indexStr)
        {
            bool flag = false;
            if ((this._curTenDayBrowser != null) && (this._curTenDayBrowser.Document != null))
            {
                mshtml.IHTMLDocument2 domDocument = (mshtml.IHTMLDocument2)this._curTenDayBrowser.Document.DomDocument;
                IntPtr windowHwnd = GetWindowHwnd(this._curTenDayBrowser.Handle.ToInt32());
                try
                {
                    if (shouldScroll)
                    {
                        int height = _curTenDayBrowser.Document.Body.ScrollRectangle.Height;
                        if (!isScrollUp)
                        {
                            scrollPos += height / 30;
                            if (scrollPos >= height)
                            {
                                scrollPos = height;
                                isScrollUp = true;
                            }
                        }
                        else
                        {
                            scrollPos -= height / 30;
                            if (scrollPos <= 0)
                            {
                                scrollPos = 0;
                                isScrollUp = false;
                            }
                        }
                        _curTenDayBrowser.Document.Window.ScrollTo(new Point(0, scrollPos));
                    }
                }
                catch (System.Exception ex)
                {
                    //
                }

                parent.ShowTip2(string.Concat(new object[] { "货比第 ", compareIndex, " 家" }));
            }
            if (this.IsPageTimeOut(int.Parse(compareTime)))
            {
                TabPage seltab = parent.TabControl.SelectedTab;
                int seltabindex = parent.TabControl.SelectedIndex;
                if (seltabindex > 0)
                {
                    ExtendedTenDayBrowser seltabBroswer = _browsers[seltabindex] as ExtendedTenDayBrowser;

                    parent.TabControl.Controls.Remove(seltab);
                    _browsers.Remove(seltabBroswer);
                    _curTenDayBrowser = _browsers[seltabindex - 1] as ExtendedTenDayBrowser;

                    //seltab.Dispose();
                    //seltabBroswer.Dispose();
                    this._inputIndex = -1;
                    parent.ShowTip2("货比三家结束");
                    flag = true;
                }

            }
            return flag;
        }
 public ExtendedTenDayBrowser New(bool navigateHome, IEItem ieItem)
 {
     TabPage page = new TabPage();
     ExtendedTenDayBrowser browser = new ExtendedTenDayBrowser();
     if (ieItem != null)
     {
         ieItem.AddBrowser(browser);
     }
     page.Text = "新建窗口";
     page.Tag = browser;
     browser.Tag = page;
     browser.Dock = DockStyle.Fill;
     browser.DownloadComplete += new EventHandler(this._browser_DownloadComplete);
     browser.StartNavigate += new EventHandler<BrowserExtendedNavigatingEventArgs>(this._browser_StartNavigate);
     browser.StartNewWindow += new EventHandler<BrowserExtendedNavigatingEventArgs>(this._browser_StartNewWindow);
     browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(this._browser_DocumentCompleted);
     browser.StatusTextChanged += new EventHandler(this._browser_StatusTextChanged);
     browser.DocumentTitleChanged += new EventHandler(this.TenDayBrowser_DocumentTitleChanged);
     browser.Quit += new EventHandler(this.TenDayBrowser_Quit);
     page.Controls.Add(browser);
     if (navigateHome)
     {
         browser.GoHome();
     }
     this.tabControl.TabPages.Add(page);
     this.tabControl.SelectedTab = page;
     return browser;
 }
 public void Remove(ExtendedTenDayBrowser browser)
 {
     if (browser != null)
     {
         TabPage tag = browser.Tag as TabPage;
         if (tag != null)
         {
             this.tabControl.TabPages.Remove(tag);
             tag.Dispose();
         }
     }
 }
 private IEItem GetIEItem(ExtendedTenDayBrowser TenDayBrowser)
 {
     if ((TenDayBrowser != null) && (this._ieItem != null))
     {
         foreach (ExtendedTenDayBrowser browser in this._ieItem.Browsers)
         {
             if (browser.Equals(TenDayBrowser))
             {
                 return this._ieItem;
             }
         }
     }
     return null;
 }
Exemple #18
0
 public void AddBrowser(ExtendedTenDayBrowser browser)
 {
     this._curTenDayBrowser = browser;
     this._curTenDayBrowser.HandleDestroyed += new EventHandler(this.OnCloseBrowser);
     this._browsers.Add(this._curTenDayBrowser);
     this.ResetBrowserComplete();
 }
 public TenDayBrowserExtendedEvents(ExtendedTenDayBrowser browser)
 {
     this._Browser = browser;
 }