/// <summary> /// 检查是否有不存在的元素,如果有则修改状态为Faulted /// </summary> /// <param name="browser"></param> public void ValidateAction(csExWB.cEXWB browser) { foreach (ActionBase action in this) { string typeName = action.GetType().Name; if (typeName == "ActionClick" || typeName == "ActionSleep") { action.Status = StatusIndicators.StepContinue; continue; } ActionElementBase actionE = action as ActionElementBase; if (actionE != null) { action.Status = StatusIndicators.StepContinue; string id = actionE.ElementId; if (!string.IsNullOrEmpty(id)) { var e = browser.GetElementByID(false, id); if (e == null) { action.Status = StatusIndicators.StepFailure; } } } } }
private void PaintTab(TabPage tab) { tab.Controls.Clear(); tab.Controls.Add(new csExWB.cEXWB()); csExWB.cEXWB wb = tab.Controls[0] as csExWB.cEXWB; FunctionPage page = tab.Tag as FunctionPage; wb.Dock = DockStyle.Fill; wb.BeforeNavigate2 += new csExWB.BeforeNavigate2EventHandler(this.cEXWB1_BeforeNavigate2); string dirpath = "file:///" + wscript.AppDirectory.Replace("\\", "/") + "/Functions/"; page.PageSource = page.PageSource.Replace("%DIRPATH%/", dirpath); wb.LoadHtmlIntoBrowser(page.PageSource + "<div Id=Data style='display:none'>" + json + "</div>", dirpath); //wb.LoadHtmlIntoBrowser("page data"); for (int i = 0; i < page.scNotFoundAssemblies.Count; i++) { Button nfButton = new Button(); wb.Controls.Add(nfButton); nfButton.Height = 30; nfButton.Dock = DockStyle.Top; nfButton.TextAlign = ContentAlignment.MiddleLeft; nfButton.Text = string.Format("Cannot Find {0}", page.scNotFoundAssemblies[i]); nfButton.Tag = page.scNotFoundAssemblies[i]; nfButton.Click += new EventHandler(nfButton_Click); } }
private void cEXWB1_NewWindow3(object sender, csExWB.NewWindow3EventArgs e) { csExWB.cEXWB pWB = (csExWB.cEXWB)sender; if ((pWB != null) && (!pWB.RegisterAsBrowser)) { pWB.RegisterAsBrowser = true; } newfrm.AssignBrowserObject(ref e.browser); }
private void Form1_Load(object sender, EventArgs e) { //Form1.Name = Name; num = 0; fbrowser = cEXWB1; cEXWB1.RegisterAsBrowser = true; //panel1.Controls.Add(fbrowser); fbrowser.Navigate("www.google.com"); Task.Delay(5000); //ArrowProcess(); FastenalProcess(); }
public static void ReturnCWB(csExWB.cEXWB c) { lock (locker) { m_UsedCWB.Remove(c); if (CWBLifeCheck(c)) { m_AvailableCWB.Enqueue(c); } else { DisposeCWB(c); } } }
public static csExWB.cEXWB RentCWB() { lock (locker) { if (m_Enable) { if (m_AvailableCWB.Count <= 0) { PrepareCWB(); } csExWB.cEXWB c = m_AvailableCWB.Dequeue(); m_UsedCWB.Add(c); return(c); } return(null); } }
private static void PrepareCWB() { if (m_form.InvokeRequired) { m_form.Invoke(new PrepareCWBDelegator(PrepareCWB)); } else { for (int i = 1; i <= m_PreparedCWBNum; i++) { csExWB.cEXWB c = new csExWB.cEXWB(); c.Size = new System.Drawing.Size(50, 50); c.NavToBlank(); m_CWBCOUNTDICT.Add(c, 0); m_AvailableCWB.Enqueue(c); } } }
private static void DisposeCWB(csExWB.cEXWB c) { if (m_form.InvokeRequired) { log.Debug("Dispose CWB..."); m_form.BeginInvoke(new DisposeCWBDelegator(DisposeCWB), new object[] { c }); } else { try { c.Dispose(); } catch (Exception e) { log.Error(e); } } }
private static bool CWBLifeCheck(csExWB.cEXWB c) { if (m_CWBCOUNTDICT.ContainsKey(c)) { if (m_CWBCOUNTDICT[c] >= m_CWBLIFECOUNT) { m_CWBCOUNTDICT.Remove(c); return(false); } else { m_CWBCOUNTDICT[c] = m_CWBCOUNTDICT[c] + 1; return(true); } } else { log.Error("某浏览器对象的计数器元件未初始化!"); return(false); } }
/// <summary> /// Close all browsers except the first one from design time /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsMnuCloasAllWBs_Click(object sender, EventArgs e) { if (m_iCountWB == 1) return; try { foreach (ToolStripMenuItem item in ctxMnuOpenWBs.Items) { RemoveBrowser2(item.Name, false); } ctxMnuOpenWBs.Items.Clear(); m_CurWB = cEXWB1; m_CurWB.BringToFront(); m_CurWB.SetFocus(); m_tsBtnFirstTab.Checked = true; m_iCurTab = tsWBTabs.Items.IndexOf((ToolStripItem)m_tsBtnFirstTab); string text = m_CurWB.GetTitle(true); if (text.Length == 0) text = m_Blank; ToolStripMenuItem menu = new ToolStripMenuItem(text, m_imgUnLock); menu.Name = m_tsBtnFirstTab.Name; menu.Checked = true; ctxMnuOpenWBs.Items.Add((ToolStripItem)menu); m_iCurMenu = ctxMnuOpenWBs.Items.Count - 1; tsBtnOpenWBs.Text = m_iCountWB.ToString() + " open tab(s)"; } catch (Exception ee) { AllForms.m_frmLog.AppendToLog("tsMnuCloasAllWBs_Click\r\n" + ee.ToString()); } }
private void SwitchTabs(string name, ToolStripButton btn) { try { csExWB.cEXWB pWB = FindBrowser(name); if (pWB == null) return; //Uncheck last one if (m_iCountWB > 1) ((ToolStripButton)tsWBTabs.Items[m_iCurTab]).Checked = false; m_iCurTab = tsWBTabs.Items.IndexOf(btn); m_CurWB = pWB; tsBtnBack.Enabled = m_CurWB.CanGoBack; tsBtnForward.Enabled = m_CurWB.CanGoForward; m_CurWB.BringToFront(); m_CurWB.SetFocus(); this.Text = m_CurWB.GetTitle(true); if (this.Text.Length == 0) this.Text = m_Blank; if (btn != null) { btn.Checked = true; btn.Text = this.Text; if (btn.Text.Length > m_MaxTextLen) btn.Text = btn.Text.Substring(0, m_MaxTextLen) + "..."; btn.ToolTipText = HttpUtility.UrlDecode(m_CurWB.LocationUrl); this.comboURL.Text = btn.ToolTipText; } //Uncheck all menu items first foreach (ToolStripItem item in ctxMnuOpenWBs.Items) { if (item is ToolStripMenuItem) ((ToolStripMenuItem)item).Checked = false; } //Find target menu item ToolStripMenuItem menu = FindWBMenu(name); m_iCurMenu = ctxMnuOpenWBs.Items.IndexOf((ToolStripItem)menu); if (menu != null) { if (btn != null) menu.Text = btn.Text; menu.Checked = true; } //Reset and hide progressbar //If page is in the process of loading then the progressbar //will be adjusted tsProgress.Value = 0; tsProgress.Maximum = 0; tsProgress.Visible = false; //update SecureLockIcon state UpdateSecureLockIcon(m_CurWB.SecureLockIcon); } catch (Exception ee) { AllForms.m_frmLog.AppendToLog("SwitchingTabs\r\n" + ee.ToString()); } }
private bool AddNewBrowser(string TabText, string TabTooltip, string Url, bool BringToFront) { //Copy flags int iDochostUIFlag = (int)(DOCHOSTUIFLAG.NO3DBORDER | DOCHOSTUIFLAG.FLAT_SCROLLBAR | DOCHOSTUIFLAG.THEME); int iDocDlCltFlag = (int)(DOCDOWNLOADCTLFLAG.DLIMAGES | DOCDOWNLOADCTLFLAG.BGSOUNDS | DOCDOWNLOADCTLFLAG.VIDEOS); if (m_CurWB != null) { iDochostUIFlag = m_CurWB.WBDOCHOSTUIFLAG; iDocDlCltFlag = m_CurWB.WBDOCDOWNLOADCTLFLAG; } csExWB.cEXWB pWB = null; int i = m_iCountWB + 1; string sname = "cEXWB" + i.ToString(); try { ToolStripButton btn = new ToolStripButton(); btn.ImageAlign = ContentAlignment.MiddleCenter; btn.ImageScaling = ToolStripItemImageScaling.None; btn.TextAlign = ContentAlignment.TopLeft; btn.TextImageRelation = TextImageRelation.TextAboveImage; btn.Name = sname; if (TabText.Length > 0) btn.Text = TabText; else btn.Text = m_Blank; btn.Image = m_BlankImage; if (TabTooltip.Length > 0) btn.ToolTipText = TabTooltip; btn.AutoToolTip = true; btn.MouseUp += new MouseEventHandler(this.tsWBTabs_ToolStripButtonCtxMenuHandler); tsWBTabs.Items.Add(btn); //Create and setup browser pWB = new csExWB.cEXWB(); //pWB.Dock = cEXWB1.Dock; pWB.Anchor = cEXWB1.Anchor; pWB.Name = sname; pWB.Location = cEXWB1.Location; pWB.Size = cEXWB1.Size; pWB.RegisterAsBrowser = true; pWB.WBDOCDOWNLOADCTLFLAG = iDocDlCltFlag; pWB.WBDOCHOSTUIFLAG = iDochostUIFlag; pWB.FileDownloadDirectory = cEXWB1.FileDownloadDirectory; //Add events, using the same eventhandlers for all browsers pWB.TitleChange += new csExWB.TitleChangeEventHandler(this.cEXWB1_TitleChange); pWB.StatusTextChange += new csExWB.StatusTextChangeEventHandler(this.cEXWB1_StatusTextChange); pWB.CommandStateChange += new csExWB.CommandStateChangeEventHandler(this.cEXWB1_CommandStateChange); pWB.WBKeyDown += new csExWB.WBKeyDownEventHandler(this.cEXWB1_WBKeyDown); pWB.WBEvaluteNewWindow += new csExWB.EvaluateNewWindowEventHandler(this.cEXWB1_WBEvaluteNewWindow); pWB.BeforeNavigate2 += new csExWB.BeforeNavigate2EventHandler(this.cEXWB1_BeforeNavigate2); pWB.ProgressChange += new csExWB.ProgressChangeEventHandler(this.cEXWB1_ProgressChange); pWB.NavigateComplete2 += new csExWB.NavigateComplete2EventHandler(this.cEXWB1_NavigateComplete2); pWB.DownloadBegin += new csExWB.DownloadBeginEventHandler(this.cEXWB1_DownloadBegin); pWB.ScriptError += new csExWB.ScriptErrorEventHandler(this.cEXWB1_ScriptError); pWB.DownloadComplete += new csExWB.DownloadCompleteEventHandler(this.cEXWB1_DownloadComplete); pWB.StatusTextChange += new csExWB.StatusTextChangeEventHandler(this.cEXWB1_StatusTextChange); pWB.DocumentCompleteEX += new csExWB.DocumentCompleteExEventHandler(this.cEXWB1_DocumentCompleteEX); pWB.WBDragDrop += new csExWB.WBDropEventHandler(cEXWB1_WBDragDrop); pWB.SetSecureLockIcon += new csExWB.SetSecureLockIconEventHandler(this.cEXWB1_SetSecureLockIcon); pWB.NavigateError += new csExWB.NavigateErrorEventHandler(this.cEXWB1_NavigateError); pWB.WBSecurityProblem += new csExWB.SecurityProblemEventHandler(this.cEXWB1_WBSecurityProblem); pWB.NewWindow2 += new csExWB.NewWindow2EventHandler(this.cEXWB1_NewWindow2); pWB.DocumentComplete += new csExWB.DocumentCompleteEventHandler(this.cEXWB1_DocumentComplete); pWB.NewWindow3 += new csExWB.NewWindow3EventHandler(this.cEXWB1_NewWindow3); pWB.WBKeyUp += new csExWB.WBKeyUpEventHandler(this.cEXWB1_WBKeyUp); pWB.WindowClosing += new csExWB.WindowClosingEventHandler(this.cEXWB1_WindowClosing); pWB.WBContextMenu += new csExWB.ContextMenuEventHandler(this.cEXWB1_WBContextMenu); pWB.WBDocHostShowUIShowMessage += new csExWB.DocHostShowUIShowMessageEventHandler(this.cEXWB1_WBDocHostShowUIShowMessage); pWB.FileDownload += new csExWB.FileDownloadEventHandler(this.cEXWB1_FileDownload); pWB.WBAuthenticate += new csExWB.AuthenticateEventHandler(this.cEXWB1_WBAuthenticate); pWB.WBStop += new csExWB.StopEventHandler(cEXWB1_WBStop); pWB.FileDownloadExStart += new csExWB.FileDownloadExEventHandler(cEXWB1_FileDownloadExStart); pWB.FileDownloadExEnd += new csExWB.FileDownloadExEndEventHandler(cEXWB1_FileDownloadExEnd); pWB.FileDownloadExProgress += new csExWB.FileDownloadExProgressEventHandler(cEXWB1_FileDownloadExProgress); pWB.FileDownloadExError += new csExWB.FileDownloadExErrorEventHandler(cEXWB1_FileDownloadExError); pWB.FileDownloadExAuthenticate += new csExWB.FileDownloadExAuthenticateEventHandler(cEXWB1_FileDownloadExAuthenticate); pWB.FileDownloadExDownloadFileFullyWritten += new csExWB.FileDownloadExDownloadFileFullyWrittenEventHandler(cEXWB1_FileDownloadExDownloadFileFullyWritten); pWB.WBStop += new csExWB.StopEventHandler(cEXWB1_WBStop); //pWB.ProcessUrlAction += new csExWB.ProcessUrlActionEventHandler(cEXWB1_ProcessUrlAction); pWB.WBLButtonDown += new csExWB.HTMLMouseEventHandler(cEXWB1_WBLButtonDown); pWB.WBLButtonUp += new csExWB.HTMLMouseEventHandler(cEXWB1_WBLButtonUp); //pWB.WBMouseMove += new csExWB.HTMLMouseEventHandler(cEXWB1_WBMouseMove); ////pWB.RegisterAsBrowser = true; //Add to controls collection //this.Controls.Add(pWB); this.toolStripContainer1.ContentPanel.Controls.Add(pWB); ToolStripMenuItem menu = new ToolStripMenuItem(btn.Text, m_imgUnLock); menu.Name = sname; ctxMnuOpenWBs.Items.Add((ToolStripItem)menu); if (BringToFront) { //Uncheck last tab ((ToolStripButton)tsWBTabs.Items[m_iCurTab]).Checked = false; btn.Checked = true; ((ToolStripMenuItem)ctxMnuOpenWBs.Items[m_iCurMenu]).Checked = false; m_iCurMenu = ctxMnuOpenWBs.Items.Count - 1; menu.Checked = true; //Adjust current browser pointer m_CurWB = pWB; //Adjust current tab index m_iCurTab = tsWBTabs.Items.Count - 1; //Reset and hide progressbar tsProgress.Value = 0; tsProgress.Maximum = 0; tsProgress.Visible = false; //Bring to front pWB.BringToFront(); } //Increase count m_iCountWB++; tsBtnOpenWBs.Text = m_iCountWB.ToString() + " open tab(s)"; if (Url.Length > 0) pWB.Navigate(Url); } catch (Exception ee) { AllForms.m_frmLog.AppendToLog("AddNewBrowser\r\n" + ee.ToString()); return false; } return true; }
/// <summary> /// Removes the current browser and switches to the one before it /// if one is available, else the first one is selected /// </summary> /// <param name="name"></param> /// <returns></returns> private bool RemoveBrowser(string name) { bool bRet = false; //Do not remove the first browser if ((m_iCountWB == 1) || (name == m_tsBtnFirstTab.Name)) return bRet; tsProgress.Value = 0; tsProgress.Maximum = 0; tsProgress.Visible = false; ToolStripButton btn = FindTab(name); ToolStripButton nexttab = null; try { //find the first available btn before this one and switch foreach (ToolStripItem item in tsWBTabs.Items) { if (item.Name == btn.Name) { break; } if (item is ToolStripButton) nexttab = (ToolStripButton)item; } } catch (Exception ERemoveBrowser) { AllForms.m_frmLog.AppendToLog("RemoveBrowser\r\n" + ERemoveBrowser.ToString()); } try { tsWBTabs.Items.Remove((ToolStripItem)btn); btn.Dispose(); btn = null; } catch (Exception ERemoveBrowser1) { AllForms.m_frmLog.AppendToLog("RemoveBrowser1\r\n" + ERemoveBrowser1.ToString()); } try { csExWB.cEXWB pWB = FindBrowser(name); //Controls.Remove(pWB); this.toolStripContainer1.ContentPanel.Controls.Remove(pWB); pWB.Dispose(); pWB = null; } catch (Exception ERemoveBrowser2) { AllForms.m_frmLog.AppendToLog("RemoveBrowser2\r\n" + ERemoveBrowser2.ToString()); } ToolStripMenuItem menu = FindWBMenu(name); ToolStripMenuItem nextmenu = null; try { foreach (ToolStripItem titem in ctxMnuOpenWBs.Items) { if (titem.Name == menu.Name) { break; } if (titem is ToolStripMenuItem) nextmenu = (ToolStripMenuItem)titem; } ctxMnuOpenWBs.Items.Remove((ToolStripItem)menu); menu.Dispose(); menu = null; } catch (Exception ERemoveBrowser3) { AllForms.m_frmLog.AppendToLog("RemoveBrowser3\r\n" + ERemoveBrowser3.ToString()); } try { if (nexttab == null) { m_CurWB = cEXWB1; m_iCurTab = tsWBTabs.Items.IndexOf((ToolStripItem)m_tsBtnFirstTab); m_iCurMenu = 0; nexttab = m_tsBtnFirstTab; } else { m_CurWB = FindBrowser(nexttab.Name); m_iCurTab = tsWBTabs.Items.IndexOf((ToolStripItem)nexttab); m_iCurMenu = ctxMnuOpenWBs.Items.IndexOf((ToolStripItem)nextmenu); } this.Text = m_CurWB.GetTitle(true); if (this.Text.Length == 0) this.Text = m_Blank; this.comboURL.Text = nexttab.ToolTipText; nexttab.Checked = true; nextmenu.Checked = true; m_CurWB.BringToFront(); m_CurWB.SetFocus(); } catch (Exception ERemoveBrowser4) { AllForms.m_frmLog.AppendToLog("RemoveBrowser4\r\n" + ERemoveBrowser4.ToString()); } m_iCountWB--; tsBtnOpenWBs.Text = m_iCountWB.ToString() + " open tab(s)"; return bRet; }
private void frmMain_Load(object sender, EventArgs e) { try { mainToolStripMenuItem.Visible = false; SetupImages(); //Restricted //this.cEXWB1.WBDOCDOWNLOADCTLFLAG = (int)(DOCDOWNLOADCTLFLAG.NO_DLACTIVEXCTLS | //DOCDOWNLOADCTLFLAG.NO_FRAMEDOWNLOAD | DOCDOWNLOADCTLFLAG.NO_JAVA | //DOCDOWNLOADCTLFLAG.NO_RUNACTIVEXCTLS | DOCDOWNLOADCTLFLAG.NO_SCRIPTS | //DOCDOWNLOADCTLFLAG.NOFRAMES | DOCDOWNLOADCTLFLAG.PRAGMA_NO_CACHE | //DOCDOWNLOADCTLFLAG.NO_BEHAVIORS | DOCDOWNLOADCTLFLAG.NO_CLIENTPULL | //DOCDOWNLOADCTLFLAG.SILENT); // //To activate autocomplete // this.cEXWB1.WBDOCHOSTUIFLAG = (int)(DOCHOSTUIFLAG.NO3DBORDER | //DOCHOSTUIFLAG.FLAT_SCROLLBAR | DOCHOSTUIFLAG.THEME | //DOCHOSTUIFLAG.ENABLE_FORMS_AUTOCOMPLETE); this.cEXWB1.DownloadComplete += new csExWB.DownloadCompleteEventHandler(this.cEXWB1_DownloadComplete); this.cEXWB1.DocumentComplete += new csExWB.DocumentCompleteEventHandler(this.cEXWB1_DocumentComplete); this.cEXWB1.TitleChange += new csExWB.TitleChangeEventHandler(this.cEXWB1_TitleChange); this.cEXWB1.NewWindow2 += new csExWB.NewWindow2EventHandler(this.cEXWB1_NewWindow2); this.cEXWB1.ScriptError += new csExWB.ScriptErrorEventHandler(this.cEXWB1_ScriptError); this.cEXWB1.WBKeyDown += new csExWB.WBKeyDownEventHandler(this.cEXWB1_WBKeyDown); this.cEXWB1.WindowClosing += new csExWB.WindowClosingEventHandler(this.cEXWB1_WindowClosing); this.cEXWB1.DocumentCompleteEX += new csExWB.DocumentCompleteExEventHandler(this.cEXWB1_DocumentCompleteEX); this.cEXWB1.NewWindow3 += new csExWB.NewWindow3EventHandler(this.cEXWB1_NewWindow3); this.cEXWB1.WBSecurityProblem += new csExWB.SecurityProblemEventHandler(this.cEXWB1_WBSecurityProblem); this.cEXWB1.WBKeyUp += new csExWB.WBKeyUpEventHandler(this.cEXWB1_WBKeyUp); this.cEXWB1.WBContextMenu += new csExWB.ContextMenuEventHandler(this.cEXWB1_WBContextMenu); this.cEXWB1.FileDownload += new csExWB.FileDownloadEventHandler(this.cEXWB1_FileDownload); this.cEXWB1.StatusTextChange += new csExWB.StatusTextChangeEventHandler(this.cEXWB1_StatusTextChange); this.cEXWB1.WBDragDrop += new csExWB.WBDropEventHandler(this.cEXWB1_WBDragDrop); this.cEXWB1.WBDocHostShowUIShowMessage += new csExWB.DocHostShowUIShowMessageEventHandler(this.cEXWB1_WBDocHostShowUIShowMessage); this.cEXWB1.SetSecureLockIcon += new csExWB.SetSecureLockIconEventHandler(this.cEXWB1_SetSecureLockIcon); this.cEXWB1.DownloadBegin += new csExWB.DownloadBeginEventHandler(this.cEXWB1_DownloadBegin); this.cEXWB1.NavigateComplete2 += new csExWB.NavigateComplete2EventHandler(this.cEXWB1_NavigateComplete2); this.cEXWB1.WBEvaluteNewWindow += new csExWB.EvaluateNewWindowEventHandler(this.cEXWB1_WBEvaluteNewWindow); this.cEXWB1.WBAuthenticate += new csExWB.AuthenticateEventHandler(this.cEXWB1_WBAuthenticate); this.cEXWB1.RefreshEnd += new csExWB.RefreshEndEventHandler(this.cEXWB1_RefreshEnd); this.cEXWB1.NavigateError += new csExWB.NavigateErrorEventHandler(this.cEXWB1_NavigateError); this.cEXWB1.BeforeNavigate2 += new csExWB.BeforeNavigate2EventHandler(this.cEXWB1_BeforeNavigate2); this.cEXWB1.RefreshBegin += new csExWB.RefreshBeginEventHandler(this.cEXWB1_RefreshBegin); this.cEXWB1.CommandStateChange += new csExWB.CommandStateChangeEventHandler(this.cEXWB1_CommandStateChange); this.cEXWB1.ProgressChange += new csExWB.ProgressChangeEventHandler(this.cEXWB1_ProgressChange); this.cEXWB1.FileDownloadExStart += new csExWB.FileDownloadExEventHandler(this.cEXWB1_FileDownloadExStart); this.cEXWB1.FileDownloadExEnd += new csExWB.FileDownloadExEndEventHandler(this.cEXWB1_FileDownloadExEnd); this.cEXWB1.FileDownloadExProgress += new csExWB.FileDownloadExProgressEventHandler(this.cEXWB1_FileDownloadExProgress); this.cEXWB1.FileDownloadExError += new csExWB.FileDownloadExErrorEventHandler(this.cEXWB1_FileDownloadExError); this.cEXWB1.FileDownloadExAuthenticate += new csExWB.FileDownloadExAuthenticateEventHandler(this.cEXWB1_FileDownloadExAuthenticate); this.cEXWB1.FileDownloadExDownloadFileFullyWritten += new csExWB.FileDownloadExDownloadFileFullyWrittenEventHandler(cEXWB1_FileDownloadExDownloadFileFullyWritten); this.cEXWB1.WBStop += new csExWB.StopEventHandler(cEXWB1_WBStop); //this.cEXWB1.ProcessUrlAction += new csExWB.ProcessUrlActionEventHandler(cEXWB1_ProcessUrlAction); this.cEXWB1.WBLButtonDown += new csExWB.HTMLMouseEventHandler(cEXWB1_WBLButtonDown); this.cEXWB1.WBLButtonUp += new csExWB.HTMLMouseEventHandler(cEXWB1_WBLButtonUp); //this.cEXWB1.WBMouseMove += new csExWB.HTMLMouseEventHandler(cEXWB1_WBMouseMove); cEXWB1.RegisterAsBrowser = true; cEXWB1.FileDownloadDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + System.IO.Path.DirectorySeparatorChar.ToString(); this.cEXWB1.NavToBlank(); //Add first tab string sname = cEXWB1.Name; m_tsBtnFirstTab = new ToolStripButton(); m_tsBtnFirstTab.ImageScaling = ToolStripItemImageScaling.None; m_tsBtnFirstTab.ImageAlign = ContentAlignment.MiddleCenter; m_tsBtnFirstTab.TextAlign = ContentAlignment.TopLeft; m_tsBtnFirstTab.TextImageRelation = TextImageRelation.TextAboveImage; m_tsBtnFirstTab.Name = sname; m_tsBtnFirstTab.Text = m_Blank; m_tsBtnFirstTab.Image = m_BlankImage; m_tsBtnFirstTab.ToolTipText = m_AboutBlank; m_tsBtnFirstTab.Checked = true; m_tsBtnFirstTab.MouseUp += new MouseEventHandler(this.tsWBTabs_ToolStripButtonCtxMenuHandler); tsWBTabs.Items.Add((ToolStripItem)m_tsBtnFirstTab); //Take note of current WB and first toolstripbutton index m_CurWB = cEXWB1; m_iCurTab = tsWBTabs.Items.Count - 1; //Add menu ToolStripMenuItem menu = new ToolStripMenuItem(m_Blank, m_imgUnLock); menu.Name = sname; menu.Checked = true; ctxMnuOpenWBs.Items.Add((ToolStripItem)menu); m_iCurMenu = ctxMnuOpenWBs.Items.Count - 1; m_frmFind.Icon = AllForms.BitmapToIcon(30); //form find callback m_frmFind.FindInPageEvent += new FindInPage(m_frmFind_FindInPageEvent); //Start watching favorites folder fswFavorites.Path = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); //Load favorites LoadFavoriteMenuItems(); //Fill up the screen this.WindowState = FormWindowState.Maximized; } catch (Exception ee) { MessageBox.Show("frmMain_Load Failed\r\n" + ee.ToString()); } }
/// <summary> /// Loads document information into the Tree /// Uses each node.Tag to store information /// </summary> /// <param name="pWB">An instance of csExWB.cEXWB</param> public void LoadDocumentInfo(csExWB.cEXWB pWB) { treeDocInfo.Nodes.Clear(); txtDocInfo.Clear(); IHTMLDocument2 doc2 = null; //First fill in the main document information TreeNode root = treeDocInfo.Nodes.Add("Main Document"); TreeNode node = root.Nodes.Add("HTML"); TreeNode subnode = node.Nodes.Add("Title"); subnode.Tag = pWB.GetTitle(true); doc2 = (IHTMLDocument2)pWB.WebbrowserObject.Document; subnode = node.Nodes.Add("URL"); subnode.Tag = doc2.url; subnode = node.Nodes.Add("Domain"); subnode.Tag = doc2.domain; subnode = node.Nodes.Add("Protocol"); subnode.Tag = doc2.protocol; subnode = node.Nodes.Add("Cookie"); subnode.Tag = doc2.cookie; subnode = node.Nodes.Add("Referrer"); subnode.Tag = doc2.referrer; subnode = node.Nodes.Add("Last Modified"); subnode.Tag = doc2.lastModified; subnode = node.Nodes.Add("Source"); subnode.Tag = pWB.GetSource(true); subnode = node.Nodes.Add("Text"); subnode.Tag = pWB.GetText(true); //or pWB.GetImages(true); IHTMLElementCollection elems = (IHTMLElementCollection)doc2.images; subnode = node.Nodes.Add("Images"); IHTMLImgElement img = null; string str = string.Empty; foreach (IHTMLElement elem in elems) { if (elem != null) { img = (IHTMLImgElement)elem; str += Environment.NewLine + img.src; } } subnode.Tag = str; // //Other collections // //elems = (IHTMLElementCollection)doc2.anchors; //subnode = node.Nodes.Add("Links"); //elems = (IHTMLElementCollection)doc2.scripts; //subnode = node.Nodes.Add("Java Scripts"); //IHTMLMetaElement meta = null; //IHTMLElementCollection col = (IHTMLElementCollection)pWB.GetElementsByTagName(true, "meta"); //foreach (IHTMLElement elem in col) //{ // meta = (IHTMLMetaElement)elem; // if (meta != null) // { // AllForms.m_frmLog.AppendToLog("\r\nhttpEquiv=" + meta.httpEquiv + "\r\nname=" + meta.name + // "\r\nurl=" + meta.url + "\r\ncharset=" + meta.charset + "\r\ncontent=" + meta.content); // } // meta = null; //} //If frameset, we add the frames if (pWB.IsFrameset()) { TreeNode framenode = root.Nodes.Add("FRAMES"); List <IWebBrowser2> frames = pWB.GetFrames(); foreach (IWebBrowser2 wb in frames) { node = framenode.Nodes.Add("HTML"); subnode = node.Nodes.Add("Title"); subnode.Tag = pWB.GetTitle(wb); doc2 = (IHTMLDocument2)wb.Document; subnode = node.Nodes.Add("URL"); subnode.Tag = doc2.url; subnode = node.Nodes.Add("Domain"); subnode.Tag = doc2.domain; subnode = node.Nodes.Add("Protocol"); subnode.Tag = doc2.protocol; subnode = node.Nodes.Add("Cookie"); subnode.Tag = doc2.cookie; subnode = node.Nodes.Add("Referrer"); subnode.Tag = doc2.referrer; subnode = node.Nodes.Add("Last Modified"); subnode.Tag = doc2.lastModified; subnode = node.Nodes.Add("Source"); subnode.Tag = pWB.GetSource(wb); subnode = node.Nodes.Add("Text"); subnode.Tag = pWB.GetText(wb); } } //Expand the root root.Expand(); }