private void btnReplaceAll_Click(object sender, EventArgs e)
{
if (this.cboFindR.Text == string.Empty)
return;
this.lblStatus.Text = string.Empty;
List<Range> foundRanges = null;
if (this.rdoRegexR.Checked)
{
Regex rr = null;
try
{
rr = new Regex(this.cboFindR.Text, this.GetRegexOptions());
}
catch (ArgumentException ex)
{
this.lblStatus.Text = "Error in Regular Expression: " + ex.Message;
return;
}
if (this.chkSearchSelectionR.Checked)
{
if (this._searchRange == null)
{
this._searchRange = this.Scintilla.Selection.Range;
}
foundRanges = this.Scintilla.FindReplace.ReplaceAll(this._searchRange, rr, this.cboReplace.Text);
}
else
{
this._searchRange = null;
foundRanges = this.Scintilla.FindReplace.ReplaceAll(rr, this.cboReplace.Text);
}
}
else
{
if (this.chkSearchSelectionR.Checked)
{
if (this._searchRange == null)
this._searchRange = this.Scintilla.Selection.Range;
foundRanges = this.Scintilla.FindReplace.ReplaceAll(this._searchRange, this.cboFindR.Text, this.cboReplace.Text, this.GetSearchFlags());
}
else
{
this._searchRange = null;
foundRanges = this.Scintilla.FindReplace.ReplaceAll(this.cboFindR.Text, this.cboReplace.Text, this.GetSearchFlags());
}
}
this.lblStatus.Text = "Total Replaced: " + foundRanges.Count.ToString();
}