本文整理汇总了C#中System.Windows.Forms.TreeNodeCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.AddRange方法的具体用法?C# TreeNodeCollection.AddRange怎么用?C# TreeNodeCollection.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.AddRange方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SortTreeview
/// <summary>
/// Sort the treeview by name and child count.
/// </summary>
/// <param name="nodes">All child tree nodes.</param>
public static void SortTreeview(TreeNodeCollection nodes)
{
if (nodes.Count == 0)
return;
List<TreeNode> leaves = new List<TreeNode>();
List<TreeNode> branches = new List<TreeNode>();
foreach (TreeNode node in nodes)
{
if (node.GetNodeCount(false) > 0)
{
branches.Add(node);
SortTreeview(node.Nodes);
}
else
{
leaves.Add(node);
}
}
nodes.Clear();
if (leaves.Count > 0)
{
TreeNode[] leafArray = new TreeNode[leaves.Count];
leaves.CopyTo(leafArray, 0);
Comparison<TreeNode> compare = delegate(TreeNode tx, TreeNode ty)
{
if (tx.Text.Length != ty.Text.Length)
return tx.Text.Length - ty.Text.Length;
return string.Compare(tx.Text, ty.Text);
};
Array.Sort<TreeNode>(leafArray, compare);
nodes.AddRange(leafArray);
}
foreach (TreeNode node in branches)
{
nodes.Add(node);
}
}
示例2: AddTreeNodesFor
private void AddTreeNodesFor(FlatRedBall.Performance.Measurement.Section section, TreeNodeCollection treeNodeCollection)
{
TreeNode mostExpensive = null;
float mostExpensiveValue = -1; // so it is always smaller than even the smallest starting value:
double timeOfSubSections = 0;
List<TreeNode> list = new List<TreeNode>();
// This may be a revisited node:
foreach (TreeNode node in treeNodeCollection)
{
list.Add(node);
}
foreach (var subSection in section.Children)
{
TreeNode treeNode = null;
treeNode = CreateTreeNode(subSection);
if (subSection.Time > mostExpensiveValue)
{
mostExpensive = treeNode;
mostExpensiveValue = subSection.Time;
}
timeOfSubSections += subSection.Time;
list.Add(treeNode);
// adding tree nodes will just add times to existing
// tree nodes if they already exist
AddTreeNodesFor(subSection, treeNode.Nodes);
}
if (mostExpensive != null)
{
AppendTimeInMilliseconds(mostExpensive);
}
if(section.Time != 0)
{
double ratioAccountedFor = timeOfSubSections / section.Time;
if (ratioAccountedFor < .98)
{
TreeNode node = new TreeNode();
node.Text = "???? " + (100 - ratioAccountedFor*100).ToString("0.00") + "%";
list.Insert(0, node);
}
}
treeNodeCollection.AddRange(list.ToArray());
}
示例3: SortNodes
public void SortNodes(TreeNodeCollection nodes, bool recursive)
{
if (!isSorted) {
return;
}
TreeNode[] nodeArray = new TreeNode[nodes.Count];
nodes.CopyTo(nodeArray, 0);
Array.Sort(nodeArray, nodeSorter);
nodes.Clear();
nodes.AddRange(nodeArray);
if (recursive) {
foreach (TreeNode childNode in nodeArray) {
SortNodes(childNode.Nodes, true);
}
}
}
示例4: FillTreeNodes
private void FillTreeNodes(
TemplateNodeInfo parent,
TreeNodeCollection treeNodes
)
{
List<Tuple<TreeNode, ConcreteTemplateNodeDefinition>> pendingUpdateNodes =
new List<Tuple<TreeNode, ConcreteTemplateNodeDefinition>>();
Action action = () =>
{
treeNodes.Clear();
treeNodes.AddRange(parent.Childs.Select(n =>
{
ConcreteTemplateNodeDefinition nodedef;
TreeNode node = this._treeControl.CreateTreeViewNode(n, out nodedef);
pendingUpdateNodes.Add(new Tuple<TreeNode, ConcreteTemplateNodeDefinition>(node, nodedef));
return node;
}).ToArray());
if (parent.ChildrenAreLoadingNow)
{
treeNodes.Add(new TreeNode(this._treeControl._model.LocaleManager.GetLocalizedText(
"common", "NodesQueryingTreeNodeText")
)
{
ImageKey = "NodesQuerying",
SelectedImageKey = "NodesQuerying"
});
}
};
this._treeControl.SafeInvoke(action);
foreach (Tuple<TreeNode, ConcreteTemplateNodeDefinition> pendingNode in pendingUpdateNodes)
{
TreeNode node = pendingNode.Item1;
ConcreteTemplateNodeDefinition nodeDef = pendingNode.Item2;
if (parent.IsDisabled)
{
nodeDef.TemplateNode.IsDisabled = true;
nodeDef.NodeActivated = false;
}
nodeDef.NodeAvailable = nodeDef.IsAvailableForDatabase(Program.Model) ?? true;
if (!nodeDef.NodeAvailable)
{
this._treeControl.SetNotAvailableNode(node);
}
else
{
this._treeControl.SetNodeLoaded(node);
List<TemplateNodeUpdateJob> refreshJobs = nodeDef.TemplateNode.GetRefreshJob(true);
nodeDef.TemplateNode.HasActiveJobs = refreshJobs.Any(
job =>
job != null
&& !job.IsEmpty()
&& job.Enabled
);
UpdateTreeCounts(node, NodeUpdatingSource.LocallyOnly);
}
}
}
示例5: CreateNodeList
static void CreateNodeList(TreeNodeCollection nodes, object target)
{
var treeNodes = CreateNodes(target);
//Tracer.FlaggedLine(treeNodes.Dump());
//Tracer.ConditionalBreak(treeNodes.Length == 20,"");
nodes.Clear();
nodes.AddRange(treeNodes);
}
示例6: AddObjectsToTreeNodeCollection
public void AddObjectsToTreeNodeCollection(TreeNodeCollection col, List<OutlinerNode> nodes, Boolean addChildNodes)
{
if (nodes == null || nodes.Count == 0)
return;
List<TreeNode> newNodes = new List<TreeNode>();
foreach (OutlinerNode node in nodes)
{
if (!_treeNodes.ContainsKey(node) && Filter.ShowNode(node) && (!(ListMode == OutlinerListMode.Layer) || !HideGroupMembersLayerMode || !(node is OutlinerObject) || !((OutlinerObject)node).IsGroupMember))
{
TreeNode tn = CreateTreeNodeForOutlinerNode(node);
// Add node to outlinernode/treenode dictionary.
_treeNodes.Add(node, tn);
newNodes.Add(tn);
// Recursively go through childnodes.
if ((addChildNodes && node.ChildNodesCount > 0) || !(node is OutlinerObject))
AddObjectsToTreeNodeCollection(tn.Nodes, node.ChildNodes, addChildNodes);
}
}
col.AddRange(newNodes.ToArray());
}
示例7: SortNodes
public void SortNodes(TreeNodeCollection nodes, bool recursive)
{
if (this.isSorted)
{
TreeNode[] dest = new TreeNode[nodes.Count];
nodes.CopyTo(dest, 0);
Array.Sort<TreeNode>(dest, this.nodeSorter);
nodes.Clear();
nodes.AddRange(dest);
if (recursive)
{
foreach (TreeNode node in dest)
{
this.SortNodes(node.Nodes, true);
}
}
}
}
示例8: SortNodes
/// <summary>Sorts the specified nodes.</summary>
/// <param name="nodes">The nodes.</param>
/// <param name="recursive">if set to <c>true</c> recursively sorts the children nodes.</param>
protected void SortNodes(TreeNodeCollection nodes, bool recursive)
{
TreeNode[] array = new TreeNode[nodes.Count];
nodes.CopyTo(array, 0);
Array.Sort(array, base.TreeViewNodeSorter);
nodes.Clear();
nodes.AddRange(array);
if (recursive)
{
foreach (TreeNode child in array) SortNodes(child.Nodes, true);
}
}
示例9: RefreshNodes
/// <summary>Refreshes the specified nodes.</summary>
/// <param name="nodes">The nodes.</param>
private void RefreshNodes(TreeNodeCollection nodes)
{
TreeNode[] dest = new TreeNode[nodes.Count];
nodes.CopyTo(dest, 0);
nodes.Clear();
nodes.AddRange(dest);
}