當前位置: 首頁>>代碼示例>>C#>>正文


C# TreeNodeCollection.AddRange方法代碼示例

本文整理匯總了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);
            }
        }
開發者ID:KeyleXiao,項目名稱:behaviac,代碼行數:50,代碼來源:UIUtilities.cs

示例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());

        }
開發者ID:vchelaru,項目名稱:FlatRedBall,代碼行數:55,代碼來源:TreeViewManager.cs

示例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);
				}
			}
		}
開發者ID:Bombadil77,項目名稱:SharpDevelop,代碼行數:17,代碼來源:ExtTreeView.cs

示例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);
				}
			}
		}
開發者ID:saycale,項目名稱:MSSQLServerAuditor,代碼行數:70,代碼來源:TreeTaskManager.cs

示例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);
 }
開發者ID:hahoyer,項目名稱:HWClassLibrary.cs,代碼行數:8,代碼來源:Extender.cs

示例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());
      }
開發者ID:Pjanssen,項目名稱:Outliner,代碼行數:26,代碼來源:TreeView.cs

示例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);
             }
         }
     }
 }
開發者ID:vanloc0301,項目名稱:mychongchong,代碼行數:18,代碼來源:ExtTreeView.cs

示例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);
            }
        }
開發者ID:sagar1589,項目名稱:Delta.Cryptography,代碼行數:16,代碼來源:TreeViewEx.cs

示例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);
 }
開發者ID:sagar1589,項目名稱:Delta.Cryptography,代碼行數:9,代碼來源:TreeViewEx.cs


注:本文中的System.Windows.Forms.TreeNodeCollection.AddRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。