Update to close the procedure when opened during the paste/replace option.

This commit is contained in:
Kevin Laskey 2024-06-18 10:48:28 -04:00
parent 9d1b99b08e
commit c92b888ec2
3 changed files with 15 additions and 3 deletions

View File

@ -688,8 +688,14 @@ namespace Volian.Controls.Library
edtitm.PasteSiblingAfter(copyStartID); edtitm.PasteSiblingAfter(copyStartID);
break; break;
case ItemInfo.EAddpingPart.Replace: case ItemInfo.EAddpingPart.Replace:
EditItem ei = edtitm.PasteReplace(copyStartID); EditItem ei = edtitm.PasteReplace(copyStartID);
if (ei == null) return false; //B2017-179 PasteReplace will return null if was aborted if (ei == null)
{
CloseTabItem(_MyDisplayTabItems["Item - " + myItemInfo.ItemID.ToString()]); //Grab itemID and set to close open tab.
return false; //B2017-179 PasteReplace will return null if was aborted
}
if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID) if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID)
{ {
edtitm.Dispose(); edtitm.Dispose();

View File

@ -1825,6 +1825,7 @@ namespace Volian.Controls.Library
EditItem newFocus = null; EditItem newFocus = null;
EditItem nextEditItem = MyNextEditItem; EditItem nextEditItem = MyNextEditItem;
EditItem prevEditItem = MyPreviousEditItem; EditItem prevEditItem = MyPreviousEditItem;
if (MyStepPanel?.SelectedEditItem?.ActiveParent == null) return null; //Was causing an error when active parent was null and the replaced proc was opened in the editor.
EditItem parentEditItem = ActiveParent; EditItem parentEditItem = ActiveParent;
StepConfig savOrigPasteConfig = MyItemInfo.MyConfig as StepConfig; StepConfig savOrigPasteConfig = MyItemInfo.MyConfig as StepConfig;

View File

@ -2031,7 +2031,7 @@ namespace Volian.Controls.Library
tv_NodePaste(mi.Text); tv_NodePaste(mi.Text);
break; break;
case "Replace Existing Procedure": case "Replace Existing Procedure":
DialogResult ovewriteEx = FlexibleMessageBox.Show("This will overwrite the procedure with then one you copied, would you like to overwrite it?\r\n\r\nSelecting 'Cancel' will cancel the paste action.", "Overwrite the procedure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);// == DialogResult.Yes; DialogResult ovewriteEx = FlexibleMessageBox.Show("This will overwrite the selected procedure with then one you copied, would you like to overwrite it?\r\n\r\nSelecting 'Cancel' will cancel the paste action.", "Overwrite the procedure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);// == DialogResult.Yes;
if (ovewriteEx == DialogResult.Cancel) break; if (ovewriteEx == DialogResult.Cancel) break;
else else
@ -2442,7 +2442,9 @@ namespace Volian.Controls.Library
else if (p.IndexOf("After") > -1) else if (p.IndexOf("After") > -1)
PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID); PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID);
else if (p.IndexOf("Replace") > -1) else if (p.IndexOf("Replace") > -1)
{
PasteReplace(tn, iiClipboard.ItemID); PasteReplace(tn, iiClipboard.ItemID);
}
else // paste as child else // paste as child
PasteAsChild(tn, iiClipboard.ItemID); PasteAsChild(tn, iiClipboard.ItemID);
@ -2549,6 +2551,7 @@ namespace Volian.Controls.Library
// first, check if a changeid is required. // first, check if a changeid is required.
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii)); string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID, chgId); ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID, chgId);
StepConfig replItemConfig = ii.MyConfig as StepConfig; StepConfig replItemConfig = ii.MyConfig as StepConfig;
if (replItemInfo != null) if (replItemInfo != null)
{ {
@ -2557,6 +2560,8 @@ namespace Volian.Controls.Library
} }
// B2018-047: was crashing on the following line (before change it was casting the result to a VETreeNote when the partn.FirstNode was just a TreeNode) // B2018-047: was crashing on the following line (before change it was casting the result to a VETreeNote when the partn.FirstNode was just a TreeNode)
SelectedNode = prevtn != null ? prevtn.NextNode : partn.FirstNode; SelectedNode = prevtn != null ? prevtn.NextNode : partn.FirstNode;
} }
private void tv_NodeCopy() private void tv_NodeCopy()
{ {