当前位置: 首页>>代码示例>>C#>>正文


C# TreeNodeCollection.Insert方法代码示例

本文整理汇总了C#中System.Windows.Forms.TreeNodeCollection.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.Insert方法的具体用法?C# TreeNodeCollection.Insert怎么用?C# TreeNodeCollection.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TreeNodeCollection的用法示例。


在下文中一共展示了TreeNodeCollection.Insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertNode

 private static void InsertNode(TreeNodeCollection nodes, TreeNode newNode)
 {
     for (int i = 0; i < nodes.Count; i++)
         if (string.Compare(nodes[i].Text, newNode.Text, true) >= 0)
         {
             nodes.Insert(i, newNode);
             return;
         }
     nodes.Add(newNode);
 }
开发者ID:bgarrels,项目名称:betterpoeditor,代码行数:10,代码来源:frmSelectLanguage.cs

示例2: AddTreeNodeIntoTree

        protected void AddTreeNodeIntoTree(ConnectionPointContainer container, TreeNodeCollection nodes, PluginConfigItem theItem, PluginMenuPath thePath, IList<PluginMenuItemPart> thePaths, ExecutePluginCallback callback)
        {
            if (thePaths.Count < 1) return;

            PluginMenuItemPart firstPart = thePaths[0];
            PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, nodes);
            IList<PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths);

            if (!menuStruct.IsCreate)
            {
                AddTreeNodeIntoTree(container, nodes[menuStruct.Index].Nodes,
                       theItem, thePath, otherParts, callback);
            }
            else
            {
                TreeNode theMenuItem = new TreeNode(firstPart.TextStyle.Text);
                CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex));

                nodes.Insert(
                    menuStruct.Index,
                    theMenuItem
                );

                if (thePaths.Count > 1)
                {
                    AddTreeNodeIntoTree(container, theMenuItem.Nodes, theItem, thePath, otherParts, callback);
                }
                else
                {
                    theMenuItem.Name = theItem.Url;
                    theMenuItem.Tag = new object[] { theItem, callback };

                    theMenuItem.TreeView.NodeMouseClick -= new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick);
                    theMenuItem.TreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick);

                    return;
                }
            }
        }
开发者ID:nateliu,项目名称:StarSharp,代码行数:39,代码来源:PluginMenuTreeNodeBuilder.cs

示例3: InsertTreeNode

            private void InsertTreeNode(NavigatorPage page, TreeNodeCollection treeNodes, int depth, Dictionary<NavigatorPage, TreeNode> pageMap)
            {
                PathSegment segment = page.Path.Segments[depth];

                // see if node for this segment already exists
                TreeNode treeNode = CollectionUtils.FirstElement(treeNodes.Find(segment.LocalizedText, false));
                if (treeNode == null)
                {
                    // need to create the node, however, we can't just add it to the end of the child collection,
                    // we need to insert it at the appropriate place, which is just after the last "visited" node
                    // find first unvisited node, which indicates the insertion point
                    int i = 0;
                    for (; i < treeNodes.Count; i++)
                    {
                        if (!_visitedNodes.Contains(treeNodes[i]))
                            break;
                    }

                    // insert new node
                    treeNode = treeNodes.Insert(i, segment.LocalizedText, segment.LocalizedText);
                }

                if (depth < page.Path.Segments.Count - 1)
                {
                    // recur on next path segment
                    InsertTreeNode(page, treeNode.Nodes, depth + 1, pageMap);
                }
                else
                {
                    // this is the last path segment
                    treeNode.Tag = page;
                    pageMap.Add(page, treeNode);
                }

                // remember that this node has now been "visited"
                _visitedNodes.Add(treeNode);

            }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:38,代码来源:NavigatorComponentContainerControl.cs

示例4: AddToExplorer

        private void AddToExplorer(ItemStatus value, TreeNodeCollection nodes, int position)
        {
            TreeNode node = null;

            // First attempt to find a node with a matching name
            foreach (TreeNode nodeToCheck in nodes)
            {
                if (object.Equals((nodeToCheck.Tag as ItemStatus), value))
                {
                    node = nodeToCheck;
                    break;
                }
            }

            string nodeKey = value.Identifier.ToString();
            string nodeText = value.Name + (value.Description!=null? "[" + value.Description + "]" : "");
            bool newNode = false;
            if (node == null)
            {
                // Need to add a whole new node
                node = nodes.Insert(position, nodeKey, nodeText);
                newNode = true;
            }
            newKeys.Add(nodeKey);

            // Update the node
            node.Tag = value;
            node.Text = nodeText;
            node.ImageKey = value.Status.ToString();
            node.SelectedImageKey = node.ImageKey;

            // Update all the child items
            int childPosition = 0;
            foreach (ItemStatus childItem in value.ChildItems)
            {
                AddToExplorer(childItem, node.Nodes, childPosition++);
            }
            if (newNode) node.Expand();
        }
开发者ID:sbukhtiyarov,项目名称:CruiseControl.NET,代码行数:39,代码来源:CurrentStatusWindow.cs

示例5: InsertIntoSortedTree

        /// <summary>
        /// Inserts a nodes into a nodes collection, sorted by name.
        /// </summary>
        /// <param name="nodes">
        /// The collection of nodes to insert into.
        /// </param>
        /// <param name="nodeToInsert">
        /// The node to insert.
        /// </param>
        private static void InsertIntoSortedTree(TreeNodeCollection nodes, TreeNode nodeToInsert)
        {
            Param.AssertNotNull(nodes, "nodes");
            Param.AssertNotNull(nodeToInsert, "nodeToInsert");

            int index = 0;
            for (; index < nodes.Count; ++index)
            {
                if (string.Compare(nodes[index].Text, nodeToInsert.Text, StringComparison.Ordinal) > 0)
                {
                    break;
                }
            }

            Debug.Assert(index <= nodes.Count, "The algoritm did not find a valid insertion position.");
            nodes.Insert(index, nodeToInsert);
        }
开发者ID:kjata30,项目名称:StyleCop,代码行数:26,代码来源:AnalyzersOptions.cs

示例6: AddNode

        /// <summary>
        /// Insert the node into the collection in the correct position based
        /// on its name
        /// </summary>
        /// <param name="nodes">The node collection</param>
        /// <param name="newNode">The new node</param>
        private static void AddNode(TreeNodeCollection nodes, TreeNode newNode)
        {
            NodeData compareData, newNodeData = (NodeData)newNode.Tag;
            int idx;

            for(idx = 0; idx < nodes.Count; idx++)
            {
                compareData = (NodeData)nodes[idx].Tag;

                if(compareData.BuildAction > BuildAction.Folder)
                    continue;

                if(compareData.BuildAction == BuildAction.Folder &&
                  newNodeData.BuildAction != BuildAction.Folder)
                    continue;

                if(compareData.BuildAction != BuildAction.Folder &&
                  newNodeData.BuildAction == BuildAction.Folder)
                    break;

                if(String.Compare(nodes[idx].Text, newNode.Text,
                  StringComparison.OrdinalIgnoreCase) > 0)
                    break;
            }

            if(idx < nodes.Count)
                nodes.Insert(idx, newNode);
            else
                nodes.Add(newNode);
        }
开发者ID:codemonster234,项目名称:scbuilder,代码行数:36,代码来源:FileTree.cs

示例7: InsertNewNode

        private TreeNode InsertNewNode(TreeNodeCollection collection, string nodetext)
        {
            TreeNode newnode = NewTreeNode(nodetext);

            int insertat = 0;
            int min = 0;
            int max = collection.Count - 1;
            string haystack = null;
            bool found;
            if (collection.Count > 0 && object.ReferenceEquals(collection, treeView1.Nodes)
                && collection[max - 1].Text == UnknownId)
                max--;

            while (StringSearchHelper(nodetext, haystack, ref min, ref max, out insertat, out found))
                haystack = collection[insertat].Text;

            if (insertat < collection.Count)
                collection.Insert(insertat, newnode);
            else
                collection.Add(newnode);
            return newnode;
        }
开发者ID:markmanching,项目名称:virtual-artisan-s3mods,代码行数:22,代码来源:Form1.cs

示例8: InsertPageSorted

        private void InsertPageSorted(TreeNodeCollection nodes, TreeNode treeNode)
        {
            for (int i = 0; i < nodes.Count; i++)
            {
                if (ComparePage(nodes[i], treeNode) < 0)
                {
                    nodes.Insert(i, treeNode);
                    return;
                }
            }

            nodes.Add(treeNode);
        }
开发者ID:netide,项目名称:netide,代码行数:13,代码来源:ToolsOptionsForm.cs

示例9: AddLayerNode

        /// <summary>
        /// Adding a new layerObj to the mapObj.
        /// </summary>
        /// <param name="nodes">The TreeNodeCollection of the parent object.</param>
        /// <param name="layerHolder">Wrapper class containing the layerObj and the parent object.</param>
        /// <param name="showRoot">A flag indicating whether the root object should be displayed or not.</param>
        private void AddLayerNode(TreeNodeCollection nodes, MapObjectHolder layerHolder, bool showRoot, ImageList imageList)
        {
            layerObj layer = layerHolder;

            // adding the layer based on the icon of the first class
            if (showRoot)
            {
                TreeNode layerNode = new TreeNode(layer.name, imageList.Images.Count,
                    imageList.Images.Count);
                layerNode.Checked = (layer.status != mapscript.MS_OFF);
                layerNode.Tag = layerHolder; // wire up the layer into the node
                if (MapUtils.HasMetadata(layer, "link"))
                {
                    layerNode.NodeFont = new Font(treeView.Font, FontStyle.Underline | FontStyle.Italic);
                    layerNode.ForeColor = Color.Blue;
                }
                nodes.Insert(0, layerNode);
                nodes = layerNode.Nodes;

                if (layer.type == MS_LAYER_TYPE.MS_LAYER_RASTER)
                    imageList.Images.Add(global::MapLibrary.Properties.Resources.raster);
            }

            for (int j = 0; j < layer.numclasses; j++)
            {
                classObj layerclass = layer.getClass(j);
                AddClassNode(nodes, new MapObjectHolder(layerclass, layerHolder), imageList);

                if (!showClasses || string.Compare(layer.styleitem, "AUTO", true) == 0)
                    break;
            }
        }
开发者ID:4g0st1n0,项目名称:MapManager,代码行数:38,代码来源:LayerControl.cs

示例10: AddItem

        private void AddItem(TreeNodeCollection lst, BaseObject obj)
        {
            LoadTreeNodeChilds();

            if (obj is DataBase.Category)
            {
                DataBase.Category c = (DataBase.Category) obj;

                int pos = 0;

                for (pos = 0; (pos < lst.Count) && (lst[pos] is TreeNodeCategory); pos++)
                {
                    TreeNodeCategory cc = (TreeNodeCategory) lst[pos];

                    if (cc.cat.Name.CompareTo(c.Name) >= 0)
                    {
                        lst.Insert(pos, new TreeNodeCategory(this.db, c, this.trv));
                        return;
                    }
                }

                lst.Insert(pos, new TreeNodeCategory(this.db, c, this.trv));
            }
            else if (obj is DataBase.Box)
            {
                DataBase.Box b = (DataBase.Box) obj;

                int pos = 0;

                for (pos = 0; pos < lst.Count; pos++)
                {
                    if (lst[pos] is TreeNodeBox)
                    {
                        TreeNodeBox bb = (TreeNodeBox) lst[pos];

                        if (bb.InternalBox.Name.CompareTo(b.Name) >= 0)
                        {
                            lst.Insert(pos, new TreeNodeBox(this.db, b, this.trv));
                            return;
                        }
                    }
                }

                lst.Insert(pos, new TreeNodeBox(this.db, b, this.trv));
            }
        }
开发者ID:drme,项目名称:disks-db,代码行数:46,代码来源:TreeNodeCategory.cs

示例11: Recurse

        public void Recurse(String aRoot, TreeNodeCollection aNodes)
        {
            IEnumerator items;
              mDataStore.GetElements(aRoot, out items);
              items.Reset();

              ManticoreTreeNode node;

              while (items.MoveNext())
              {
            // |id| is the item's unique identifier within the DataStore.
            // The handling code can use this to probe for more information
            // about the selected item.
            CommandTarget current = items.Current as CommandTarget;
            if (current != null)
            {
              // Determine based on conditions defined by the |TreeView|
              // whether or not this node should be built.
              if (!mTreeView.ShouldBuild(current))
            continue;

              String id = current.Data as String;

              int idKey = id.GetHashCode();

              if (!mNodes.ContainsKey(idKey))
              {
            node = new ManticoreTreeNode(current.Label, id);

            int imageIndex = mTreeView.GetIconIndex(current);
            if (imageIndex > -1)
              node.ImageIndex = imageIndex;
            aNodes.Insert(mInsertionPoint++, node);
            if (current.IsContainer && current.IsOpen)
              node.Expand();
            mNodes.Add(id.GetHashCode(), node);

            // If we're a container, recurse
            if (current.IsContainer)
              Recurse(id, node.Nodes);
              }
            }
              }

              ResetInsertionPoint();
        }
开发者ID:nfan,项目名称:Jaxer,代码行数:46,代码来源:TreeBuilder.cs

示例12: Add

 public void Add(TreeNodeCollection nodes, TreeNode node)
 {
     if (TestList.InvokeRequired == true)
     {
         this.Invoke(new AddNodeCB(Add), new object[] { nodes, node });
         return;
     }
     nodes.Insert( FindIndex( nodes, node ), node );
 }
开发者ID:powerumc,项目名称:vutpp,代码行数:9,代码来源:UnitTestBrowser.cs

示例13: AddItem

        private void AddItem(TreeNodeCollection lst, BaseObject obj)
        {
            LoadTreeNodeChilds();

            if (obj is DisksDB.DataBase.Disk)
            {
                DisksDB.DataBase.Disk d = (DisksDB.DataBase.Disk)obj;

                int pos = 0;

                for (pos = 0; (pos < lst.Count) && (lst[pos] is TreeNodeDisk); pos++)
                {
                    TreeNodeDisk dd = (TreeNodeDisk)lst[pos];

                    if (dd.InternalDisk.Name.CompareTo(d.Name) >= 0)
                    {
                        lst.Insert(pos, new TreeNodeDisk(d, this.db));
                        return;
                    }
                }

                lst.Insert(pos, new TreeNodeDisk(d, this.db));
            }
        }
开发者ID:drme,项目名称:disks-db,代码行数:24,代码来源:TreeNodeBox.cs

示例14: AddTreeNode

        protected void AddTreeNode(TreeNodeCollection collection, TreeNode child)
        {
            int insertPoint = 0;

            for (int i = 0; i < collection.Count; i++)
            {
                if (child.ImageIndex != 1 && collection[i].ImageIndex == 1)
                    break;

                if (child.ImageIndex == collection[i].ImageIndex && String.Compare(collection[i].Text, child.Text) > 0)
                    break;

                insertPoint++;
            }

            collection.Insert(insertPoint, child);
        }
开发者ID:mustafamagdy,项目名称:EasyConnect,代码行数:17,代码来源:HistoryWindow.cs

示例15: RecursiveAddChunkNode

        private void RecursiveAddChunkNode(TreeNodeCollection xiNodes, int xiIndex, Chunk xiChunk)
        {
            TreeNode lNode = xiNodes.Insert(xiIndex, xiChunk.Name);
              //record the mapping on the two objects, for easy reference later
              //no doubt, this will play merry hell with the GC if you load lots
              //of different levels...
              lNode.Tag = xiChunk;
              xiChunk.TreeNode = lNode;

              //recurse
              foreach (Chunk child in xiChunk.GetChildren())
              {
            RecursiveAddChunkNode(lNode.Nodes, child);
              }
        }
开发者ID:RichardBradley,项目名称:MMEd,代码行数:15,代码来源:MainForm.cs


注:本文中的System.Windows.Forms.TreeNodeCollection.Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。