This commit is contained in:
parent
9ec318366c
commit
c7383915ec
@ -405,10 +405,11 @@ namespace Volian.Controls.Library
|
||||
#region MenuSupport
|
||||
private void tv_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
if(!_AdjustingTree)
|
||||
if (!_AdjustingTree)
|
||||
OnNodeSelectionChange(sender, new vlnTreeEventArgs(e.Node));
|
||||
}
|
||||
// use to determine which menu items have been selected for those tree nodes
|
||||
|
||||
// that allow more than one type of operation associated with their selection.
|
||||
public enum MenuSelections : int
|
||||
{
|
||||
@ -472,8 +473,19 @@ namespace Volian.Controls.Library
|
||||
// insert process.
|
||||
cm.MenuItems.Add("Insert Section Before", new EventHandler(mi_Click));
|
||||
cm.MenuItems.Add("Insert Section After", new EventHandler(mi_Click));
|
||||
if (si.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections) cm.MenuItems.Add("New Subsection", new EventHandler(mi_Click));
|
||||
if (si.IsStepSection) cm.MenuItems.Add("New Step", new EventHandler(mi_Click));
|
||||
if (!si.IsAutoTOCSection)
|
||||
{
|
||||
bool meta = si.ActiveFormat.PlantFormat.FormatData.SectData.UseMetaSections;
|
||||
if (meta) cm.MenuItems.Add("New Subsection", new EventHandler(mi_Click));
|
||||
// if this section has subsections, then be sure that the 'editable' data config
|
||||
// is set to allow new step creation.
|
||||
if (si.IsStepSection)
|
||||
{
|
||||
SectionConfig sc = si.MyConfig as SectionConfig;
|
||||
if (si.Sections==null || si.Sections.Count==0 || (meta && sc != null && si.Sections != null && si.Sections.Count > 0 && sc.SubSection_Edit == "Y"))
|
||||
cm.MenuItems.Add("New Step", new EventHandler(mi_Click));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tn.VEObject as StepInfo != null)
|
||||
{
|
||||
@ -1070,14 +1082,76 @@ namespace Volian.Controls.Library
|
||||
int s1 = -1;
|
||||
if (!(_LastProcedureInfo == null) || !(_LastSectionInfo == null))
|
||||
{
|
||||
// May need to create 'pseudo' nodes, for the 'Steps' and 'Sections' grouping tree nodes.
|
||||
// If no grouping nodes exist off a section (we are adding a subsection), then
|
||||
// add a 'pseudo' node.
|
||||
// If step(s) exists, but not a section, then need 'pseudo' nodes, i.e. 'Steps' and 'Sections'
|
||||
// tree nodes.
|
||||
// Otherwise, the 'Sections' pseudo node will exist.
|
||||
// Note that this check has to be done before the section is made, otherwise the item will
|
||||
// have sections, i.e. the one getting added.
|
||||
bool doPseudo = false;
|
||||
if (_LastItemInfo.IsSection) // if adding off of a procedure, don't add pseuo.
|
||||
{
|
||||
if (SelectedNode.Nodes.Count == 0)
|
||||
doPseudo = true;
|
||||
else if (SelectedNode.Nodes.Count > 0)
|
||||
{
|
||||
// Check to see if sections already exist, if so, the pseudo node will too.
|
||||
bool hasMetaSubs = _LastItemInfo.Sections != null && _LastItemInfo.Sections.Count > 0;
|
||||
if (!hasMetaSubs) doPseudo = true;
|
||||
}
|
||||
}
|
||||
using (Section section = Section.MakeSection(_LastItemInfo, _LastItemInfo.LastChild(E_FromType.Section), null, "New Section", 10000))
|
||||
{
|
||||
ShowBrokenRules(section.BrokenRulesCollection);
|
||||
SetLastValues(SectionInfo.Get(section.ItemID));
|
||||
if (OnNodeOpenProperty(this, new vlnTreePropertyEventArgs("New Section", section.SectionConfig)) == DialogResult.OK)
|
||||
{
|
||||
tn = new VETreeNode(_LastSectionInfo);
|
||||
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
|
||||
if (!doPseudo)
|
||||
{
|
||||
tn = new VETreeNode(_LastSectionInfo);
|
||||
SelectedNode.Nodes.Add(tn); // add tree node to end of list.
|
||||
}
|
||||
else
|
||||
{
|
||||
// may have to add a 'steps' node if a step(s) already exist...
|
||||
ItemInfo ii = (SelectedNode as VETreeNode).VEObject as ItemInfo;
|
||||
int cpindx = 0;
|
||||
if (SelectedNode.Nodes.Count>0)
|
||||
{
|
||||
ItemInfo ichld1 = (SelectedNode.Nodes[0] as VETreeNode).VEObject as ItemInfo;
|
||||
if (ichld1.IsStep)
|
||||
{
|
||||
// find associated part node:
|
||||
foreach (PartInfo pi in ii.MyContent.ContentParts)
|
||||
{
|
||||
if (pi.FromType == (int)E_FromType.Step)
|
||||
{
|
||||
// A 'Steps' pseudo node must be added and any existing steps
|
||||
// must be moved below it:
|
||||
VETreeNode tnStepPart = new VETreeNode(ii.MyContent.ContentParts[cpindx]);
|
||||
foreach (TreeNode tnc in SelectedNode.Nodes)
|
||||
{
|
||||
TreeNode cloned = (TreeNode)tnc.Clone();
|
||||
tnStepPart.Nodes.Add(cloned);
|
||||
}
|
||||
SelectedNode.Nodes.Clear();
|
||||
SelectedNode.Nodes.Add(tnStepPart);
|
||||
break;
|
||||
}
|
||||
cpindx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// At this level, there will only be 'Steps' or 'Sections' nodes. So, use
|
||||
// the ContentParts[indx] that was not used to create the pseudo node.
|
||||
if (cpindx == 1) cpindx = 0;
|
||||
VETreeNode tnPart = new VETreeNode(ii.MyContent.ContentParts[cpindx]);
|
||||
SelectedNode.Nodes.Add(tnPart);
|
||||
tn = new VETreeNode(_LastSectionInfo);
|
||||
tnPart.Nodes.Add(tn); // add tree node to end of list.
|
||||
}
|
||||
}
|
||||
else
|
||||
s1 = section.ItemID;
|
||||
|
Loading…
x
Reference in New Issue
Block a user