Esempio n. 1
0
 private void RegisterEvent(cEXWB WebBrower)
 {
     WebBrower.DocumentComplete += new DocumentCompleteEventHandler(WebBrower_DocumentComplete);
     WebBrower.WBLButtonDown    += new csExWB.HTMLMouseEventHandler(WebBrower_WBLButtonDown);
     WebBrower.WBLButtonUp      += new csExWB.HTMLMouseEventHandler(WebBrower_WBLButtonUp);
     WebBrower.NewWindow2       += new NewWindow2EventHandler(WebBrower_NewWindow2);
 }
Esempio n. 2
0
        private void ShowDialog(IHTMLElement el)
        {
            cEXWB webBrowser = AppContext.Browser as cEXWB;

            if (webBrowser.InvokeRequired)
            {
                webBrowser.Invoke(new Action(Perform));
                return;
            }
            ValidateCodeDialog dialog = new ValidateCodeDialog(webBrowser, el);

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                InputValue = dialog.ValidateCode;
            }
        }
Esempio n. 3
0
 private void WebBrower_WBOnDocumentChanged(object sender, EventArgs e)
 {
     try
     {
         cEXWB pWB = sender as cEXWB;
         if (pWB != null)
         {
             //Logger.Log(LogLevel.Info, ">>>>>>WBOnDocumentChanged=>"+pWB.SendSourceOnDocumentCompleteWBEx);
         }
         //Debug.Print(">>>>>>WBOnDocumentChanged=>");
     }
     catch (System.ObjectDisposedException)
     {
         Logger.Log(LogLevel.Info, "WBOnDocumentChanged::System.ObjectDisposedException");
         //Debug.Print("WBOnDocumentChanged::System.ObjectDisposedException");
     }
 }
Esempio n. 4
0
        public void Setup(cEXWB wb)
        {
            this.WB = wb;
            if (this.WB == null)
            {
                return;
            }

            this.SetupWebBrower(this.WB);
            this.RegiserWebBrowerHandler(this.WB);

            // need to initialize the webbrowser control by calling NavToBlank() at least once
            this.WB.NavToBlank();
            if (this.HttpRequestUrls == null)
            {
                this.HttpRequestUrls = new List <string>();
            }
        }
Esempio n. 5
0
        public override void Perform()
        {
            cEXWB webBrowser = AppContext.Browser as cEXWB;

            if (webBrowser.InvokeRequired)
            {
                webBrowser.Invoke(new Action(Perform));
                return;
            }
            bool exists = Window.Elements.Exists(GetConstraint());

            if (exists)
            {
                Element element = GetElement();
                //弹出对话框输验证码
                if (ValidateImage != null && !string.IsNullOrEmpty(ValidateImage.InputValue))
                {
                    TextToType = ValidateImage.InputValue;
                    base.Perform();
                }
                else if (IsMobileValidate)
                {
                    ValidateCodeDialog dialog = new ValidateCodeDialog(webBrowser);
                    dialog.Activate();
                    dialog.WindowState = System.Windows.Forms.FormWindowState.Normal;
                    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        if (!string.IsNullOrEmpty(dialog.ValidateCode))
                        {
                            TextToType = dialog.ValidateCode;
                            base.Perform();
                        }
                    }
                }
                else //在浏览器里面输验证码
                {
                    //var nativeElement = element.NativeElement as IEElement;
                    //nativeElement.AsHtmlElement.scrollIntoView();
                    //webBrowser.WBKeyDown -= new WBKeyDownEventHandler(webBrowser_WBKeyDown);
                    //webBrowser.WBKeyDown += new WBKeyDownEventHandler(webBrowser_WBKeyDown);
                    //this.Breakpoint = BreakpointIndicators.ActiveBreakpoint;
                }
            }
        }
Esempio n. 6
0
        public Form1()
        {
            this.cEXWB1        = new csExWB.cEXWB();
            this.cEXWB1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                        | System.Windows.Forms.AnchorStyles.Left)
                                                                       | System.Windows.Forms.AnchorStyles.Right)));
            this.cEXWB1.Border3DEnabled       = false;
            this.cEXWB1.DocumentSource        = "<HTML><HEAD></HEAD>\r\n<BODY></BODY></HTML>";
            this.cEXWB1.DocumentTitle         = "";
            this.cEXWB1.DownloadActiveX       = true;
            this.cEXWB1.DownloadFrames        = true;
            this.cEXWB1.DownloadImages        = true;
            this.cEXWB1.DownloadJava          = true;
            this.cEXWB1.DownloadScripts       = true;
            this.cEXWB1.DownloadSounds        = true;
            this.cEXWB1.DownloadVideo         = true;
            this.cEXWB1.FileDownloadDirectory = "C:\\DEV\\";
            this.cEXWB1.Location                         = new System.Drawing.Point(4, 212);
            this.cEXWB1.LocationUrl                      = "about:blank";
            this.cEXWB1.Name                             = "cEXWB1";
            this.cEXWB1.ObjectForScripting               = null;
            this.cEXWB1.OffLine                          = false;
            this.cEXWB1.RegisterAsBrowser                = false;
            this.cEXWB1.RegisterAsDropTarget             = false;
            this.cEXWB1.RegisterForInternalDragDrop      = true;
            this.cEXWB1.ScrollBarsEnabled                = true;
            this.cEXWB1.SendSourceOnDocumentCompleteWBEx = false;
            this.cEXWB1.Silent                           = false;
            this.cEXWB1.Size                             = new System.Drawing.Size(1000, 528);
            this.cEXWB1.TabIndex                         = 25;
            this.cEXWB1.Text                             = "cEXWB1";
            this.cEXWB1.TextSize                         = IfacesEnumsStructsClasses.TextSizeWB.Medium;
            this.cEXWB1.UseInternalDownloadManager       = true;
            this.cEXWB1.WBDOCDOWNLOADCTLFLAG             = 112;
            this.cEXWB1.WBDOCHOSTUIDBLCLK                = IfacesEnumsStructsClasses.DOCHOSTUIDBLCLK.DEFAULT;
            this.cEXWB1.WBDOCHOSTUIFLAG                  = 262276;
            this.cEXWB1.DocumentComplete                += new csExWB.DocumentCompleteEventHandler(this.cEXWB1_DocumentComplete);

            InitializeComponent();
        }
Esempio n. 7
0
 /// <summary>
 /// 初始化浏览器组件
 /// </summary>
 /// <param name="wb"></param>
 private void SetupWebBrower(cEXWB wb)
 {
     //wb.WBDOCDOWNLOADCTLFLAG = (int)(
     //    DOCDOWNLOADCTLFLAG.NO_SCRIPTS |
     //    DOCDOWNLOADCTLFLAG.NO_DLACTIVEXCTLS |
     //    DOCDOWNLOADCTLFLAG.NO_JAVA |
     //    DOCDOWNLOADCTLFLAG.NO_RUNACTIVEXCTLS |
     //    DOCDOWNLOADCTLFLAG.PRAGMA_NO_CACHE |
     //    DOCDOWNLOADCTLFLAG.SILENT);
     wb.DownloadSounds    = false;
     wb.DownloadVideo     = false;
     wb.DownloadActiveX   = false;
     wb.DownloadFrames    = false;
     wb.DownloadImages    = false;
     wb.DownloadScripts   = true;
     wb.Border3DEnabled   = false;
     wb.ScrollBarsEnabled = false;
     wb.Silent            = false;//whether the Webbrowser control can show dialog boxes
     //wb.FileDownloadDirectory = "C:\\Documents and Settings\\Mike\\My Documents\\";
     wb.FileDownloadDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + System.IO.Path.DirectorySeparatorChar.ToString();
     //wb.UseInternalDownloadManager = true;
 }
Esempio n. 8
0
        private void InitWebBrower()
        {
            WebBrower = new cEXWB();

            this.WebBrower.Border3DEnabled = false;
            //this.WebBrower.DocumentSource = "<HTML><HEAD></HEAD>\r\n<BODY></BODY></HTML>";
            this.WebBrower.DocumentTitle = "";
            //this.WebBrower.DownloadActiveX = false;
            //this.WebBrower.DownloadFrames = true;
            //this.WebBrower.DownloadImages = true;
            //this.WebBrower.DownloadJava = true;
            //this.WebBrower.DownloadScripts = true;
            //this.WebBrower.DownloadSounds = false;
            //this.WebBrower.DownloadVideo = false;
            this.WebBrower.FileDownloadDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + System.IO.Path.DirectorySeparatorChar.ToString();
            this.WebBrower.Location                         = new Point(5, 38);
            this.WebBrower.LocationUrl                      = "about:blank";
            this.WebBrower.Name                             = "WebBrower";
            this.WebBrower.ObjectForScripting               = null;
            this.WebBrower.OffLine                          = false;
            this.WebBrower.RegisterAsBrowser                = true;
            this.WebBrower.RegisterAsDropTarget             = false;
            this.WebBrower.RegisterForInternalDragDrop      = true;
            this.WebBrower.ScrollBarsEnabled                = true;
            this.WebBrower.SendSourceOnDocumentCompleteWBEx = false;
            this.WebBrower.Silent                           = false;
            this.WebBrower.Size                             = new Size(749, 449);
            this.WebBrower.TabIndex                         = 0;
            this.WebBrower.Text                             = "WebBrower";
            this.WebBrower.TextSize                         = IfacesEnumsStructsClasses.TextSizeWB.Medium;
            this.WebBrower.UseInternalDownloadManager       = true;
            this.WebBrower.WBDOCDOWNLOADCTLFLAG             = 112;
            this.WebBrower.WBDOCHOSTUIDBLCLK                = IfacesEnumsStructsClasses.DOCHOSTUIDBLCLK.DEFAULT;
            this.WebBrower.WBDOCHOSTUIFLAG                  = 262276;
            this.WebBrower.Anchor                           = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            this.WebBrower.Dock                             = DockStyle.Fill;
            this.WebBrower.NavToBlank();
            this.WebBrower.Navigate("http://finance.qq.com/a/20121223/000025.htm?pgv_ref=aio2012&ptlang=2052");
        }
Esempio n. 9
0
        /*
         * When e.isTopLevel parameter of DocumentComplete is true, it means that the main document has finished loading whether we have a frameset or not.
         * In a frameset page, DocumentComplete is fired for every frame. In the case of a frame, e.isTopLevel is false, meanning that the document is still loading.
         * When all frames have been loaded then the DocumentComplete is fired for the main document signaling that the document has finished loading which is recognized when isTopLevel is true. There is no need to use timers to find out when the page has fully loaded.
         */
        private void WebBrower_DocumentComplete(object sender, DocumentCompleteEventArgs e)
        {
            if (e.url.ToLower() == "about:blank")
            {
                return;
            }
            cEXWB pWB = sender as cEXWB;

            if (e.istoplevel)
            {
                IsDocumentFinish = true;
                //Logger.Log(LogLevel.Info, string.Format("DocumentComplete,Url:{0},时间:{1}", e.url,DateTime.Now));
            }
            else if (pWB != null && pWB.MainDocumentFullyLoaded) // a frame naviagtion within a frameset
            {
                IsDocumentFinish = true;
                //Logger.Log(LogLevel.Info, string.Format("MainDocumentFullyLoaded,Url:{0},时间:{1}", e.url, DateTime.Now));
            }
            else
            {
                //log.Debug("DocumentComplete::TopLevel is FALSE===>" + e.url);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 解除浏览器绑定的事件
        /// </summary>
        /// <param name="wb"></param>
        private void UnregiserWebBrowerHandler(cEXWB wb)
        {
            if (wb != null)
            {
                //注销事件处理方法
                wb.ProtocolHandlerBeginTransaction   -= new ProtocolHandlerBeginTransactionEventHandler(WebBrower_ProtocolHandlerBeginTransaction);
                wb.ProtocolHandlerOnResponse         -= new ProtocolHandlerOnResponseEventHandler(WebBrower_ProtocolHandlerOnResponse);
                wb.ProtocolHandlerDataFullyAvailable -= new ProtocolHandlerDataFullyAvailableEventHandler(WebBrower_ProtocolHandlerDataFullyAvailable);
                wb.ProtocolHandlerDataFullyRead      -= new ProtocolHandlerDataFullyReadEventHandler(WebBrower_ProtocolHandlerDataFullyRead);
                wb.ProtocolHandlerOperationFailed    -= new ProtocolHandlerOperationFailedEventHandler(WebBrower_ProtocolHandlerOperationFailed);

                wb.ScriptError         -= new ScriptErrorEventHandler(WebBrower_ScriptError);
                wb.WBOnDocumentChanged -= new EventHandler(WebBrower_WBOnDocumentChanged);

                wb.DocumentComplete  -= new DocumentCompleteEventHandler(WebBrower_DocumentComplete);
                wb.NavigateError     -= new NavigateErrorEventHandler(WebBrower_NavigateError);
                wb.WBSecurityProblem -= new SecurityProblemEventHandler(WebBrower_WBSecurityProblem);
                //wb.BeforeNavigate2 -= new BeforeNavigate2EventHandler(VBACsEXWB_BeforeNavigate2);
                wb.WBDocHostShowUIShowMessage -= new DocHostShowUIShowMessageEventHandler(WebBrower_WBDocHostShowUIShowMessage);
                wb.ProcessUrlAction           -= new ProcessUrlActionEventHandler(WebBrower_ProcessUrlAction);
                //wb.WBEvaluteNewWindow -= new EvaluateNewWindowEventHandler(WebBrower_WBEvaluteNewWindow);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 浏览器组件事件绑定
        /// </summary>
        /// <param name="wb"></param>
        private void RegiserWebBrowerHandler(cEXWB wb)
        {
            if (wb != null)
            {
                //注册事件处理方法
                wb.ProtocolHandlerBeginTransaction   += new ProtocolHandlerBeginTransactionEventHandler(WebBrower_ProtocolHandlerBeginTransaction);
                wb.ProtocolHandlerOnResponse         += new ProtocolHandlerOnResponseEventHandler(WebBrower_ProtocolHandlerOnResponse);
                wb.ProtocolHandlerDataFullyAvailable += new ProtocolHandlerDataFullyAvailableEventHandler(WebBrower_ProtocolHandlerDataFullyAvailable);
                wb.ProtocolHandlerDataFullyRead      += new ProtocolHandlerDataFullyReadEventHandler(WebBrower_ProtocolHandlerDataFullyRead);
                wb.ProtocolHandlerOperationFailed    += new ProtocolHandlerOperationFailedEventHandler(WebBrower_ProtocolHandlerOperationFailed);

                wb.ScriptError         += new ScriptErrorEventHandler(WebBrower_ScriptError);
                wb.WBOnDocumentChanged += new EventHandler(WebBrower_WBOnDocumentChanged);
                wb.DocumentComplete    += new DocumentCompleteEventHandler(WebBrower_DocumentComplete);
                wb.NavigateError       += new NavigateErrorEventHandler(WebBrower_NavigateError);
                wb.WBSecurityProblem   += new SecurityProblemEventHandler(WebBrower_WBSecurityProblem);
                //wb.BeforeNavigate2 += new BeforeNavigate2EventHandler(VBACsEXWB_BeforeNavigate2);
                wb.WBDocHostShowUIShowMessage += new DocHostShowUIShowMessageEventHandler(WebBrower_WBDocHostShowUIShowMessage);
                wb.ProcessUrlAction           += new ProcessUrlActionEventHandler(WebBrower_ProcessUrlAction);
                //wb.WBEvaluteNewWindow += new EvaluateNewWindowEventHandler(WebBrower_WBEvaluteNewWindow);
                wb.NewWindow2 += new NewWindow2EventHandler(WebBrower_NewWindow2);
                //wb.FileDownloadExStart += new FileDownloadExEventHandler(WebBrower_FileDownloadExStart);
            }
        }
Esempio n. 12
0
        private void WebBrower_DocumentComplete(object sender, DocumentCompleteEventArgs e)
        {
            if (e.url.ToLower() == "about:blank")
            {
                return;
            }

            cEXWB pWB = sender as cEXWB;

            if (e.istoplevel)
            {
                IsDocumentFinish = true;
                Html             = pWB.DocumentSource;
                htmlDocument     = HtmlAgilityPackHelper.GetHtmlDocument(pWB.DocumentSource);
                //Stopwatch sw=new Stopwatch();
                //sw.Start();
                //LoadHtmlTree();
                //sw.Stop();
                Stopwatch sw1 = new Stopwatch();
                sw1.Start();
                BuildTree3();
                sw1.Stop();
                richTextBox.Text += string.Format("DOM树构建时间{0}毫秒", sw1.ElapsedMilliseconds) + "\n";
                //MessageBox.Show(sw1.ElapsedMilliseconds.ToString());
                //Logger.Log(LogLevel.Info, string.Format("DocumentComplete,Url:{0},时间:{1}", e.url,DateTime.Now));
            }
            else if (pWB != null && pWB.MainDocumentFullyLoaded) // a frame naviagtion within a frameset
            {
                IsDocumentFinish = true;
                //Logger.Log(LogLevel.Info, string.Format("MainDocumentFullyLoaded,Url:{0},时间:{1}", e.url, DateTime.Now));
            }
            else
            {
                //log.Debug("DocumentComplete::TopLevel is FALSE===>" + e.url);
            }
        }
Esempio n. 13
0
        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 (WebBrower != null)
            //{
            //    iDochostUIFlag = WebBrower.WBDOCHOSTUIFLAG;
            //    iDocDlCltFlag = WebBrower.WBDOCDOWNLOADCTLFLAG;
            //}

            csExWB.cEXWB pWB = null;

            try
            {
                //Create and setup browser
                pWB = new csExWB.cEXWB();

                //pWB.Dock = cEXWB1.Dock;
                pWB.Anchor = WebBrower.Anchor;

                pWB.Location = WebBrower.Location;
                pWB.Size     = WebBrower.Size;
                //pWB.Name = System.Guid.NewGuid().ToString();
                pWB.RegisterAsBrowser    = true;
                pWB.WBDOCDOWNLOADCTLFLAG = iDocDlCltFlag;
                pWB.WBDOCHOSTUIFLAG      = iDochostUIFlag;
                //pWB.FileDownloadDirectory = WebBrower.FileDownloadDirectory;
                //pWB.DownloadActiveX = false;
                //pWB.DownloadFrames = true;
                //pWB.DownloadImages = true;
                //pWB.DownloadJava = true;
                //pWB.DownloadScripts = true;
                //pWB.DownloadSounds = false;
                //pWB.DownloadVideo = false;

                pWB.RegisterAsBrowser = true;
                this.RegisterEvent(pWB);

                //Add to controls collection
                //this.Controls.Add(pWB);
                BrowerPannel.Controls.Add(pWB);

                if (BringToFront)
                {
                    //Bring to front
                    pWB.BringToFront();
                }
                //Increase count
                WebBrower = pWB;
            }
            catch (Exception ee)
            {
                return(false);
            }

            return(true);
        }