private void RenderItemInternal(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem      item         = e.Item;
            Graphics           dc           = e.Graphics;
            ToolBarState       toolBarState = GetToolBarState(item);
            VisualStyleElement normal       = VisualStyleElement.ToolBar.Button.Normal;

            if (ToolStripManager.VisualStylesEnabled && System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(normal))
            {
                System.Windows.Forms.VisualStyles.VisualStyleRenderer visualStyleRenderer = VisualStyleRenderer;
                visualStyleRenderer.SetParameters(normal.ClassName, normal.Part, (int)toolBarState);
                visualStyleRenderer.DrawBackground(dc, new Rectangle(Point.Empty, item.Size));
            }
            else
            {
                this.RenderSmall3DBorderInternal(dc, new Rectangle(Point.Empty, item.Size), toolBarState, item.RightToLeft == RightToLeft.Yes);
            }
            Rectangle contentRectangle = item.ContentRectangle;

            if (item.BackgroundImage != null)
            {
                ControlPaint.DrawBackgroundImage(dc, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, contentRectangle, contentRectangle);
            }
            else
            {
                ToolStrip currentParent = item.GetCurrentParent();
                if (((currentParent != null) && (toolBarState != ToolBarState.Checked)) && (item.BackColor != currentParent.BackColor))
                {
                    FillBackground(dc, contentRectangle, item.BackColor);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///  This exists mainly so that buttons, labels and items, etc can share the same implementation.
        ///  If OnRenderButton called OnRenderItem we would never be able to change the implementation
        ///  as it would be a breaking change. If in v1, the user overrode OnRenderItem to draw green triangles
        ///  and in v2 we decided to add a feature to button that would require us to no longer call OnRenderItem -
        ///  the user's version of OnRenderItem would not get called when he upgraded his framework.  Hence
        ///  everyone should just call this private shared method.  Users need to override each item they want
        ///  to change the look and feel of.
        ///  </summary>
        private void RenderItemInternal(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item = e.Item;
            Graphics      g    = e.Graphics;

            ToolBarState       state          = GetToolBarState(item);
            VisualStyleElement toolBarElement = VisualStyleElement.ToolBar.Button.Normal;

            if (ToolStripManager.VisualStylesEnabled &&
                (VisualStyleRenderer.IsElementDefined(toolBarElement)))
            {
                VisualStyleRenderer vsRenderer = VisualStyleRenderer;
                vsRenderer.SetParameters(toolBarElement.ClassName, toolBarElement.Part, (int)state);
                vsRenderer.DrawBackground(g, new Rectangle(Point.Empty, item.Size));
            }
            else
            {
                RenderSmall3DBorderInternal(g, new Rectangle(Point.Empty, item.Size), state, (item.RightToLeft == RightToLeft.Yes));
            }

            Rectangle fillRect = item.ContentRectangle;

            if (item.BackgroundImage != null)
            {
                ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, fillRect, fillRect);
            }
            else
            {
                ToolStrip parent = item.GetCurrentParent();
                if ((parent != null) && (state != ToolBarState.Checked) && (item.BackColor != parent.BackColor))
                {
                    FillBackground(g, fillRect, item.BackColor);
                }
            }
        }
Esempio n. 3
0
        protected virtual void OnPaint(PaintEventArgs e)
        {
            var localBackColor = stateSelected && Enabled ? hoverColor : BackColor;
            var rect           = Bounds;
            var graphics       = e.Graphics;
            var textColor      = Enabled ? ForeColor : SystemColors.InactiveCaption;

            // Text left offset for vertical ToolStrip.
            var leftOffset = 0;

            if (Owner != null && Owner.Orientation == Orientation.Vertical)
            {
                leftOffset = Owner.Padding.Left;
            }

            // Paint back + backImage.
            ControlPaint.DrawBackgroundImage(graphics, BackgroundImage, localBackColor, BackgroundImageLayout, rect, rect);

            // Draw border for selected state.
            if (stateSelected && Enabled)
            {
                graphics.DrawRectangle(selectPen, rect);
            }

            // Image.
            DrawImage(graphics);

            // Text.
            graphics.uwfDrawString(Text, Font, textColor, rect.X + leftOffset, rect.Y, rect.Width - leftOffset, rect.Height, TextAlign);
            ////graphics.DrawRectangle(new Pen(Color.Red), rect); // Debug.
        }
Esempio n. 4
0
        internal void PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor, Point scrollOffset)
        {
            var bImage = BackgroundImage;

            if (bImage != null) // Fill back & draw image.
            {
                ControlPaint.DrawBackgroundImage(e.Graphics, bImage, backColor, BackgroundImageLayout, ClientRectangle, rectangle);
            }
            else if (backColor.A > 0) // Fill back.
            {
                PaintBackColor(e, rectangle, backColor);
            }
        }
        private static void RenderLabelInternal(ToolStripItemRenderEventArgs e)
        {
            ToolStripItem item             = e.Item;
            Graphics      g                = e.Graphics;
            Rectangle     contentRectangle = item.ContentRectangle;

            if (item.BackgroundImage != null)
            {
                ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, contentRectangle, contentRectangle);
            }
            else if ((VisualStyleRenderer == null) || (item.BackColor != SystemColors.Control))
            {
                FillBackground(g, contentRectangle, item.BackColor);
            }
        }
 protected override void OnPaintBackground(PaintEventArgs e)
 {
     if ((this.HScroll || this.VScroll) && ((this.BackgroundImage != null) && (((this.BackgroundImageLayout == ImageLayout.Zoom) || (this.BackgroundImageLayout == ImageLayout.Stretch)) || (this.BackgroundImageLayout == ImageLayout.Center))))
     {
         if (ControlPaint.IsImageTransparent(this.BackgroundImage))
         {
             base.PaintTransparentBackground(e, this.displayRect);
         }
         ControlPaint.DrawBackgroundImage(e.Graphics, this.BackgroundImage, this.BackColor, this.BackgroundImageLayout, this.displayRect, this.displayRect, this.displayRect.Location);
     }
     else
     {
         base.OnPaintBackground(e);
     }
 }
Esempio n. 7
0
        /// <include file='doc\TabPage.uex' path='docs/doc[@for="TabPage.OnPaintBackground"]/*' />
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            // Utilize the TabRenderer new to Whidbey to draw the tab pages so that the
            // panels are drawn using the correct visual styles when the application supports using visual
            // styles.

            // Does this application utilize Visual Styles?
            // Utilize the UseVisualStyleBackColor property to determine whether or
            // not the themed background should be utilized.
            TabControl parent = ParentInternal as TabControl;

            if (Application.RenderWithVisualStyles && UseVisualStyleBackColor && (parent != null && parent.Appearance == TabAppearance.Normal))
            {
                Color     bkcolor     = UseVisualStyleBackColor ? Color.Transparent : this.BackColor;
                Rectangle inflateRect = LayoutUtils.InflateRect(DisplayRectangle, Padding);



                //To ensure that the tabpage draws correctly (the border will get clipped and
                // and gradient fill will match correctly with the tabcontrol).  Unfortunately, there is no good way to determine
                // the padding used on the tabpage.
                // I would like to use the following below, but GetMargins is busted in the theming API:
                //VisualStyleRenderer visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Tab.Pane.Normal);
                //Padding themePadding = visualStyleRenderer.GetMargins(e.Graphics, MarginProperty.ContentMargins);
                //Rectangle rectWithBorder = new Rectangle(inflateRect.X - themePadding.Left,
                //    inflateRect.Y - themePadding.Top,
                //    inflateRect.Width + themePadding.Right + themePadding.Left,
                //    inflateRect.Height + themePadding.Bottom + themePadding.Top);
                Rectangle rectWithBorder = new Rectangle(inflateRect.X - 4, inflateRect.Y - 2, inflateRect.Width + 8, inflateRect.Height + 6);

                TabRenderer.DrawTabPage(e.Graphics, rectWithBorder);

                // Is there a background image to paint? The TabRenderer does not currently support
                // painting the background image on the panel, so we need to draw it ourselves.
                if (this.BackgroundImage != null)
                {
                    ControlPaint.DrawBackgroundImage(e.Graphics, BackgroundImage, bkcolor, BackgroundImageLayout, inflateRect, inflateRect, DisplayRectangle.Location);
                }
            }
            else
            {
                base.OnPaintBackground(e);
            }
        }
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripMenuItem item = e.Item as ToolStripMenuItem;
            Graphics          g    = e.Graphics;

            if (!(item is MdiControlStrip.SystemMenuItem) && (item != null))
            {
                Rectangle bounds = new Rectangle(Point.Empty, item.Size);
                if (item.IsTopLevel && !ToolStripManager.VisualStylesEnabled)
                {
                    if (item.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, item.ContentRectangle, item.ContentRectangle);
                    }
                    else if (item.RawBackColor != Color.Empty)
                    {
                        FillBackground(g, item.ContentRectangle, item.BackColor);
                    }
                    ToolBarState toolBarState = GetToolBarState(item);
                    this.RenderSmall3DBorderInternal(g, bounds, toolBarState, item.RightToLeft == RightToLeft.Yes);
                }
                else
                {
                    Rectangle rect = new Rectangle(Point.Empty, item.Size);
                    if (item.IsOnDropDown)
                    {
                        rect.X     += 2;
                        rect.Width -= 3;
                    }
                    if (item.Selected || item.Pressed)
                    {
                        g.FillRectangle(SystemBrushes.Highlight, rect);
                    }
                    else if (item.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, item.ContentRectangle, rect);
                    }
                    else if (!ToolStripManager.VisualStylesEnabled && (item.RawBackColor != Color.Empty))
                    {
                        FillBackground(g, rect, item.BackColor);
                    }
                }
            }
        }
Esempio n. 9
0
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            TabControl parentInternal = this.ParentInternal as TabControl;

            if ((Application.RenderWithVisualStyles && this.UseVisualStyleBackColor) && ((parentInternal != null) && (parentInternal.Appearance == TabAppearance.Normal)))
            {
                Color     backColor  = this.UseVisualStyleBackColor ? Color.Transparent : this.BackColor;
                Rectangle bounds     = LayoutUtils.InflateRect(this.DisplayRectangle, base.Padding);
                Rectangle rectangle2 = new Rectangle(bounds.X - 4, bounds.Y - 2, bounds.Width + 8, bounds.Height + 6);
                TabRenderer.DrawTabPage(e.Graphics, rectangle2);
                if (this.BackgroundImage != null)
                {
                    ControlPaint.DrawBackgroundImage(e.Graphics, this.BackgroundImage, backColor, this.BackgroundImageLayout, bounds, bounds, this.DisplayRectangle.Location);
                }
            }
            else
            {
                base.OnPaintBackground(e);
            }
        }
Esempio n. 10
0
        private static void RenderLabelInternal(ToolStripItemRenderEventArgs e)
        {
            // dont call RenderItemInternal, as we NEVER want to paint hot.
            ToolStripItem item = e.Item;
            Graphics      g    = e.Graphics;

            Rectangle fillRect = item.ContentRectangle;

            if (item.BackgroundImage != null)
            {
                ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, fillRect, fillRect);
            }
            else
            {
                VisualStyleRenderer vsRenderer = VisualStyleRenderer;

                if (vsRenderer == null || (item.BackColor != SystemColors.Control))
                {
                    FillBackground(g, fillRect, item.BackColor);
                }
            }
        }
Esempio n. 11
0
        /// <include file='doc\ToolStripRenderer.uex' path='docs/doc[@for="ToolStripRenderer.OnRenderSplitButton"]/*' />
        /// <devdoc>
        /// Draw the item's background.
        /// </devdoc>
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripSplitButton splitButton = e.Item as ToolStripSplitButton;
            Graphics             g           = e.Graphics;

            bool  rightToLeft = (splitButton.RightToLeft == RightToLeft.Yes);
            Color arrowColor  = splitButton.Enabled ? SystemColors.ControlText : SystemColors.ControlDark;


            // in right to left - we need to swap the parts so we dont draw  v][ toolStripSplitButton
            VisualStyleElement splitButtonDropDownPart = (rightToLeft) ? VisualStyleElement.ToolBar.SplitButton.Normal : VisualStyleElement.ToolBar.SplitButtonDropDown.Normal;
            VisualStyleElement splitButtonPart         = (rightToLeft) ? VisualStyleElement.ToolBar.DropDownButton.Normal : VisualStyleElement.ToolBar.SplitButton.Normal;

            Rectangle bounds = new Rectangle(Point.Empty, splitButton.Size);

            if (ToolStripManager.VisualStylesEnabled &&
                VisualStyleRenderer.IsElementDefined(splitButtonDropDownPart) &&
                VisualStyleRenderer.IsElementDefined(splitButtonPart))
            {
                VisualStyleRenderer vsRenderer = VisualStyleRenderer;


                // Draw the SplitButton Button portion of it.
                vsRenderer.SetParameters(splitButtonPart.ClassName, splitButtonPart.Part, GetSplitButtonItemState(splitButton));


                // the lovely Windows theming for split button comes in three pieces:
                //  SplitButtonDropDown: [ v |
                //  Separator:                |
                //  SplitButton:               |  ]
                // this is great except if you want to swap the button in RTL.  In this case we need
                // to use the DropDownButton instead of the SplitButtonDropDown and paint the arrow ourselves.
                Rectangle splitButtonBounds = splitButton.ButtonBounds;
                if (rightToLeft)
                {
                    // scoot to the left so we dont draw double shadow like so: ][
                    splitButtonBounds.Inflate(2, 0);
                }
                // Draw the button portion of it.
                vsRenderer.DrawBackground(g, splitButtonBounds);

                // Draw the SplitButton DropDownButton portion of it.
                vsRenderer.SetParameters(splitButtonDropDownPart.ClassName, splitButtonDropDownPart.Part, GetSplitButtonDropDownItemState(splitButton));

                // Draw the drop down button portion
                vsRenderer.DrawBackground(g, splitButton.DropDownButtonBounds);

                // fill in the background image
                Rectangle fillRect = splitButton.ContentRectangle;
                if (splitButton.BackgroundImage != null)
                {
                    ControlPaint.DrawBackgroundImage(g, splitButton.BackgroundImage, splitButton.BackColor, splitButton.BackgroundImageLayout, fillRect, fillRect);
                }

                // draw the separator over it.
                RenderSeparatorInternal(g, splitButton, splitButton.SplitterBounds, true);

                // and of course, now if we're in RTL we now need to paint the arrow
                // because we're no longer using a part that has it built in.
                if (rightToLeft || splitButton.BackgroundImage != null)
                {
                    DrawArrow(new ToolStripArrowRenderEventArgs(g, splitButton, splitButton.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
            }
            else
            {
                // Draw the split button button
                Rectangle splitButtonButtonRect = splitButton.ButtonBounds;

                if (splitButton.BackgroundImage != null)
                {
                    // fill in the background image
                    Rectangle fillRect = (splitButton.Selected) ? splitButton.ContentRectangle :bounds;
                    if (splitButton.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(g, splitButton.BackgroundImage, splitButton.BackColor, splitButton.BackgroundImageLayout, bounds, fillRect);
                    }
                }
                else
                {
                    FillBackground(g, splitButtonButtonRect, splitButton.BackColor);
                }

                ToolBarState state = GetSplitButtonToolBarState(splitButton, false);

                RenderSmall3DBorderInternal(g, splitButtonButtonRect, state, rightToLeft);

                // draw the split button drop down
                Rectangle dropDownRect = splitButton.DropDownButtonBounds;

                // fill the color in the dropdown button
                if (splitButton.BackgroundImage == null)
                {
                    FillBackground(g, dropDownRect, splitButton.BackColor);
                }

                state = GetSplitButtonToolBarState(splitButton, true);

                if ((state == ToolBarState.Pressed) || (state == ToolBarState.Hot))
                {
                    RenderSmall3DBorderInternal(g, dropDownRect, state, rightToLeft);
                }

                DrawArrow(new ToolStripArrowRenderEventArgs(g, splitButton, dropDownRect, arrowColor, ArrowDirection.Down));
            }
        }
Esempio n. 12
0
        /// <include file='doc\ToolStripRenderer.uex' path='docs/doc[@for="ToolStripRenderer.OnRenderMenuItem"]/*' />
        /// <devdoc>
        /// Draw the items background
        /// </devdoc>
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripMenuItem item = e.Item as ToolStripMenuItem;
            Graphics          g    = e.Graphics;

            if (item is MdiControlStrip.SystemMenuItem)
            {
                return; // no highlights are painted behind a system menu item
            }

            //

            if (item != null)
            {
                Rectangle bounds = new Rectangle(Point.Empty, item.Size);
                if (item.IsTopLevel && !ToolStripManager.VisualStylesEnabled)
                {
                    // CLASSIC MODE (3D edges)
                    // Draw box highlight for toplevel items in downlevel platforms
                    if (item.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, item.ContentRectangle, item.ContentRectangle);
                    }
                    else if (item.RawBackColor != Color.Empty)
                    {
                        FillBackground(g, item.ContentRectangle, item.BackColor);
                    }
                    // Toplevel menu items do 3D borders.
                    ToolBarState state = GetToolBarState(item);
                    RenderSmall3DBorderInternal(g, bounds, state, (item.RightToLeft == RightToLeft.Yes));
                }
                else
                {
                    // XP++ MODE (no 3D edges)
                    // Draw blue filled highlight for toplevel items in themed platforms
                    // or items parented to a drop down
                    Rectangle fillRect = new Rectangle(Point.Empty, item.Size);
                    if (item.IsOnDropDown)
                    {
                        // VSWhidbey 518568: scoot in by 2 pixels when selected
                        fillRect.X     += 2;
                        fillRect.Width -= 3; //its already 1 away from the right edge
                    }

                    if (item.Selected || item.Pressed)
                    {
                        g.FillRectangle(SystemBrushes.Highlight, fillRect);
                    }
                    else
                    {
                        if (item.BackgroundImage != null)
                        {
                            ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, item.ContentRectangle, fillRect);
                        }
                        else if (!ToolStripManager.VisualStylesEnabled && (item.RawBackColor != Color.Empty))
                        {
                            FillBackground(g, fillRect, item.BackColor);
                        }
                    }
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        ///  Draw the items background
        /// </summary>
        protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripMenuItem item = e.Item as ToolStripMenuItem;
            Graphics          g    = e.Graphics;

            if (item is MdiControlStrip.SystemMenuItem)
            {
                return; // no highlights are painted behind a system menu item
            }

            //

            if (item != null)
            {
                Rectangle bounds = new Rectangle(Point.Empty, item.Size);
                if (item.IsTopLevel && !ToolStripManager.VisualStylesEnabled)
                {
                    // Classic Mode (3D edges)
                    // Draw box highlight for toplevel items in downlevel platforms
                    if (item.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, item.ContentRectangle, item.ContentRectangle);
                    }
                    else if (item.RawBackColor != Color.Empty)
                    {
                        FillBackground(g, item.ContentRectangle, item.BackColor);
                    }
                    // Toplevel menu items do 3D borders.
                    ToolBarState state = GetToolBarState(item);
                    RenderSmall3DBorderInternal(g, bounds, state, (item.RightToLeft == RightToLeft.Yes));
                }
                else
                {
                    // Modern MODE (no 3D edges)
                    // Draw blue filled highlight for toplevel items in themed platforms
                    // or items parented to a drop down
                    Rectangle fillRect = new Rectangle(Point.Empty, item.Size);
                    if (item.IsOnDropDown)
                    {
                        // Scoot in by 2 pixels when selected
                        fillRect.X     += 2;
                        fillRect.Width -= 3; //its already 1 away from the right edge
                    }

                    if (item.Selected || item.Pressed)
                    {
                        // Legacy behavior is to always paint the menu item background.
                        // The correct behavior is to only paint the background if the menu item is
                        // enabled.
                        if (item.Enabled)
                        {
                            g.FillRectangle(SystemBrushes.Highlight, fillRect);
                        }

                        Color borderColor = ToolStripManager.VisualStylesEnabled ?
                                            SystemColors.Highlight : ProfessionalColors.MenuItemBorder;

                        // draw selection border - always drawn regardless of Enabled.
                        using (Pen p = new Pen(borderColor))
                        {
                            g.DrawRectangle(p, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
                        }
                    }
                    else
                    {
                        if (item.BackgroundImage != null)
                        {
                            ControlPaint.DrawBackgroundImage(g, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, item.ContentRectangle, fillRect);
                        }
                        else if (!ToolStripManager.VisualStylesEnabled && (item.RawBackColor != Color.Empty))
                        {
                            FillBackground(g, fillRect, item.BackColor);
                        }
                    }
                }
            }
        }
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStripSplitButton item   = e.Item as ToolStripSplitButton;
            Graphics             dc     = e.Graphics;
            bool  rightToLeft           = item.RightToLeft == RightToLeft.Yes;
            Color arrowColor            = item.Enabled ? SystemColors.ControlText : SystemColors.ControlDark;
            VisualStyleElement element  = rightToLeft ? VisualStyleElement.ToolBar.SplitButton.Normal : VisualStyleElement.ToolBar.SplitButtonDropDown.Normal;
            VisualStyleElement element2 = rightToLeft ? VisualStyleElement.ToolBar.DropDownButton.Normal : VisualStyleElement.ToolBar.SplitButton.Normal;
            Rectangle          bounds   = new Rectangle(Point.Empty, item.Size);

            if ((ToolStripManager.VisualStylesEnabled && System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(element)) && System.Windows.Forms.VisualStyles.VisualStyleRenderer.IsElementDefined(element2))
            {
                System.Windows.Forms.VisualStyles.VisualStyleRenderer visualStyleRenderer = VisualStyleRenderer;
                visualStyleRenderer.SetParameters(element2.ClassName, element2.Part, GetSplitButtonItemState(item));
                Rectangle buttonBounds = item.ButtonBounds;
                if (rightToLeft)
                {
                    buttonBounds.Inflate(2, 0);
                }
                visualStyleRenderer.DrawBackground(dc, buttonBounds);
                visualStyleRenderer.SetParameters(element.ClassName, element.Part, GetSplitButtonDropDownItemState(item));
                visualStyleRenderer.DrawBackground(dc, item.DropDownButtonBounds);
                Rectangle contentRectangle = item.ContentRectangle;
                if (item.BackgroundImage != null)
                {
                    ControlPaint.DrawBackgroundImage(dc, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, contentRectangle, contentRectangle);
                }
                this.RenderSeparatorInternal(dc, item, item.SplitterBounds, true);
                if (rightToLeft || (item.BackgroundImage != null))
                {
                    base.DrawArrow(new ToolStripArrowRenderEventArgs(dc, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
            }
            else
            {
                Rectangle rectangle4 = item.ButtonBounds;
                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    if (item.BackgroundImage != null)
                    {
                        ControlPaint.DrawBackgroundImage(dc, item.BackgroundImage, item.BackColor, item.BackgroundImageLayout, bounds, clipRect);
                    }
                }
                else
                {
                    FillBackground(dc, rectangle4, item.BackColor);
                }
                ToolBarState splitButtonToolBarState = GetSplitButtonToolBarState(item, false);
                this.RenderSmall3DBorderInternal(dc, rectangle4, splitButtonToolBarState, rightToLeft);
                Rectangle dropDownButtonBounds = item.DropDownButtonBounds;
                if (item.BackgroundImage == null)
                {
                    FillBackground(dc, dropDownButtonBounds, item.BackColor);
                }
                splitButtonToolBarState = GetSplitButtonToolBarState(item, true);
                switch (splitButtonToolBarState)
                {
                case ToolBarState.Pressed:
                case ToolBarState.Hot:
                    this.RenderSmall3DBorderInternal(dc, dropDownButtonBounds, splitButtonToolBarState, rightToLeft);
                    break;
                }
                base.DrawArrow(new ToolStripArrowRenderEventArgs(dc, item, dropDownButtonBounds, arrowColor, ArrowDirection.Down));
            }
        }