public int GetNodesCount(RadTreeNodeCollection nodes) { foreach (RadTreeNode node in nodes) { return(nodes.Count + GetNodesCount(node.Nodes)); } return(nodes.Count); }
public int GetNodesCount(RadTreeNodeCollection nodes) { using (IEnumerator <RadTreeNode> enumerator = nodes.GetEnumerator()) { if (enumerator.MoveNext()) { RadTreeNode current = enumerator.Current; return(nodes.Count + this.GetNodesCount(current.Nodes)); } } return(nodes.Count); }
private int GetChildCount(RadTreeNodeCollection nodes) { int result = 0; foreach (RadTreeNode node in nodes) { if (node.Nodes.Count > 0) { result += this.GetChildCount(node.Nodes); } } return(result); }
private AccessibleObject GetChild(RadTreeNodeCollection nodes, int index) { if (index > nodes.Count) { foreach (RadTreeNode node in nodes) { if (node.Nodes.Count > 0) { return(this.GetChild(node.Nodes, index - nodes.Count - 1)); } } } return(new RadTreeNodeAccessibleObject(nodes[index])); }
protected virtual void PerformDragDropCore(DropPosition position, RadTreeNode targetNode, List <RadTreeNode> draggedNodes) { RadTreeNode parent = targetNode.Parent; RadTreeNodeCollection collection = targetNode.TreeViewElement.Nodes; if (parent != null) { collection = parent.Nodes; } bool dropAtTop = position == DropPosition.BeforeNode; int index = collection.IndexOf(targetNode); if (!dropAtTop && index + 1 <= collection.Count) { index++; } foreach (RadTreeNode node in draggedNodes) { if (!this.OnDragEnding(position, node, targetNode)) { continue; } if (node.Parent == parent && node.TreeViewElement == targetNode.TreeViewElement) { int nodeIndex = collection.IndexOf(node); if (nodeIndex < index) { index--; } } node.Remove(); collection.Insert(index, node); index++; this.owner.OnDragEnded(new RadTreeViewDragEventArgs(node, targetNode)); } }
private void DeleteNode() { if (this.treeView.IsEditing || !this.treeView.AllowRemove) { return; } RadTreeNode node = this.treeView.SelectedNode; if (node == null) { return; } RadTreeNodeCollection nodes = this.treeView.Nodes; RadTreeNode parent = node.Parent; if (parent != null) { nodes = parent.Nodes; } nodes.Remove(node); }
protected virtual void PerformDragDropCore( DropPosition position, RadTreeNode targetNode, List <RadTreeNode> draggedNodes) { RadTreeNode parent = targetNode.Parent; RadTreeNodeCollection nodes = targetNode.TreeViewElement.Nodes; if (parent != null) { nodes = parent.Nodes; } bool flag = position == DropPosition.BeforeNode; int index1 = nodes.IndexOf(targetNode); if (!flag && index1 + 1 <= nodes.Count) { ++index1; } bool isCopyingNodes = this.IsCopyingNodes; int index2 = 0; while (index2 < draggedNodes.Count) { if (!this.OnDragEnding(position, draggedNodes[index2], targetNode)) { draggedNodes.RemoveAt(index2); } else { ++index2; } } if (this.owner.bindingProvider.CanDrop || targetNode.treeView != null && targetNode.treeView.bindingProvider.CanDrop) { this.owner.bindingProvider.DropNodes(targetNode.Parent, draggedNodes); foreach (RadTreeNode draggedNode in draggedNodes) { this.owner.OnDragEnded(new RadTreeViewDragEventArgs(draggedNode, targetNode)); } } else { foreach (RadTreeNode draggedNode in draggedNodes) { RadTreeNode radTreeNode = draggedNode; if (radTreeNode.Parent == parent && radTreeNode.TreeViewElement == targetNode.TreeViewElement && nodes.IndexOf(radTreeNode) < index1) { --index1; } if (isCopyingNodes) { radTreeNode = this.CreateTreeNode(radTreeNode); } else { radTreeNode.Remove(); } nodes.Insert(index1, radTreeNode); ++index1; this.owner.OnDragEnded(new RadTreeViewDragEventArgs(radTreeNode, targetNode)); } } }