private void SortRecursive(JetListViewNode node) { node.SortChildren(GetNodeComparer(node)); for (int i = 0; i < node.ChildCount; i++) { SortRecursive(node.GetChildNode(i)); } }
public void Update(object item) { lock (this) { JetListViewNode[] nodes = NodesFromItem(item); if (nodes.Length == 0) { throw new ArgumentException("Item not found in list", "item"); } for (int i = 0; i < nodes.Length; i++) { JetListViewNode node = nodes [i]; Guard.NullLocalVariable(node, "node"); if (_filters != null) { UpdateFiltersAccept(node); } JetListViewNode parent = node.Parent; Guard.NullLocalVariable(parent, "parent"); bool needMove = false; IComparer comparer = GetNodeComparer(parent); if (comparer != null) { needMove = parent.IsChildOutOfSortedPosition(node, comparer); if (needMove) { OnNodeMoving(node); parent.UpdateChildPosition(node, comparer); OnNodeMoved(node); // HACK (see OM-9953 and MultipleSortUpdate test) // we receive updates after the nodes have been changed, so the IsChildInSortedPosition() // check uses new state of the node and may erroneously tell us that the node is // in sorted position when it actually is not if (_lastUpdatedNode != null && _lastUpdatedNode.Parent == parent && parent.IsChildOutOfSortedPosition(_lastUpdatedNode, comparer)) { parent.SortChildren(comparer); OnSorted(); } } } if (!needMove && IsNodeVisible(node)) { OnNodeChanged(node); } _lastUpdatedNode = node; } } }