From e5938b18150066cd3bd793434133cce13ee5e41f Mon Sep 17 00:00:00 2001 From: John Date: Thu, 27 Sep 2018 13:53:57 +0000 Subject: [PATCH] =?UTF-8?q?B2016-058=20Context=20menu=20at=20the=20procedu?= =?UTF-8?q?re=20level=20will=20read=20=E2=80=9CCollapse=20Procedure?= =?UTF-8?q?=E2=80=9D,=20at=20the=20section=20level=20it=20will=20read=20?= =?UTF-8?q?=E2=80=9CCollapse=20Section=E2=80=9D,=20at=20the=20step=20and?= =?UTF-8?q?=20sub=20step=20levels=20will=20read=20=E2=80=9CCollapse?= =?UTF-8?q?=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PROMS/Volian.Controls.Library/vlnTreeView.cs | 32 ++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/PROMS/Volian.Controls.Library/vlnTreeView.cs b/PROMS/Volian.Controls.Library/vlnTreeView.cs index c53ff0e1..d57afe1d 100644 --- a/PROMS/Volian.Controls.Library/vlnTreeView.cs +++ b/PROMS/Volian.Controls.Library/vlnTreeView.cs @@ -620,6 +620,11 @@ namespace Volian.Controls.Library OwnerInfoList oil = null; OwnerInfo oi = null; FolderInfo fi = null; + // B2016-058 so we can customize the "collapse" menu item text + bool isProcNode = false; + bool isSectNode = false; + bool isFolderNode = false; + bool isWrkDftNode = false; VETreeNode tn = this.GetNodeAt(new Point(e.X, e.Y)) as VETreeNode; if (tn != null) { @@ -641,6 +646,7 @@ namespace Volian.Controls.Library #region Menu_New if (tn.VEObject as FolderInfo != null) { + isFolderNode = true; // For Folders, if no children, can add either docversion or folder. If children are // folders then can only add another folder, and if children are docversions can only // add docversion. @@ -672,6 +678,7 @@ namespace Volian.Controls.Library } else if (tn.VEObject as DocVersionInfo != null) // DocVersions can only contain procs { + isWrkDftNode = true; //_MyLog.WarnFormat("Context Menu 1c - {0}", GC.GetTotalMemory(true)); DocVersionInfo dvi = tn.VEObject as DocVersionInfo; if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi)) @@ -771,6 +778,7 @@ namespace Volian.Controls.Library } else if (tn.VEObject as ProcedureInfo != null) // Procs can only contain sections { + isProcNode = true; ProcedureInfo pri = tn.VEObject as ProcedureInfo; oi = OwnerInfo.GetByItemID(pri.ItemID, CheckOutType.Procedure); if (ui.IsAdministrator() || ui.IsSetAdministrator(pri.MyDocVersion)) @@ -852,6 +860,7 @@ namespace Volian.Controls.Library } else if (tn.VEObject as SectionInfo != null) { + isSectNode = true; // A step Section can contain other steps or can contain subsections (either step section // or word doc section). Also note that there can be a mix. // A word doc section can contain another subsection (either step section or word doc section), @@ -914,7 +923,16 @@ namespace Volian.Controls.Library else if (!tn.IsExpanded) cm.MenuItems.Add("Open", new EventHandler(mi_Click)); else - cm.MenuItems.Add("Collapse Procedures", new EventHandler(mi_Click)); + { // B2016-058 customize the "Collapse" menu text based on tree node type + string mtext = "Collapse"; // only the step or substep (RNOs, Cautions, Notes as well) will be collapsed + if (isFolderNode || isWrkDftNode) + mtext += " All Procedures"; // all expanded procedure nodes in all procedure sets are collapsed (folder and working draft nodes remain expanded) + else if (isProcNode) + mtext += " Procedure"; // only the current procedure node is collapsed + else if (isSectNode) + mtext += " Section"; // only the current section node is collapsed + cm.MenuItems.Add(mtext, new EventHandler(mi_Click)); + } #endregion //_MyLog.WarnFormat("Context Menu 3 - {0}", GC.GetTotalMemory(true)); @@ -1640,7 +1658,7 @@ namespace Volian.Controls.Library OnNodeSI(this, new vlnTreeEventArgs(tn, null, 0)); return; } - if (mi.Text == "Collapse Procedures") + if (mi.Text.StartsWith("Collapse")) { CollapseProcedures(); return; @@ -1815,6 +1833,7 @@ namespace Volian.Controls.Library break; } } + private bool _doingCollapseNode = false; // B2016-058 when collapse is done, it always calls the drag node event which doesn't appear to be needed private void CollapseProcedures() { CollapseProcedures(SelectedNode as VETreeNode); @@ -1826,10 +1845,14 @@ namespace Volian.Controls.Library if (tn.VEObject.GetType() == typeof(ProcedureInfo)) { tn.Collapse(); + _doingCollapseNode = true; // B2016-058 this will prevent a Drag Node error when collapsing an RNOs, Cautions, or Notes tree node return; } foreach (VETreeNode tnc in tn.Nodes) CollapseProcedures(tnc); + if (tn.VEObject as DocVersionInfo == null && tn.VEObject as FolderInfo == null) + tn.Collapse(); + _doingCollapseNode = true; // B2016-058 this will prevent a Drag Node error when collapsing an RNOs, Cautions, or Notes tree node } private void tv_RemoveChgIds() { @@ -3177,6 +3200,11 @@ namespace Volian.Controls.Library } private void tv_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) { + if (_doingCollapseNode) + { + _doingCollapseNode = false; + return; + } // Get drag node and select it try {