示例#1
0
        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)
            {
                CommonTools.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);
        }
示例#2
0
        protected override bool GetHitTest(Point point)
        {
            // if mouse is over node, columns or scrollbar then return true
            // which will cause the mouse event to be forwarded to the control
            TreeListView tree = Control as TreeListView;

            point = tree.PointToClient(point);

            Node node = tree.CalcHitNode(point);

            if (node != null)
            {
                return(true);
            }

            CommonTools.HitInfo colinfo = tree.CalcColumnHit(point);
            if ((int)(colinfo.HitType & HitInfo.eHitType.kColumnHeader) > 0)
            {
                return(true);
            }

            if (tree.HitTestScrollbar(point))
            {
                return(true);
            }
            return(base.GetHitTest(point));
        }
示例#3
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (m_resizingColumn != null)
            {
                int left  = m_resizingColumn.CalculatedRect.Left - m_resizingColumnScrollOffset;
                int width = e.X - left;
                if (width < 10)
                {
                    width = 10;
                }
                m_resizingColumn.Width = width;
                Columns.RecalcVisibleColumsRect(true);
                Invalidate();
                return;
            }

            TreeListColumn hotcol = null;

            CommonTools.HitInfo info = Columns.CalcHitInfo(new Point(e.X, e.Y), HScrollValue());
            if ((int)(info.HitType & HitInfo.eHitType.kColumnHeader) > 0)
            {
                hotcol = info.Column;
            }
            if ((int)(info.HitType & HitInfo.eHitType.kColumnHeaderResize) > 0)
            {
                Cursor = Cursors.VSplit;
            }
            else
            {
                Cursor = Cursors.Arrow;
            }

            SetHotColumn(hotcol, true);

            int vScrollOffset = VScrollValue();

            int newhotrow = -1;

            if (hotcol == null)
            {
                int row = (e.Y - Columns.Options.HeaderHeight) / RowOptions.ItemHeight;
                newhotrow = row + vScrollOffset;
            }
            if (newhotrow != m_hotrow)
            {
                InvalidateRow(m_hotrow);
                m_hotrow = newhotrow;
                InvalidateRow(m_hotrow);
            }
        }