public ExtendedWebBrowser New(bool navigateHome, TaskBrowser.IEItem ieItem = new TaskBrowser.IEItem()) { TabPage page = new TabPage(); ExtendedWebBrowser browser = new ExtendedWebBrowser(); 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.WebBrowser_DocumentTitleChanged); browser.Quit += new EventHandler(this.WebBrowser_Quit); page.Controls.Add(browser); if (navigateHome) { browser.GoHome(); } this.tabControl.TabPages.Add(page); this.tabControl.SelectedTab = page; return(browser); }
public void StartTaskThread(MyTask task) { this.StopTaskThread(); this._taskThreadRun = true; if (this._ieItem == null) { this._ieItem = new TaskBrowser.IEItem(this, task, this._waitFindTime, this._waitDocCompleteTime); this.New(true, this._ieItem); } }
public void TaskThreadFunc(object sender, EventArgs ea) { if (this._completedIeItem != null) { this.SendCompleteTask(this._completedIeItem.Task._id, this._completedIeItem.IsCompleted, this._completedIeItem.TaskInfoIndex, this._completedIeItem.ErrorString); this._completedIeItem = null; this._ieItem = null; Application.Exit(); } if ((this._ieItem != null) && this._ieItem.Update(this)) { this.CompleteIeItem(this._ieItem); } }
private void _browser_StartNavigate(object sender, BrowserExtendedNavigatingEventArgs ev) { ExtendedWebBrowser webBrowser = sender as ExtendedWebBrowser; if (!string.IsNullOrEmpty(webBrowser.Referer)) { LoadTempHtml.SetIEConnectionMode(true); } TaskBrowser.IEItem iEItem = this.GetIEItem(webBrowser); if (iEItem != null) { iEItem.SetDocCompleted(false); } }
private void _browser_StartNewWindow(object sender, BrowserExtendedNavigatingEventArgs ev) { try { if ((ev.NavigationContext & UrlContext.HtmlDialog) != UrlContext.HtmlDialog) { TaskBrowser.IEItem iEItem = this.GetIEItem(sender as ExtendedWebBrowser); ExtendedWebBrowser 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 { ExtendedWebBrowser webBrowser = sender as ExtendedWebBrowser; if (webBrowser != null) { if (ev.Url.Equals(webBrowser.Url)) { TaskBrowser.IEItem iEItem = this.GetIEItem(webBrowser); if (iEItem != null) { iEItem.SetDocCompleted(true); } } this.UpdateAddressBox(); } } catch { } }
public void CompleteIeItem(TaskBrowser.IEItem ieItem) { this._completedIeItem = ieItem; }