public virtual void DrawSelectionBackground(Graphics dc, Rectangle nodeRect, Node node)
 {
     if (m_owner.NodesSelection.Contains(node) || m_owner.FocusedNode == node)
     {
         if (!Application.RenderWithVisualStyles)
         {
             // have to fill the solid background only before the node is painted
             dc.FillRectangle(SystemBrushes.FromSystemColor(SystemColors.Highlight), 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);
         }
     }
     if (m_owner.Focused && (m_owner.FocusedNode == node))
     {
         nodeRect.Height += 1;
         nodeRect.Inflate(-1, -1);
         ControlPaint.DrawFocusRectangle(dc, nodeRect);
     }
 }
Exemplo n.º 2
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);
            }
        }