B2018-152 Added a message box for case where user deletes all of the text in a step element, then selects one of its substeps. Added logic to handle the deleting of the that step if user selects YES from message box.

This commit is contained in:
John Jenko 2019-04-26 15:07:52 +00:00
parent cd3656c955
commit 536f7efb7e

View File

@ -443,6 +443,8 @@ namespace Volian.Controls.Library
}
set
{
EditItem newFocus = null; // B2018-152 when empty step is deleted, will contain the new step element focus
bool deletingParent = false; // B2018-152 used to tell us user clicked on subtep of step element who's text was removed (special case)
EditItem lastEI = _SelectedEditItem;
if (value != null) value.SetActive(); // Set the active color
if (lastEI == value) return; // Same - No Change
@ -455,15 +457,24 @@ namespace Volian.Controls.Library
{
if (lastEI.HasChildren)
{
// B2018-152 Added a messagebox for when user clicks on a substep of a step element who's text was just deleted
// Also made the message for when we ask about removing a step and its substeps more descriptive
string msg1 = "Do you want to delete it and its substeps?";
string msg2 = "Select YES to remove the empty step";
string msg3 = "Select NO to keep the empty step which can be restored via the History tab on the Step Properties panel.";
if (value != null && value.MyItemInfo.HasAncestor(lastEI.MyItemInfo))
{
shouldDelete = false;
msg1 = "This step does not have text but you had selected one of its substeps. " + msg1;
msg2 = msg2 + " including the substep you had selected. You will be placed at the next location.";
deletingParent = true; // B2018-152 this will tell us that the user selected a substep of a parent being deleted
}
else
{
DialogResult result = FlexibleMessageBox.Show("This step does not have text but has substeps. Do you want to delete it and its substeps?", "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No) shouldDelete = false;
msg1 = "This step does not have text but has substeps. " + msg1;
msg2 = msg2 + " and its substeps.";
}
DialogResult result = FlexibleMessageBox.Show(msg1 + "\n\n" + msg2 + "\n\n" + msg3, "Verify Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No) shouldDelete = false;
}
}
if (shouldDelete)
@ -496,7 +507,7 @@ namespace Volian.Controls.Library
}
}
float oldTop = lastEI.Top;
EditItem newFocus = lastEI.DeleteItem();
newFocus = lastEI.DeleteItem(); //B2018-152 made "newFocus" available outside this IF statement
if (newFocus == null)
{
lastEI.RefreshContent();
@ -544,6 +555,10 @@ namespace Volian.Controls.Library
lastEI.RefreshDisplay(false);
}
}
//B2018-152 if we are deleteing a step element that has substeps and the user click on one of those substep,
// use resulting focus position returned from lastEI.DeleteItem() instead of current "value"
if (deletingParent && newFocus != null)
value = newFocus;
_SelectedEditItem = value;
MyStepTabPanel.MyStepTabRibbon.MyEditItem = value;// Update StepTabRibbon.MyEditItem to match
if (value != null)