private void MultiSelectAdd(TreeListNode clickedNode, Keys modifierKeys) { if (Control.ModifierKeys == Keys.None) { foreach (TreeListNode node in NodesSelection) { int newrow = NodeCollection.GetVisibleNodeIndex(node); InvalidateRow(newrow); } NodesSelection.Clear(); NodesSelection.Add(clickedNode); } if (Control.ModifierKeys == Keys.Shift) { if (NodesSelection.Count == 0) { NodesSelection.Add(clickedNode); } else { int startrow = NodeCollection.GetVisibleNodeIndex(NodesSelection[0]); int currow = NodeCollection.GetVisibleNodeIndex(clickedNode); if (currow > startrow) { TreeListNode startingNode = NodesSelection[0]; NodesSelection.Clear(); foreach (TreeListNode node in NodeCollection.ForwardNodeIterator(startingNode, clickedNode, true)) { NodesSelection.Add(node); } Invalidate(); } if (currow < startrow) { TreeListNode startingNode = NodesSelection[0]; NodesSelection.Clear(); foreach (TreeListNode node in NodeCollection.ReverseNodeIterator(startingNode, clickedNode, true)) { NodesSelection.Add(node); } Invalidate(); } } } if (Control.ModifierKeys == Keys.Control) { if (NodesSelection.Contains(clickedNode)) { NodesSelection.Remove(clickedNode); } else { NodesSelection.Add(clickedNode); } } InvalidateRow(NodeCollection.GetVisibleNodeIndex(clickedNode)); FocusedNode = clickedNode; }
public void EnsureVisible(TreeListNode node) { int screenvisible = MaxVisibleRows() - 1; int visibleIndex = NodeCollection.GetVisibleNodeIndex(node); if (visibleIndex < VScrollValue()) { SetVScrollValue(visibleIndex); } if (visibleIndex > VScrollValue() + screenvisible) { SetVScrollValue(visibleIndex - screenvisible); } }