예제 #1
0
        /// <summary>
        /// Handler of the NavigateComplete2 event.
        /// </summary>
        public void NavigateComplete2Handler()
        {
            mshtml.IHTMLTxtRange theIHTMLTxtRange = null;

            htmlDocument = (mshtml.HTMLDocument)webBrowserUserControl.Document.DomDocument;
            htmlBody     = (mshtml.HTMLBody)htmlDocument.body;

            // Determine if errors exist in the displayed Html.
            theIHTMLTxtRange = htmlBody.createTextRange();
            if (theIHTMLTxtRange.text == null)
            {
            }
            else
            {
                containsErrors = theIHTMLTxtRange.findText(ERROR, theIHTMLTxtRange.text.Length, FIND_MATCH_CASE | FIND_MATCH_WHOLE_WORD);
            }

            // Determine if warnings exist in the displayed Html.
            theIHTMLTxtRange = htmlBody.createTextRange();
            if (theIHTMLTxtRange.text == null)
            {
            }
            else
            {
                containsWarnings = theIHTMLTxtRange.findText(WARNING, theIHTMLTxtRange.text.Length, FIND_MATCH_CASE | FIND_MATCH_WHOLE_WORD);
            }

            findRemainingText = htmlBody.createTextRange();
            ((mshtml.IHTMLSelectionObject)htmlDocument.selection).empty();
        }
예제 #2
0
        /// <summary>
        /// Handler of the NavigateComplete2 event.
        /// </summary>
        public void NavigateComplete2Handler()
        {
            mshtml.IHTMLTxtRange theIHTMLTxtRange = null;

            if (_webBrowser.Document == null)
            {
                return;
            }

            _HTMLDocument = (mshtml.HTMLDocument)_webBrowser.Document.DomDocument;
            _HTMLBody     = (mshtml.HTMLBody)_HTMLDocument.body;

            // Determine if errors exist in the displayed Html.
            theIHTMLTxtRange = _HTMLBody.createTextRange();
            if (theIHTMLTxtRange.text == null)
            {
            }
            else
            {
                _ContainsErrors = theIHTMLTxtRange.findText(_ERROR, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD);
            }

            // Determine if warnings exist in the displayed Html.
            theIHTMLTxtRange = _HTMLBody.createTextRange();
            if (theIHTMLTxtRange.text == null)
            {
            }
            else
            {
                _ContainsWarnings = theIHTMLTxtRange.findText(_WARNING, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD);
            }

            _FindRemainingText = _HTMLBody.createTextRange();
            ((mshtml.IHTMLSelectionObject)_HTMLDocument.selection).empty();
        }
예제 #3
0
        /// <summary>
        /// Public method
        /// </summary>
        /// <param name="theText"></param>
        /// <param name="mustMatchWholeWord"></param>
        /// <param name="mustMatchCase"></param>
        public void FindNextText(string theText, bool mustMatchWholeWord, bool mustMatchCase)
        {
            // define the search options
            int theSearchOption = 0;

            if (mustMatchWholeWord)
            {
                theSearchOption += FIND_MATCH_WHOLE_WORD;
            }

            if (mustMatchCase)
            {
                theSearchOption += FIND_MATCH_CASE;
            }

            if ((findRemainingText == null) || (findRemainingText.text == null))
            {
                // Sanity check.
                Debug.Assert(false);
            }
            else
            {
                // perform the search operation
                if (findRemainingText.findText(theText, findRemainingText.text.Length, theSearchOption))
                // String has been found.
                {
                    // Select the found text within the document
                    findRemainingText.select();

                    // Limit the new find range to be from the newly found text
                    mshtml.IHTMLTxtRange theFoundRange = (mshtml.IHTMLTxtRange)htmlDocument.selection.createRange();
                    findRemainingText = (mshtml.IHTMLTxtRange)htmlBody.createTextRange();
                    findRemainingText.setEndPoint("StartToEnd", theFoundRange);
                }
                else
                {
                    // Reset the find ranges
                    findRemainingText = htmlBody.createTextRange();
                    ((mshtml.IHTMLSelectionObject)htmlDocument.selection).empty();

                    MessageBox.Show("Finished searching the document", string.Format("Find text \"{0}\"", theText), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }