//----------------------------------------------------------------------------- internal void SortNodes(eSortParmItem SortBy) { treeViewParameters.BeginUpdate(); _SortNodes(treeViewParameters.Nodes, SortBy); treeViewParameters.EndUpdate(); treeViewParameters.Invalidate(); }
//----------------------------------------------------------------------------- internal void _SortNodes(TreeNodeCollection Nodes, eSortParmItem SortBy) { int N = Nodes.Count; if (N > 0) { int index_of_min = 0; for (int iterator = 0; iterator < N - 1; iterator++) { index_of_min = iterator; for (int index = iterator + 1; index < N; index++) { int test = 0; if (SortBy == eSortParmItem.spiFieldname) { test = ParmTreeNode.CompareBasedOnField((Nodes[index] as ParmTreeNode), (Nodes[index_of_min] as ParmTreeNode)); } else { test = ParmTreeNode.CompareBasedOnLabel((Nodes[index] as ParmTreeNode), (Nodes[index_of_min] as ParmTreeNode)); } if (test < 0) { index_of_min = index; } } if (iterator != index_of_min) { SwapParmNodes(Nodes, iterator, index_of_min); } } } foreach (TreeNode node in Nodes) { if (node.Nodes.Count > 0) { _SortNodes(node.Nodes, SortBy); } } }