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); }
private void OnMoveUpButtonClick() { System.Windows.Forms.TreeNode selectedNode = this._treeView.SelectedNode; if (selectedNode != null) { System.Windows.Forms.TreeNode prevNode = selectedNode.PrevNode; System.Windows.Forms.TreeNodeCollection nodes = this._treeView.Nodes; if (selectedNode.Parent != null) { nodes = selectedNode.Parent.Nodes; } if (prevNode != null) { selectedNode.Remove(); nodes.Insert(prevNode.Index, selectedNode); this._treeView.SelectedNode = selectedNode; } } }
private void OnMoveDownButtonClick() { this.ValidatePropertyGrid(); System.Windows.Forms.TreeNode selectedNode = this._treeView.SelectedNode; if (selectedNode != null) { System.Windows.Forms.TreeNode nextNode = selectedNode.NextNode; System.Windows.Forms.TreeNodeCollection nodes = this._treeView.Nodes; if (selectedNode.Parent != null) { nodes = selectedNode.Parent.Nodes; } if (nextNode != null) { selectedNode.Remove(); nodes.Insert(nextNode.Index + 1, selectedNode); this._treeView.SelectedNode = selectedNode; } } }
private void OnUnindentButtonClick() { System.Windows.Forms.TreeNode selectedNode = this._treeView.SelectedNode; if (selectedNode != null) { System.Windows.Forms.TreeNode parent = selectedNode.Parent; if (parent != null) { System.Windows.Forms.TreeNodeCollection nodes = this._treeView.Nodes; if (parent.Parent != null) { nodes = parent.Parent.Nodes; } if (parent != null) { selectedNode.Remove(); nodes.Insert(parent.Index + 1, selectedNode); this._treeView.SelectedNode = selectedNode; } } } }
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; } } }
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); }
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); }
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); } }
//INSTANT C# NOTE: C# does not support optional parameters. Overloaded method(s) are created above. //ORIGINAL LINE: Private Sub AddToTreeview(ByVal nodes As TreeNodeCollection, ByVal node As GISATreeNode, Optional ByVal insertAt As Integer = -1) private void AddToTreeview(TreeNodeCollection nodes, GISATreeNode node, int insertAt) { if (insertAt == -1) { nodes.Add(node); } else { nodes.Insert(insertAt, node); } AddToTable(node); }
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(); }
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); }
/// <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); }
/// <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); }
private static void InsertIntoSortedTree(TreeNodeCollection nodes, TreeNode nodeToInsert) { int index = 0; while (index < nodes.Count) { if (string.Compare(nodes[index].Text, nodeToInsert.Text, StringComparison.Ordinal) > 0) { break; } index++; } nodes.Insert(index, nodeToInsert); }
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)); } }
private static void InsertNodePreservingOrder(TreeNodeCollection nodes, int index, TreeNode tagNode) { if (index < 0) nodes.Add(tagNode); else nodes.Insert(index, tagNode); }
/// <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; } }
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)); } }
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(); }
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 ); }
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; }
private void MoveNode(int index, TreeNodeCollection nodes, TreeNode targetNode) { nodes.Remove(targetNode); nodes.Insert(index, targetNode); OnMovedNode(targetNode); }
private void UpdateNodesInternal(TreeNodeCollection nodes) { List<TreeItem> children = GetChildren().ToList(); Dictionary<TreeItem, bool> shouldShow = children.ToDictionary(x => x, x => true); int i, j; for (i = 0, j = 0; j < children.Count; ) { TreeNode node = i < nodes.Count ? nodes[i] : null; TreeItem item = node != null ? node.Tag as TreeItem : null; if (children[j].Equals(item)) { children[j].UpdateInternal(node); i++; j++; } else if (node == null || (item != null && shouldShow.ContainsKey(item))) { nodes.Insert(i, children[j].CreateNode()); i++; j++; } else { nodes.RemoveAtWithSelectionBackup(i, nodes[i].TreeView, nodes[i].Parent); } } for (int k = nodes.Count - 1; k >= i; k--) nodes.RemoveAtWithSelectionBackup(k, nodes[k].TreeView, nodes[k].Parent); }
private void AddItem(TreeNodeCollection lst, BaseObject obj) { LoadTreeNodeChilds(); if (obj is DisksDB.DataBase.Image) { DisksDB.DataBase.Image img = (DisksDB.DataBase.Image)obj; int pos = 0; for (pos = 0; (pos < lst.Count) && (lst[pos] is TreeNodeImage); pos++) { TreeNodeImage ti = (TreeNodeImage)lst[pos]; if (ti.InternalImage.Name.CompareTo(img.Name) >= 0) { lst.Insert(pos, new TreeNodeImage(img, this.imgFact)); return; } } lst.Insert(pos, new TreeNodeImage(img, this.imgFact)); } }
private void SwapTreeNodes(TreeNodeCollection collection, int a, int b) { var aNode = collection[a]; var bNode = collection[b]; collection.Remove(aNode); collection.Remove(bNode); collection.Insert(a, bNode); collection.Insert(b, aNode); }
private void Sort(TreeNodeCollection treeNodeCollection) { int lastObjectExclusive = treeNodeCollection.Count; int whereObjectBelongs; for (int i = 0 + 1; i < lastObjectExclusive; i++) { if (StateTreeNodeExtensionMethods.Compare(treeNodeCollection[i], treeNodeCollection[i - 1]) < 0) { if (i == 1) { TreeNode treeNode = treeNodeCollection[i]; treeNodeCollection.RemoveAt(i); treeNodeCollection.Insert(0, treeNode); continue; } for (whereObjectBelongs = i - 2; whereObjectBelongs > -1; whereObjectBelongs--) { if (StateTreeNodeExtensionMethods.Compare(treeNodeCollection[i], treeNodeCollection[whereObjectBelongs]) >= 0) { TreeNode treeNode = treeNodeCollection[i]; treeNodeCollection.RemoveAt(i); treeNodeCollection.Insert(whereObjectBelongs + 1, treeNode); break; } else if (whereObjectBelongs == 0 && StateTreeNodeExtensionMethods.Compare(treeNodeCollection[i], treeNodeCollection[0]) < 0) { TreeNode treeNode = treeNodeCollection[i]; treeNodeCollection.RemoveAt(i); treeNodeCollection.Insert(0, treeNode); break; } } } } }
internal void Add(TreeNodeCollection parent, TreeListNode node) { if (!_useCompareTo) { parent.Add(node); return; } /* Console.WriteLine("AddSorted: " + node); Console.WriteLine("Current nodes: "); for (int j = 0; j < parent.Count; j++) Console.WriteLine(" " + parent[j]); */ int i; for (i = parent.Count - 1; i >= 0; i--) { TreeListNode lookNode = (TreeListNode)parent[i]; // Console.WriteLine("looking at: " + lookNode // + " (" + i + ")"); if (lookNode.CompareTo(node) <= 0) break; } parent.Insert(i + 1, node); }
/// <summary> /// Inserts a node in the correct location (sorting alphabetically by /// directories first, then files). /// </summary> /// <param name="node"></param> private static void InsertNode(TreeNodeCollection nodes, GenericNode node) { bool inserted = false; for (int i=0; i<nodes.Count; i++) { GenericNode existingNode = nodes[i] as GenericNode; if (node is FileNode && existingNode is DirectoryNode) continue; if ((node is DirectoryNode && existingNode is FileNode) || string.Compare(existingNode.Text, node.Text, true) > 0) { nodes.Insert(i,node); inserted = true; break; } } if (!inserted) nodes.Add(node); // append to the end of the list // is the tree looking to have this node selected? if (Tree.PathToSelect == node.BackingPath) { // use SelectedNode so multiselect treeview can handle painting Tree.SelectedNodes = new ArrayList(new object[]{node}); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Adds the node. /// </summary> /// <param name="parentNodeCollection">The parent node collection.</param> /// <param name="classname">The classname.</param> /// <param name="clid">The clid.</param> /// ------------------------------------------------------------------------------------ private void AddNode(TreeNodeCollection parentNodeCollection, string classname, int clid) { bool isAbstract = m_mdc.GetAbstract(clid); string label = classname + ": (" + clid + ")" + (isAbstract ? " abstract class" : ""); TreeNode node = new TreeNode(label) {Tag = clid}; bool fAdded = false; for (int i = 0; i < parentNodeCollection.Count; i++) { if (node.Text.CompareTo(parentNodeCollection[i].Text) < 0) { parentNodeCollection.Insert(i, node); fAdded = true; break; } } if (!fAdded) parentNodeCollection.Add(node); AddSubNodes(node.Nodes, clid); }
void add_nodes( TreeNodeCollection nodes, ArrayList l, int param ) { foreach( object o in l ) { int icon = param >= 0 ? param : UMLDes.GUI.IconUtility.IconForElement( (UmlObject)o ); TreeNode t = new TreeNode( getName(o), icon, icon ); t.Tag = new NodeTag( o ); if( param == 1 ) { int i = nodes.IndexOf( refs ); nodes.Insert( i >= 0 ? i : nodes.Count, t ); } else nodes.Add( t ); } }
private void InsertNode(TreeNodeCollection nodeCollection, TreeNode node) { int index = 0; for (int i = 0; i < nodeCollection.Count; i++) { if (nodeCollection[i].Name.CompareTo(node.Name) > 0) { index = i; break; } } nodeCollection.Insert(index, node); }
private void AddNodes(TreeNodeCollection nodes, OptionsBase options) { foreach (OptionsBase options1 in (IEnumerable<OptionsBase>) options.SubOptions) { OptionsNode optionsNode = new OptionsNode(options1); nodes.Add((TreeNode) optionsNode); if (!this.optionsNodes.ContainsKey(options1.GetType())) this.optionsNodes.Add(options1.GetType(), optionsNode); this.AddNodes(optionsNode.Nodes, options1); } if (nodes.Count <= 0 || options is AppOptions) return; GeneralOptionsNode generalOptionsNode = new GeneralOptionsNode(options); nodes.Insert(0, (TreeNode) generalOptionsNode); }