Replace was not replacing the first instance, improved flow and general functionality of Find/Replace

This commit is contained in:
2014-06-30 13:45:22 +00:00
parent c9cdc35ff2
commit 25b536dea5
2 changed files with 88 additions and 79 deletions

View File

@@ -14,7 +14,16 @@ namespace Volian.Controls.Library
private bool doingfind = false;
private bool found = false;
private bool findingbookmarks = false;
private bool IsFound
{
get
{
if (!cbxCaseSensitive.Checked)
return MyEditItem.MyStepRTB.SelectedText.ToUpper() == cmboFindText.Text.ToUpper();
else
return MyEditItem.MyStepRTB.SelectedText == cmboFindText.Text;
}
}
//private bool _offsetStartPos = false;
private EditItem _MyEditItem;
public EditItem MyEditItem
@@ -116,28 +125,31 @@ namespace Volian.Controls.Library
private void btnReplace_Click(object sender, EventArgs e)
{
btnFindNext_Click(sender, e);
if (found) // found is set in btnFindNext_Click()
if (!IsFound)
btnFindNext_Click(sender, e);
else
{
MyEditItem.ReplaceText(cmboReplaceText.Text, cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked, false, null);
found = false;
}
}
private void btnRplAll_Click(object sender, EventArgs e)
{
btnFindNext_Click(sender, e);
while (found) // found is set in btnFindNext_Click()
if (!IsFound)
btnFindNext_Click(sender, e);
else
{
if (MyEditItem.ReplaceText(cmboReplaceText.Text, cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked, true, this) == DialogResult.Cancel)
found = false;
else
btnFindNext_Click(sender, e);
btnReplace_Click(sender, e);
btnFindNext_Click(sender, e);
}
}
private void btnBookMrkAll_Click(object sender, EventArgs e)
{
findingbookmarks = true;
btnFindNext_Click(sender, e);
while (found) // found is set in btnFindNext_Click()
if (!IsFound) btnFindNext_Click(sender, e);
while (IsFound) // found is set in btnFindNext_Click()
{
MyDisplayBookMarks.AddBookMark(MyEditItem.MyItemInfo);
btnFindNext_Click(sender, e);