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);
break;
case ItemInfo.EAddpingPart.Replace:
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)
{
edtitm.Dispose();

View File

@ -1825,6 +1825,7 @@ namespace Volian.Controls.Library
EditItem newFocus = null;
EditItem nextEditItem = MyNextEditItem;
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;
StepConfig savOrigPasteConfig = MyItemInfo.MyConfig as StepConfig;

View File

@ -2031,11 +2031,11 @@ namespace Volian.Controls.Library
tv_NodePaste(mi.Text);
break;
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;
else
{
{
tv_NodePaste(mi.Text);
break;
}
@ -2442,7 +2442,9 @@ namespace Volian.Controls.Library
else if (p.IndexOf("After") > -1)
PasteBeforeOrAfter(MenuSelections.StepAfter, tn, iiClipboard.ItemID);
else if (p.IndexOf("Replace") > -1)
{
PasteReplace(tn, iiClipboard.ItemID);
}
else // paste as child
PasteAsChild(tn, iiClipboard.ItemID);
@ -2549,6 +2551,7 @@ namespace Volian.Controls.Library
// first, check if a changeid is required.
string chgId = OnGetChangeId(this, new vlnTreeItemInfoEventArgs(ii));
ItemInfo replItemInfo = Item.PasteReplace(ii, copyStartID, chgId);
StepConfig replItemConfig = ii.MyConfig as StepConfig;
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)
SelectedNode = prevtn != null ? prevtn.NextNode : partn.FirstNode;
}
private void tv_NodeCopy()
{