protected override void OnMouseDown(MouseEventArgs e) { this.Focus(); if (e.Button == MouseButtons.Right) { Point mousePoint = new Point(e.X, e.Y); Node clickedNode = CalcHitNode(mousePoint); if (clickedNode != null) { // if multi select the selection is cleard if clicked node is not in selection if (MultiSelect) { if (NodesSelection.Contains(clickedNode) == false) { MultiSelectAdd(clickedNode, Control.ModifierKeys); } } FocusedNode = clickedNode; Invalidate(); } BeforeShowContextMenu(); } if (e.Button == MouseButtons.Left) { BodyArchitect.Controls.External.HitInfo info = Columns.CalcHitInfo(new Point(e.X, e.Y), HScrollValue()); if ((int)(info.HitType & HitInfo.eHitType.kColumnHeaderResize) > 0) { m_resizingColumn = info.Column; m_resizingColumnScrollOffset = HScrollValue(); return; } } base.OnMouseDown(e); }
void MultiSelectAdd(Node clickedNode, Keys modifierKeys) { if (Control.ModifierKeys == Keys.None) { foreach (Node 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) { Node startingNode = NodesSelection[0]; NodesSelection.Clear(); foreach (Node node in NodeCollection.ForwardNodeIterator(startingNode, clickedNode, true)) { NodesSelection.Add(node); } Invalidate(); } if (currow < startrow) { Node startingNode = NodesSelection[0]; NodesSelection.Clear(); foreach (Node 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; }