From 7cf28366f4259761b762e2d09cd115fe7b9eedbf Mon Sep 17 00:00:00 2001 From: Kathy Ruffing Date: Thu, 8 Aug 2024 09:01:31 -0400 Subject: [PATCH] B2024-038: tree view menuing for paste/replace of sections --- .../DisplayTabControl.cs | 7 ++++-- PROMS/Volian.Controls.Library/vlnTreeView.cs | 24 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index faecc214..5f37d421 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -672,8 +672,10 @@ namespace Volian.Controls.Library if (_MyDisplayTabItems.ContainsKey(key) && pasteType != ItemInfo.EAddpingPart.Replace) // If procedure page open use it unless replace { DisplayTabItem pg = _MyDisplayTabItems[key]; + // B2024-038: if section, refresh the editor even if the section is not expanded. + bool isSec = myItemInfo.IsSection; if (pg.MyStepTabPanel.MyStepPanel._LookupEditItems.ContainsKey(myItemInfo.ItemID) && - pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID].Expanded) + (pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID].Expanded || isSec)) { EditItem edtitm = pg.MyStepTabPanel.MyStepPanel._LookupEditItems[myItemInfo.ItemID]; switch (pasteType) @@ -710,7 +712,8 @@ namespace Volian.Controls.Library } else if (_MyDisplayTabItems.ContainsKey(key) && pasteType == ItemInfo.EAddpingPart.Replace) { - CloseTabItem(_MyDisplayTabItems["Item - " + myItemInfo.ItemID.ToString()]); //Grab itemID and set to close open tab. + // B2024-038: changed tab key to procedure (was item, which caused crash if section) + CloseTabItem(_MyDisplayTabItems["Item - " + proc.ItemID.ToString()]); //Grab itemID and set to close open tab. return false; //B2017-179 PasteReplace will return null if was aborted } return false; diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index 78554d1b..e60b358b 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -1740,10 +1740,13 @@ namespace Volian.Controls.Library // 1) 'to' & 'from' both 'non', i.e. Neither can have enhanced config data (be source or enhanced) // can do Before/After/Replace // 2) 'to' section is 'source' and 'from' section is 'non' (has no MyEnhancedDocuments) - // can do Before/After - no links exist in pasted section. - // cannot do Replace + // can do Before/After - no links exist in pasted section so cannot do Replace // 3) 'to' section is 'source' and 'from' section is same docversion 'source' - // can do Before/After/Replace + // can do Before/After (B2024-038 removes replace) + // 4) 'to' section is not 'source' and 'from' section is source + // can do Before/After but not replace - would have to manage + // links for 'from' section (B2024-038 added this case) + SectionConfig secToCfg = iiPasteHere.MyConfig as SectionConfig; SectionConfig secFromCfg = iiClipboard.MyConfig as SectionConfig; @@ -1752,13 +1755,22 @@ namespace Volian.Controls.Library bool secFromIsEnhanced = iiClipboard.IsEnhancedSection; bool secFromIsSource = secFromCfg.MyEnhancedDocuments != null && secFromCfg.MyEnhancedDocuments.Count > 0 && secFromCfg.MyEnhancedDocuments[0].Type != 0; bool secCanPaste = false; - if (!secToIsEnhanced && !secToIsSource && !secFromIsEnhanced && !secFromIsSource) secCanPaste = true; // 1) - else if (secToIsSource && !secFromIsEnhanced && !secFromIsSource) // 2) + if (!secToIsEnhanced && !secToIsSource && !secFromIsEnhanced && !secFromIsSource) secCanPaste = true; // 1) + else if (secToIsSource && !secFromIsEnhanced && !secFromIsSource) // 2) { secCanPaste = true; okToReplace = false; } - else if (secToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) secCanPaste = true; // 3) + else if (secToIsSource && iiPasteHere.MyDocVersion.VersionID == iiClipboard.MyDocVersion.VersionID) + { + secCanPaste = true; // 3) + okToReplace = false; + } + else if (!secToIsSource && secFromIsSource) + { + secCanPaste = true; // 4 + okToReplace = false; + } if (iiClipboard.IsRtfRaw) secCanPaste = okToReplace = false; // never paste an equation. if (secCanPaste) cm.MenuItems.Add("Paste Section Before", new EventHandler(mi_Click)); if (okToReplace && secCanPaste) cm.MenuItems.Add("Replace Existing Section", new EventHandler(mi_Click));