Welcome to MSDN Blogs Sign in | Join | Help

jfo's coding

adventures in windows forms and wpf
Going from Blue to Tan

Brett asks:

During the PDC we chatted about how to make the toolbar have the same look and feel that the toolbar in Visual Studio has (namely the tan gradients as opposed to the blue ones) and you mentioned you would be posting on that soon ... so, I was wondering ... if you had any idea when that post would be online!?

Thanks for reminding me! 

Turning off the Blue and Orange

If you just want to always use system colors, you can force the ToolStrip to stop picking colors based off the theme globally by:

ToolStripManager.VisualStylesEnabled = false;

Or per-toolstrip:

ProfessionalColorTable professionalColorTable = new ProfessionalColorTable();
professionalColorTable.UseSystemColors = true;
toolStrip1.Renderer = new ToolStripProfessionalRenderer(professionalColorTable);

Matching Visual Studio's scheme

Here's a sample of how to replace a color table in your ToolStripProfessionalRenderer so you can get away from the stock blue colors if blue is not your thing.

The main concept here is that the ToolStripProfessionalRenderer creates Pens and Brushes based on a color table that is replacable.  By inheriting from the ProfessionalColorTable, you can change all of the 40 some odd colors available to you.

The code to set in the tan color table is:

ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new TanColorTable());

Or you can specify one specific toolstrip's renderer:

ToolStrip.Renderer = new ToolStripProfessionalRenderer(new TanColorTable());

Note that if you are a package within Visual Studio, the Visual Studio Core team still recommends using the Command Bar technology - this allows your toolbars to feed into the commanding system as well as their extensibility model.  If your code lives in Visual Studio and after careful consideration you feel you must use a ToolStrip, try fetching the "VsRenderer" or the "VsColorTable" out of the IUIService.Styles dictionary.   The PropertyGrid has a new protected property which allows you to specify a custom renderer.

Hope this helps you get started!

Posted: Sunday, November 06, 2005 6:26 PM by jfoscoding
Filed under:

Comments

PatriotB said:

Ah, the blue toolbars. Quite possibly the worst thing ever to come out of the Office UI team.

The VS team makes a wise decision to use a tan/gray instead. Yet at the same time, makes a poor decision to have WinForms use the icky blue by default.
# November 6, 2005 8:36 PM

jfoscoding said:

I see what you're saying - it was a tough tradeoff. If windows forms didn't make it exactly match office out of the box, we might be getting exactly the opposite feedback.
# November 6, 2005 8:57 PM

PatriotB said:

Yeah, you guys aren't really at fault. It's those folks at Office, they could use a stern talking to...
# November 9, 2005 10:15 PM

PatriotB said:

Hopefully, people will follow the first method to turn off the blue, and won't use the second (hardcoding "Tan"). Encouraging hard-coding the usage of colors is just asking for trouble.

Case in point, I just downloaded the .NET 2.0 SDK today and am poking around, and ran a program called Mage. It seems to use the Windows Forms toolstrip, and it has the tan colors. It doesn't look too good on my system because I use the Media Center Royale theme. DbgClr (which uses the "native" command bars) looks great.

With Royale, Office 2003 doesn't try to "colorize" the toolbars and just uses a system-color-based method. (In fact, that was one of my main reasons for switching from Luna Blue to Royale -- to get rid of the dang blue toolbars in Office.) I haven't tried it out yet, but I wonder what the Windows Forms toolbars do in Royale...

In any event, what Mage does isn't too hot. :(
# November 12, 2005 1:15 AM

jfoscoding said:

Interesting - thanks for pointing out about mage, it probably has an old copy of the color table. Royale was one of the last color schemes we supported - this tool might not have been updated. We'll take a look.

This is pretty much the same code that the PropertyGrid in Visual Studio uses to match the rest of the Visual Studio Toolbars.
# November 12, 2005 12:17 PM

Mathias said:

Is it possible to use the TanColorTable without any license or is some kind of permission required?
# November 25, 2005 2:42 PM

jfoscoding said:

Its just like any other sample code on blogs.msdn.com.
# November 28, 2005 4:23 PM

Aaron Brethorst said:

Yes, yes, yes! If you are building a VSIP Package please use the standard Visual Studio command bars instead of the ToolStrip control. We have a ton of documentation on how to do this easily in the <a href="http://msdn.microsoft.com/vstudio/extend/">Visual Studio SDK</a>.
# December 1, 2005 11:18 PM

jfo's coding said:

If you've read the ToolStrip FAQ, you may already be aware that you can replace the colors of the ToolStrip...
# March 8, 2006 1:50 AM
New Comments to this post are disabled
Page view tracker