} //GetTableElement /// <summary> /// Get selected or parent table /// </summary> /// <returns>null if not found</returns> public HtmlTable GetTableElement() { // define the table and row elements and obtain there values HtmlTable table = null; HtmlTextRange range = SelectionHelper.GetTextRange(Document); // first see if the table element is selected table = SelectionHelper.GetFirstControl(Document) as HtmlTable; // if table not selected then parse up the selection tree if (table == null && range != null) { HtmlElement element = (HtmlElement)range.parentElement(); // parse up the tree until the table element is found while (element != null && table == null) { if (element is HtmlTable) { table = (HtmlTable)element; } element = (HtmlElement)element.parentElement; } } // return the defined table element return(table); }
/// <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(); }
/// <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(); }
/// <summary> /// /// </summary> /// <param name="src">image source / url</param> /// <param name="alt">alternate text for image</param> public void InsertImage(string src, string alt) { try { using (new UndoUnit(Document, "Insert Image")) { // obtain a reference to the body node HtmlDomNode bodyNode = (HtmlDomNode)Document.body; HtmlImageElement img = (HtmlImageElement)Document.createElement("IMG"); img.src = src; img.alt = alt; // table processing all complete so insert into the DOM HtmlSelection selection = Document.selection; HtmlTextRange textRange = SelectionHelper.GetTextRange(Document); if (textRange != null) { textRange.pasteHTML(((HtmlElement)img).outerHTML);//"<img src=\"" + src + "\" alt=\"" + alt + "\">"); } else { HtmlControlRange controlRange = SelectionHelper.GetAllControls(Document); if (controlRange != null) { // overwrite any controls the user has selected try { // clear the selection and insert the table // only valid if multiple selection is enabled for (int idx = 1; idx < controlRange.length; idx++) { controlRange.remove(idx); } controlRange.item(0).outerHTML = ((HtmlElement)img).outerHTML; // this should work with initial count set to zero // controlRange.add((HtmlControlElement)table); } catch (Exception ex) { throw new HtmlEditorException("Cannot Delete all previously Controls selected.", "InsertImage", ex); } } else { // insert the table at the end of the HTML HtmlDomNode imgNode = (HtmlDomNode)img; bodyNode.appendChild(imgNode); } } } } catch (Exception ex) { throw new HtmlEditorException("Unable to insert image.", "InsertImage", ex); } }
//</SNIPPET3> //<SNIPPET4> private void CreateHyperlinkFromSelection() { if (webBrowser1.Document != null) { mshtml.IHTMLDocument2 iDoc = (mshtml.IHTMLDocument2)webBrowser1.Document.DomDocument; if (iDoc != null) { mshtml.IHTMLSelectionObject iSelect = iDoc.selection; if (iSelect == null) { MessageBox.Show("Please select some text before using this command."); return; } mshtml.IHTMLTxtRange txtRange = (mshtml.IHTMLTxtRange)iSelect.createRange(); // Create the link. if (txtRange.queryCommandEnabled("CreateLink")) { Object o = null; txtRange.execCommand("CreateLink", true, o); } } } }
public static bool ParsePlaceholder(mshtml.IHTMLTxtRange rng, out string placeholderText, bool atomic = false) { placeholderText = String.Empty; if (!IsPlaceholder(rng, atomic)) { return(false); } return(ParsePlaceholder(rng.text, out placeholderText)); }
public static bool ParsePlaceholder(mshtml.IHTMLTxtRange rng, out string placeholderText, out int level, bool atomic = false) { placeholderText = string.Empty; level = -1; string placeholder; if (!ParsePlaceholder(rng, out placeholder, atomic)) { return(false); } return(ParsePlaceholder(placeholder, out placeholderText, out level)); }
/// <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); } } }
// determine if the current selection is a table // return the table element private void GetTableElement(out HtmlTable table, out HtmlTableRow row, out HtmlTableCell cell) { table = null; row = null; cell = null; HtmlTextRange range = SelectionHelper.GetTextRange(Document); try { // first see if the table element is selected table = SelectionHelper.GetFirstControl(Document) as HtmlTable; // if table not selected then parse up the selection tree if (table == null && range != null) { HtmlElement element = (HtmlElement)range.parentElement(); // parse up the tree until the table element is found while (element != null && table == null) { if (element is HtmlTable) { table = (HtmlTable)element; } else if (element is HtmlTableRow) { row = (HtmlTableRow)element; } else if (element is HtmlTableCell) { cell = (HtmlTableCell)element; } element = (HtmlElement)element.parentElement; } } } catch (Exception) { // have unknown error so set return to null table = null; row = null; cell = null; } } //GetTableElement
public static bool IsPlaceholder(mshtml.IHTMLTxtRange rng, bool atomic = false) { if (rng == null) { return(false); } string unused; if (!ParsePlaceholder(rng.text, out unused)) { return(false); } if (!atomic) { return(true); } return(IsPlaceholder(rng.parentElement(), atomic)); }
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(); }
// get the selected range object public static HtmlTextRange GetTextRange(HtmlDocument document) { // define the selected range object HtmlSelection selection; HtmlTextRange range = null; try { // calculate the text range based on user selection selection = document.selection; if (selection.type.Equals("text", StringComparison.OrdinalIgnoreCase) || selection.type.Equals("none", StringComparison.OrdinalIgnoreCase)) { range = selection.createRange() as HtmlTextRange; } } catch (Exception) { // have unknown error so set return to null range = null; } return(range); }
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); } } }
/// <summary> /// Determines if the current font selected is Underline when given a range /// </summary> /// <param name="range"></param> private bool IsFontUnderline(mshtmlTextRange range) { // determine the UNDERLINE property object currentUnderline = QueryCommandRange(range, HTML_COMMAND_UNDERLINE); return (currentUnderline is System.Boolean) ? (bool)currentUnderline : _bodyFont.Underline; }
/// <summary> /// Determines the value of the command /// </summary> private object QueryCommandRange(mshtmlTextRange range, string command) { object retValue = null; if (range != null) { try { // ensure command is a valid command and then enabled for the selection if (range.queryCommandSupported(command)) { if (range.queryCommandEnabled(command)) { retValue = range.queryCommandValue(command); } } } catch (Exception) { // have unknown error so set return to null retValue = null; } } // return the obtained value return retValue; }
/// <summary> /// Determines if the current font selected is Strikeout when given a range /// </summary> private bool IsFontStrikeout(mshtmlTextRange range) { // determine the STRIKEOUT property object currentStrikeout = QueryCommandRange(range, HTML_COMMAND_STRIKE_THROUGH); return (currentStrikeout is System.Boolean) ? (bool)currentStrikeout : _bodyFont.Strikeout; }
/// <summary> /// Determines if the current font selected is Superscript when given a range /// </summary> private bool IsFontSuperscript(mshtmlTextRange range) { // determine the SUPERSCRIPT property object currentSuperscript = QueryCommandRange(range, HTML_COMMAND_SUPERSCRIPT); return (currentSuperscript is System.Boolean) ? (bool)currentSuperscript : false; }
} // QueryCommandRange /// <summary> /// Determines the value of the command /// </summary> private object QueryCommandRange(mshtmlTextRange range, string command) { object retValue = null; try { if (!range.IsNull() && !range.text.IsNullOrEmpty()) { // ensure command is a valid command and then enabled for the selection if (range.queryCommandSupported(command)) { if (range.queryCommandEnabled(command)) { retValue = range.queryCommandValue(command); } } } else { retValue = QueryCommandDocument(command); } } catch (Exception) { // have unknown error so set return to null retValue = null; } // return the obtained value return retValue; } //QueryCommandRange
/// <summary> /// Determines if the current font selected is Italic when given a range /// </summary> private bool IsFontItalic(mshtmlTextRange range) { // determine the ITALIC property object currentItalic = QueryCommandRange(range, HTML_COMMAND_ITALIC); return (currentItalic is System.Boolean) ? (bool)currentItalic : _bodyFont.Italic; }
/// <summary> /// Executes the execCommand on the selected range (given the range) /// </summary> private void ExecuteCommandRange(mshtmlTextRange range, string command, object data) { try { if (range != null) { // ensure command is a valid command and then enabled for the selection if (range.queryCommandSupported(command)) { if (range.queryCommandEnabled(command)) { // mark the selection with the appropriate tag range.execCommand(command, false, data); } } } } catch (Exception ex) { // Unknown error so inform user throw new HtmlEditorException("Unknown MSHTML Error.", command, ex); } }
/// <summary> /// Method to perform the actual find of the given text /// </summary> private mshtmlTextRange FindText(string findText, bool matchWhole, bool matchCase) { // define the search options int searchOptions = 0; if (matchWhole) searchOptions = searchOptions + 2; if (matchCase) searchOptions = searchOptions + 4; // perform the search operation if (_findRange.findText(findText, _findRange.text.Length, searchOptions)) { // select the found text within the document _findRange.select(); // limit the new find range to be from the newly found text mshtmlTextRange foundRange = (mshtmlTextRange)document.selection.createRange(); _findRange = (mshtmlTextRange)body.createTextRange(); _findRange.setEndPoint("StartToEnd", foundRange); // text found so return this selection return foundRange; } else { // reset the find ranges FindReplaceReset(); // no text found so return null range return null; } }
/// <summary> /// Method to reset the find and replace options to initialize a new search /// </summary> public void FindReplaceReset() { // reset the range being worked with _findRange = (mshtmlTextRange)body.createTextRange(); ((mshtmlSelection)document.selection).empty(); }
/// <summary> /// Executes the queryCommandState on the selected range (given the range) /// </summary> private bool ExecuteCommandQuery(mshtmlTextRange range, string command) { // set the initial state as false bool retValue = false; try { if (range != null) { // ensure command is a valid command and then enabled for the selection if (range.queryCommandSupported(command)) { if (range.queryCommandEnabled(command)) { // mark the selection with the appropriate tag retValue = range.queryCommandState(command); } } } } catch (Exception ex) { // Unknown error so inform user throw new HtmlEditorException("Unknown MSHTML Error.", command, ex); } // return the value return retValue; }
/// <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(); }
// reset the find and replace options to initialize a new search public void FindReset() { // reset the range being worked with this.find_range = (HtmlTextRange)this.document_body.createTextRange(); ((HtmlSelection)this.document.selection).empty(); }
// function to insert a basic table // will honour the existing table if passed in private void ProcessTable(HtmlTable table, HtmlTableProperty tableProperties) { try { using (new UndoUnit(Document, "Table add/modify")) { // obtain a reference to the body node and indicate table present HtmlDomNode bodyNode = (HtmlDomNode)Document.body; bool tableCreated = false; MsHtmlWrap.MarkupRange targetMarkupRange = null; // ensure a table node has been defined to work with if (table == null) { // create the table and indicate it was created table = (HtmlTable)Document.createElement("TABLE"); tableCreated = true; //markup range for selecting first cell after table creation targetMarkupRange = GetMarkupRange(); } // define the table border, width, cell padding and spacing table.border = tableProperties.BorderSize; if (tableProperties.TableWidth > 0) { table.width = (tableProperties.TableWidthMeasurement == MeasurementOption.Pixel) ? string.Format("{0}", tableProperties.TableWidth) : string.Format("{0}%", tableProperties.TableWidth); } else { table.width = string.Empty; } if (tableProperties.TableAlignment != HorizontalAlignOption.Default) { table.align = tableProperties.TableAlignment.ToString().ToLower(); } else { table.align = string.Empty; } table.cellPadding = tableProperties.CellPadding.ToString(); table.cellSpacing = tableProperties.CellSpacing.ToString(); // define the given table caption and alignment string caption = tableProperties.CaptionText; HtmlTableCaption tableCaption = table.caption; if (caption != null && caption != string.Empty) { // ensure table caption correctly defined if (tableCaption == null) { tableCaption = table.createCaption(); } ((HtmlElement)tableCaption).innerText = caption; if (tableProperties.CaptionAlignment != HorizontalAlignOption.Default) { tableCaption.align = tableProperties.CaptionAlignment.ToString().ToLower(); } if (tableProperties.CaptionLocation != VerticalAlignOption.Default) { tableCaption.vAlign = tableProperties.CaptionLocation.ToString().ToLower(); } } else { // if no caption specified remove the existing one if (tableCaption != null) { // prior to deleting the caption the contents must be cleared ((HtmlElement)tableCaption).innerText = null; table.deleteCaption(); } } // determine the number of rows one has to insert int numberRows, numberCols; if (tableCreated) { numberRows = Math.Max((int)tableProperties.TableRows, 1); } else { numberRows = Math.Max((int)tableProperties.TableRows, 1) - (int)table.rows.length; } // layout the table structure in terms of rows and columns table.cols = (int)tableProperties.TableColumns; if (tableCreated) { // this section is an optimization based on creating a new table // the section below works but not as efficiently numberCols = Math.Max((int)tableProperties.TableColumns, 1); // insert the appropriate number of rows HtmlTableRow tableRow; for (int idxRow = 0; idxRow < numberRows; idxRow++) { tableRow = table.insertRow(-1) as HtmlTableRow; // add the new columns to the end of each row for (int idxCol = 0; idxCol < numberCols; idxCol++) { tableRow.insertCell(-1); } } } else { // if the number of rows is increasing insert the decrepency if (numberRows > 0) { // insert the appropriate number of rows for (int idxRow = 0; idxRow < numberRows; idxRow++) { table.insertRow(-1); } } else { // remove the extra rows from the table for (int idxRow = numberRows; idxRow < 0; idxRow++) { table.deleteRow(table.rows.length - 1); } } // have the rows constructed // now ensure the columns are correctly defined for each row HtmlElementCollection rows = table.rows; foreach (HtmlTableRow tableRow in rows) { numberCols = Math.Max((int)tableProperties.TableColumns, 1) - (int)tableRow.cells.length; if (numberCols > 0) { // add the new column to the end of each row for (int idxCol = 0; idxCol < numberCols; idxCol++) { tableRow.insertCell(-1); } } else { // reduce the number of cells in the given row // remove the extra rows from the table for (int idxCol = numberCols; idxCol < 0; idxCol++) { tableRow.deleteCell(tableRow.cells.length - 1); } } } } // if the table was created then it requires insertion into the DOM // otherwise property changes are sufficient if (tableCreated) { // table processing all complete so insert into the DOM HtmlDomNode tableNode = (HtmlDomNode)table; HtmlElement tableElement = (HtmlElement)table; HtmlSelection selection = Document.selection; HtmlTextRange textRange = SelectionHelper.GetTextRange(Document); // final insert dependant on what user has selected if (textRange != null) { // text range selected so overwrite with a table try { string selectedText = textRange.text; if (selectedText != null) { // place selected text into first cell HtmlTableRow tableRow = table.rows.item(0, null) as HtmlTableRow; (tableRow.cells.item(0, null) as HtmlElement).innerText = selectedText; } textRange.pasteHTML(tableElement.outerHTML); } catch (Exception ex) { throw new HtmlEditorException("Invalid Text selection for the Insertion of a Table.", "ProcessTable", ex); } } else { HtmlControlRange controlRange = SelectionHelper.GetAllControls(Document); if (controlRange != null) { // overwrite any controls the user has selected try { // clear the selection and insert the table // only valid if multiple selection is enabled for (int idx = 1; idx < controlRange.length; idx++) { controlRange.remove(idx); } controlRange.item(0).outerHTML = tableElement.outerHTML; // this should work with initial count set to zero // controlRange.add((HtmlControlElement)table); } catch (Exception ex) { throw new HtmlEditorException("Cannot Delete all previously Controls selected.", "ProcessTable", ex); } } else { // insert the table at the end of the HTML bodyNode.appendChild(tableNode); } } } else { // table has been correctly defined as being the first selected item // need to remove other selected items HtmlControlRange controlRange = SelectionHelper.GetAllControls(Document); if (controlRange != null) { // clear the controls selected other than than the first table // only valid if multiple selection is enabled for (int idx = 1; idx < controlRange.length; idx++) { controlRange.remove(idx); } } } //if table created, then focus the first cell if (tableCreated) { try { HtmlElement cell = targetMarkupRange.GetFirstElement(e => e is HtmlTableCell, true); if (cell != null) { SelectCell(cell as HtmlTableCell); } } catch (Exception e) { Log.Write(e); } } } } catch (Exception ex) { // throw an exception indicating table structure change error throw new HtmlEditorException("Unable to modify Html Table properties.", "ProcessTable", ex); } } //ProcessTable
/// <summary> /// Handler of the NavigateComplete2 event. /// </summary> public void NavigateComplete2Handler() { mshtml.IHTMLTxtRange theIHTMLTxtRange = null; _HTMLDocument = (mshtml.HTMLDocument)_AxWebBrowser.Document; _HTMLBody = (mshtml.HTMLBody)_HTMLDocument.body; // Determine if errors exist in the displayed Html. theIHTMLTxtRange = _HTMLBody.createTextRange(); _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(); _ContainsWarnings= theIHTMLTxtRange.findText(_WARNING, theIHTMLTxtRange.text.Length, _FIND_MATCH_CASE | _FIND_MATCH_WHOLE_WORD); _FindRemainingText = _HTMLBody.createTextRange(); ((mshtml.IHTMLSelectionObject)_HTMLDocument.selection).empty(); }
/// <summary> /// DetermineS if the current font selected is bold when given a range /// </summary> private bool IsFontBold(mshtmlTextRange range) { // determine the BOLD property object currentBold = QueryCommandRange(range, HTML_COMMAND_BOLD); return (currentBold is System.Boolean) ? (bool)currentBold : _bodyFont.Bold; }
// function to perform the actual find of the given text private HtmlTextRange FindText(string find_text, bool match_whole, bool match_case) { // define the search options int search_options = 0; if (match_whole) search_options += 2; if (match_case) search_options += 4; // Sanity checks if ((this.find_range == null) || (this.find_range.text == null)) { // reset the find ranges this.FindReset(); // no text found so return null range return null; } // perform the search operation if (this.find_range.findText(find_text, this.find_range.text.Length, search_options)) { // select the found text within the document this.find_range.select(); // limit the new find range to be from the newly found text HtmlTextRange found_range = (HtmlTextRange)this.document.selection.createRange(); this.find_range = (HtmlTextRange)this.document_body.createTextRange(); this.find_range.setEndPoint("StartToEnd", found_range); // text found so return this selection return found_range; } else { // reset the find ranges this.FindReset(); // no text found so return null range return null; } }
} //FindReplacePrompt /// <summary> /// Method to reset the find and replace options to initialize a new search /// </summary> public void FindReplaceReset() { // reset the range being worked with _findRange = body.createTextRange(); document.selection.empty(); } //FindReplaceReset