Exemple #1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            this.Focus();
            if (e.Button == MouseButtons.Right)
            {
                Point  mousePoint  = new Point(e.X, e.Y);
                TLNode 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)
            {
                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);
        }
Exemple #2
0
 void MultiSelectAdd(TLNode clickedNode, Keys modifierKeys)
 {
     if (Control.ModifierKeys == Keys.None)
     {
         foreach (TLNode 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)
             {
                 TLNode startingNode = NodesSelection[0];
                 NodesSelection.Clear();
                 foreach (TLNode node in NodeCollection.ForwardNodeIterator(startingNode, clickedNode, true))
                 {
                     NodesSelection.Add(node);
                 }
                 Invalidate();
             }
             if (currow < startrow)
             {
                 TLNode startingNode = NodesSelection[0];
                 NodesSelection.Clear();
                 foreach (TLNode 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;
 }