Beispiel #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.Control;

                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 (SystemInformation.HighContrast)
                {
                    col = SystemColors.ButtonHighlight;
                }

                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);
            }
        }
Beispiel #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);
            }
        }