From c92b888ec2ee32bf9153449878f030b6ffc36c5c Mon Sep 17 00:00:00 2001 From: Kevin Laskey Date: Tue, 18 Jun 2024 10:48:28 -0400 Subject: [PATCH] Update to close the procedure when opened during the paste/replace option. --- PROMS/Volian.Controls.Library/DisplayTabControl.cs | 8 +++++++- PROMS/Volian.Controls.Library/EditItem.cs | 1 + PROMS/Volian.Controls.Library/vlnTreeView.cs | 9 +++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index eb9fe50c..5df5eee1 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -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(); diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index 8bb85288..545d7885 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -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; diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index c9da73c4..17505c56 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -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() {