Only paint the ToolStripItem BackColor if it's not the default one. Fixes Xamarin...
authorThomas Goldstein <stifu@free.fr>
Sun, 24 Jun 2012 07:36:34 +0000 (09:36 +0200)
committerThomas Goldstein <stifu@free.fr>
Sun, 24 Jun 2012 07:36:34 +0000 (09:36 +0200)
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripRenderer.cs

index d27967917ec97c6371719fec1d82cda4b3cc0a2b..d085afe6bc82a6bff055a68173d0aa854c68d35e 100644 (file)
@@ -192,13 +192,18 @@ namespace System.Windows.Forms
 
                protected virtual void OnRenderItemBackground (ToolStripItemRenderEventArgs e)
                {
-                       Rectangle item_bounds = new Rectangle (0, 0, e.Item.Width, e.Item.Height);
-                       e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (e.Item.BackColor), item_bounds);
+                       if (e.Item.BackColor != Control.DefaultBackColor) {
+                               // Only paint the BackColor if it's not the default one,
+                               // to avoid painting a solid background color over the parent ToolStrip gradient.
+                               Rectangle item_bounds = new Rectangle (0, 0, e.Item.Width, e.Item.Height);
+                               e.Graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (e.Item.BackColor), item_bounds);
+                       }
 
                        if (e.Item.BackgroundImage != null) {
+                               Rectangle item_bounds = new Rectangle (0, 0, e.Item.Width, e.Item.Height);
                                DrawBackground (e.Graphics, item_bounds, e.Item.BackgroundImage, e.Item.BackgroundImageLayout);
                        }
-                               
+
                        ToolStripItemRenderEventHandler eh = (ToolStripItemRenderEventHandler)Events [RenderItemBackgroundEvent];
                        if (eh != null)
                                eh (this, e);