ARCed.Scintilla.FindReplaceDialog.ReplaceNext C# (CSharp) Method

ReplaceNext() private method

private ReplaceNext ( bool searchUp ) : Range
searchUp bool
return Range
        private Range ReplaceNext(bool searchUp)
        {
            Regex rr = null;
            Range selRange = this.Scintilla.Selection.Range;

            //	We only do the actual replacement if the current selection exactly
            //	matches the find.
            if (selRange.Length > 0)
            {
                if (this.rdoRegexR.Checked)
                {
                    rr = new Regex(this.cboFindR.Text, this.GetRegexOptions());
                    string selRangeText = selRange.Text;

                    if (selRange.Equals(this.Scintilla.FindReplace.Find(selRange, rr, false)))
                    {
                        //	If searching up we do the replacement using the range object.
                        //	Otherwise we use the selection object. The reason being if
                        //	we use the range the caret is positioned before the replaced
                        //	text. Conversely if we use the selection object the caret will
                        //	be positioned after the replaced text. This is very important
                        //	becuase we don't want the new text to be potentially matched
                        //	in the next search.
                        if (searchUp)
                            selRange.Text = rr.Replace(selRangeText, this.cboReplace.Text);
                        else
                            this.Scintilla.Selection.Text = rr.Replace(selRangeText, this.cboReplace.Text);
                    }
                }
                else
                {
                    if (selRange.Equals(this.Scintilla.FindReplace.Find(selRange, this.cboFindR.Text, false)))
                    {
                        if (searchUp)
                            selRange.Text = this.cboReplace.Text;
                        else
                            this.Scintilla.Selection.Text = this.cboReplace.Text;
                    }
                }
            }
            return this.FindNextR(searchUp, ref rr);
        }

Same methods

FindReplaceDialog::ReplaceNext ( ) : void