B2016-058 Context menu at the procedure level will read “Collapse Procedure”, at the section level it will read “Collapse Section”, at the step and sub step levels will read “Collapse”.

This commit is contained in:
John Jenko 2018-09-27 13:53:57 +00:00
parent d0ce429883
commit e5938b1815

View File

@ -620,6 +620,11 @@ namespace Volian.Controls.Library
OwnerInfoList oil = null; OwnerInfoList oil = null;
OwnerInfo oi = null; OwnerInfo oi = null;
FolderInfo fi = 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; VETreeNode tn = this.GetNodeAt(new Point(e.X, e.Y)) as VETreeNode;
if (tn != null) if (tn != null)
{ {
@ -641,6 +646,7 @@ namespace Volian.Controls.Library
#region Menu_New #region Menu_New
if (tn.VEObject as FolderInfo != null) if (tn.VEObject as FolderInfo != null)
{ {
isFolderNode = true;
// For Folders, if no children, can add either docversion or folder. If children are // 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 // folders then can only add another folder, and if children are docversions can only
// add docversion. // add docversion.
@ -672,6 +678,7 @@ namespace Volian.Controls.Library
} }
else if (tn.VEObject as DocVersionInfo != null) // DocVersions can only contain procs else if (tn.VEObject as DocVersionInfo != null) // DocVersions can only contain procs
{ {
isWrkDftNode = true;
//_MyLog.WarnFormat("Context Menu 1c - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 1c - {0}", GC.GetTotalMemory(true));
DocVersionInfo dvi = tn.VEObject as DocVersionInfo; DocVersionInfo dvi = tn.VEObject as DocVersionInfo;
if (ui.IsAdministrator() || ui.IsSetAdministrator(dvi)) 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 else if (tn.VEObject as ProcedureInfo != null) // Procs can only contain sections
{ {
isProcNode = true;
ProcedureInfo pri = tn.VEObject as ProcedureInfo; ProcedureInfo pri = tn.VEObject as ProcedureInfo;
oi = OwnerInfo.GetByItemID(pri.ItemID, CheckOutType.Procedure); oi = OwnerInfo.GetByItemID(pri.ItemID, CheckOutType.Procedure);
if (ui.IsAdministrator() || ui.IsSetAdministrator(pri.MyDocVersion)) if (ui.IsAdministrator() || ui.IsSetAdministrator(pri.MyDocVersion))
@ -852,6 +860,7 @@ namespace Volian.Controls.Library
} }
else if (tn.VEObject as SectionInfo != null) else if (tn.VEObject as SectionInfo != null)
{ {
isSectNode = true;
// A step Section can contain other steps or can contain subsections (either step section // 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. // 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), // 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) else if (!tn.IsExpanded)
cm.MenuItems.Add("Open", new EventHandler(mi_Click)); cm.MenuItems.Add("Open", new EventHandler(mi_Click));
else 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 #endregion
//_MyLog.WarnFormat("Context Menu 3 - {0}", GC.GetTotalMemory(true)); //_MyLog.WarnFormat("Context Menu 3 - {0}", GC.GetTotalMemory(true));
@ -1640,7 +1658,7 @@ namespace Volian.Controls.Library
OnNodeSI(this, new vlnTreeEventArgs(tn, null, 0)); OnNodeSI(this, new vlnTreeEventArgs(tn, null, 0));
return; return;
} }
if (mi.Text == "Collapse Procedures") if (mi.Text.StartsWith("Collapse"))
{ {
CollapseProcedures(); CollapseProcedures();
return; return;
@ -1815,6 +1833,7 @@ namespace Volian.Controls.Library
break; 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() private void CollapseProcedures()
{ {
CollapseProcedures(SelectedNode as VETreeNode); CollapseProcedures(SelectedNode as VETreeNode);
@ -1826,10 +1845,14 @@ namespace Volian.Controls.Library
if (tn.VEObject.GetType() == typeof(ProcedureInfo)) if (tn.VEObject.GetType() == typeof(ProcedureInfo))
{ {
tn.Collapse(); tn.Collapse();
_doingCollapseNode = true; // B2016-058 this will prevent a Drag Node error when collapsing an RNOs, Cautions, or Notes tree node
return; return;
} }
foreach (VETreeNode tnc in tn.Nodes) foreach (VETreeNode tnc in tn.Nodes)
CollapseProcedures(tnc); 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() private void tv_RemoveChgIds()
{ {
@ -3177,6 +3200,11 @@ namespace Volian.Controls.Library
} }
private void tv_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e) private void tv_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{ {
if (_doingCollapseNode)
{
_doingCollapseNode = false;
return;
}
// Get drag node and select it // Get drag node and select it
try try
{ {