Exemple #1
0
        public virtual void DrawSelectionBackground(Graphics dc, Rectangle nodeRect, Node node)
        {
            Point mousePoint = m_owner.PointToClient(Cursor.Position);
            Node  hoverNode  = m_owner.CalcHitNode(mousePoint);

            if (m_owner.NodesSelection.Contains(node) || m_owner.FocusedNode == node)
            {
                Color col = m_owner.Focused ? SystemColors.Highlight : SystemColors.ControlLight;

                if (!Application.RenderWithVisualStyles)
                {
                    // have to fill the solid background only before the node is painted
                    dc.FillRectangle(SystemBrushes.FromSystemColor(col), nodeRect);
                }
                else
                {
                    col = m_owner.Focused ? SystemColors.Highlight : Color.FromArgb(180, SystemColors.ControlDark);

                    // have to draw the transparent background after the node is painted
                    VisualStyleItemBackground.Style style = VisualStyleItemBackground.Style.Normal;
                    if (m_owner.Focused == false)
                    {
                        style = VisualStyleItemBackground.Style.Inactive;
                    }
                    VisualStyleItemBackground rendere = new VisualStyleItemBackground(style);
                    rendere.DrawBackground(m_owner, dc, nodeRect, col);
                }
            }
            else if (hoverNode == node && m_owner.RowOptions.HoverHighlight)
            {
                Color col = SystemColors.ControlLight;

                if (!Application.RenderWithVisualStyles)
                {
                    // have to fill the solid background only before the node is painted
                    dc.FillRectangle(SystemBrushes.FromSystemColor(col), nodeRect);
                }
                else
                {
                    // have to draw the transparent background after the node is painted
                    VisualStyleItemBackground.Style style = VisualStyleItemBackground.Style.Normal;
                    if (m_owner.Focused == false)
                    {
                        style = VisualStyleItemBackground.Style.Inactive;
                    }
                    VisualStyleItemBackground rendere = new VisualStyleItemBackground(style);
                    rendere.DrawBackground(m_owner, dc, nodeRect, col);
                }
            }

            if (m_owner.Focused && (m_owner.FocusedNode == node))
            {
                nodeRect.Height += 1;
                nodeRect.Inflate(-1, -1);
                ControlPaint.DrawFocusRectangle(dc, nodeRect);
            }
        }
        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);
            }

            TreelistView.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));
        }
Exemple #3
0
        void tlv_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left)
            {
                Node n = _treelistview.CalcHitNode(new System.Drawing.Point(e.X, e.Y));

                if (n == null)
                {
                    EnableControls(false, _objCtrl_ItemSelection);
                }
                else
                {
                    // comment this line
                    // since we're controling the selection from the outside
                    //EnableControls(true, this._objCtrl_ItemSelection);
                }
            }
        }