Exemple #1
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);
                }
            }
        }
Exemple #2
0
        private void SelectCell(HtmlTableCell cell)
        {
            HtmlElement cellElement = cell as HtmlElement;

            MsHtmlWrap.MshtmlMarkupServices markupServices = new MsHtmlWrap.MshtmlMarkupServices((MsHtmlWrap.IMarkupServicesRaw)Document);

            if (cellElement.document == Document)
            {
                System.Diagnostics.Debug.WriteLine("same");
            }
            // move the selection to the beginning of the cell
            MsHtmlWrap.MarkupRange markupRange = markupServices.CreateMarkupRange(cellElement);

            //  if the cell is empty then collapse the selection
            if (cellElement.innerHTML == null)
            {
                markupRange.End.MoveToPointer(markupRange.Start);
            }

            HtmlTextRange textRange = markupRange.ToTextRange();

            textRange.select();
        }