SIL.FieldWorks.Common.Framework.DetailControls.Slice.Slice.GenerateChildren C# (CSharp) Méthode

GenerateChildren() public méthode

public GenerateChildren ( XmlNode node, XmlNode caller, ICmObject obj, int indent, int &insPos, ArrayList path, ObjSeqHashMap reuseMap, bool fUsePersistentExpansion ) : void
node System.Xml.XmlNode
caller System.Xml.XmlNode
obj ICmObject
indent int
insPos int
path System.Collections.ArrayList
reuseMap ObjSeqHashMap
fUsePersistentExpansion bool
Résultat void
		public virtual void GenerateChildren(XmlNode node, XmlNode caller, ICmObject obj, int indent,
			ref int insPos, ArrayList path, ObjSeqHashMap reuseMap, bool fUsePersistentExpansion)
		{
			CheckDisposed();

			// If node has children, figure what to do with them...
			// XmlNodeList children = node.ChildNodes; // unused variable
			DataTree.NodeTestResult ntr;
			// We may get child nodes from either the node itself or the calling part, but currently
			// don't try to handle both; we consider the children of the caller, if any, to override
			// the children of the node (but not unify with them, since a different kind of children
			// are involved).
			// A newly created slice is always in state ktisFixed, but that is not appropriate if it
			// has children from either source. However, a node which notionally has children may in fact have nothing to
			// show, perhaps because a sequence is empty. First evaluate this, and if true, set it
			// to ktisCollapsedEmpty.
			//bool fUseChildrenOfNode;
			XmlNode indentNode = null;
			if (caller != null)
				indentNode = caller.SelectSingleNode("indent");
			if (indentNode != null)
			{
				// Similarly pretest for children of caller, to see whether anything is produced.
				ContainingDataTree.ApplyLayout(obj, this, indentNode, indent + ExtraIndent(indentNode), insPos, path, reuseMap,
					true, out ntr);
				//fUseChildrenOfNode = false;
			}
			else
			{
				int insPosT = insPos; // don't modify the real one in this test call.
				ntr = ContainingDataTree.ProcessPartChildren(node, path, reuseMap, obj, this, indent + ExtraIndent(node), ref insPosT,
					true, null, false, node);
				//fUseChildrenOfNode = true;
			}

			if (ntr == DataTree.NodeTestResult.kntrNothing)
				Expansion = DataTree.TreeItemState.ktisFixed; // probably redundant, but play safe
			else if (ntr == DataTree.NodeTestResult.kntrPossible)
			{
				// It could have children but currently can't: we always show this as collapsedEmpty.
				Expansion = DataTree.TreeItemState.ktisCollapsedEmpty;
			}
			// Remaining branches are for a node that really has children.
			else if (Expansion == DataTree.TreeItemState.ktisCollapsed)
			{
				// Reusing a node that was collapsed (and it has something to expand):
				// leave it that way (whatever the spec says).
			}
			else
			{
				// It has children: decide whether to expand them.
				// Old code does not expand by default, couple of ways to override.
				//			else if (Expansion == DataTree.TreeItemState.ktisExpanded
				//				|| (fUseChildrenOfNode && XmlUtils.GetOptionalAttributeValue(node, "expansion") == "expanded")
				//				|| (XmlUtils.GetOptionalAttributeValue(caller, "expansion") == "expanded")
				//				|| Expansion == DataTree.TreeItemState.ktisCollapsedEmpty)
				bool fExpand = XmlUtils.GetOptionalAttributeValue(node, "expansion") != "doNotExpand";
				if (fUsePersistentExpansion && m_mediator != null) // mediator null only in testing?
				{
					Expansion = DataTree.TreeItemState.ktisCollapsed; // Needs to be an expandable state to have ExpansionStateKey.
					fExpand = m_mediator.PropertyTable.GetBoolProperty(ExpansionStateKey, fExpand);
				}
				if (fExpand)
				{
					// Record the expansion state and generate the children.
					Expansion = DataTree.TreeItemState.ktisExpanded;
					CreateIndentedNodes(caller, obj, indent, ref insPos, path, reuseMap, node);
				}
				else
				{
					// Record expansion state and skip generating children.
					Expansion = DataTree.TreeItemState.ktisCollapsed;
				}
			}
		}