B2017-123 Find Replace handle multiple clicks without crashing

Allow done button to stop processing when doing bookmark all
This commit is contained in:
Rich 2017-06-19 17:27:41 +00:00
parent b0b4247f29
commit 9e0c47cb02

View File

@ -133,40 +133,60 @@ namespace Volian.Controls.Library
{
cmboFindText.Focus();
}
private bool DoingClick = false; // Don't allow a button to be clicked until processing is complete for the last button
private void btnReplace_Click(object sender, EventArgs e)
{
if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button
DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button
DoReplace();
DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button
}
private void DoReplace()
{
if (!IsFound)
btnFindNext_Click(sender, e);
DoFindNext();
else
{
MyEditItem.ReplaceText(cmboReplaceText.Text, cmboFindText.Text, cbxCaseSensitive.Checked, cbxWholeWord.Checked, cbxReverse.Checked, false, null);
}
}
private void btnRplAll_Click(object sender, EventArgs e)
{
if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button
DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button
DoRplAll();
DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button
}
private void DoRplAll()
{
if (!IsFound)
btnFindNext_Click(sender, e);
DoFindNext();
else
{
btnReplace_Click(sender, e);
btnFindNext_Click(sender, e);
DoReplace();
DoFindNext();
}
}
private void btnBookMrkAll_Click(object sender, EventArgs e)
{
if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button
DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button
DoBookMrkAll();
DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button
}
private void DoBookMrkAll()
{
findingbookmarks = true;
if (!IsFound) btnFindNext_Click(sender, e);
if (!IsFound) DoFindNext();
FoundIt = true;
while (FoundIt) // found is set in btnFindNext_Click()
while (FoundIt && this.Visible) // found is set in btnFindNext_Click() - Don't continue if the form is invisible (Done button pressed).
{
MyDisplayBookMarks.AddBookMark(MyEditItem.MyItemInfo);
btnFindNext_Click(sender, e);
Application.DoEvents();
DoFindNext();
}
StepPanelTabDisplayEventArgs args = new StepPanelTabDisplayEventArgs("Bookmarks");
MyEditItem.MyStepPanel.OnTabDisplay(sender, args);
MyEditItem.MyStepPanel.OnTabDisplay(btnBookMrkAll, args);
findingbookmarks = false;
}
private void btnFndRplDone_Click(object sender, EventArgs e)
@ -205,6 +225,13 @@ namespace Volian.Controls.Library
return pos != -1;
}
private void btnFindNext_Click(object sender, EventArgs e)
{
if (DoingClick) return;// Don't allow a button to be clicked until processing is complete for the last button
DoingClick = true;// Don't allow a button to be clicked until processing is complete for the last button
DoFindNext();
DoingClick = false;// Don't allow a button to be clicked until processing is complete for the last button
}
private void DoFindNext()
{
AddToComboLists();
doingfind = true;