1 Attachment(s)
Office 2003 ToolStrip renderer on Vista
--- This has been superseded by http://www.vbforums.com/showthread.php?t=582063 ---
I was really disappointed that the ProfessionalRenderMode on Vista is like Office XP instead of Office 2003. So, I thought I could use System.Reflection to get all properties of the ProfessionalColorTable on XP, write the color values to a text file and make a custom color table with that values. And it worked fine! If anybody is interested on how to achieve the Office 2003 look of ToolStrips (and MenuStrips etc.), add the class in the attached zip file to your project, then add the following in the Load event of your Form:
Code:
Dim clrtbl = New Office2003ToolStripColorTable
ToolStripManager.Renderer = New ToolStripProfessionalRenderer(clrtbl)
Re: Office 2003 ToolStrip renderer on Vista
That's awesome. I'm not on Vista so I can't test it at the moment, but I have always hated the default toolstrip look on Vista. I imitated a few of my favorite designs (like the VS2008 toolstrip) but it's a little time consuming to do that for a new toolstrip every time.
I simply created my own renderer, I didn't know you could use a color table like this. I understand that you can only change the colors, but not the shape of anything, right? So it's a little limited, but does the job nice in this case :)
Awesome!
Re: Office 2003 ToolStrip renderer on Vista
Thanks for your positive reaction!
I also like your vs2008 style renderer as I'm trying to have many toolstrip renderer styles in my application. On Google Code there are some new too, if you are interested perhaps.
btw, I was impressed by the zip file size compared with the .vb file size, but that's because there is much code which is the same for each property every time.
Re: Office 2003 ToolStrip renderer on Vista
Could you perhaps tell me how you found out the values for the different colors?
I'm making a Customizable Toolstrip control, where the ColorTable is built into the control, and each of it's overriddable properties is exposed via a normal property. This way the user can create their own ToolStrip (and MenuStrip) look in the designer via the property grid, without having to dive into ColorTable code or Renderer code.
I felt a mandatory feature was a few commands (the ones that appear in the Action List (Smart Tag) and the ones that appear in the Commands part beneath the property grid) like "Office 2003 Blue", "Office 2003 Silver", "Office 2003 Green" (does that exist?), etc, which would behave as a kind of 'preset' for the properties. If the user clicks them, the properties are set to match the color table.
For that to work of course all I need is the correct colors... So how did you get them? Can you explain in more detail?
Thanks!
Re: Office 2003 ToolStrip renderer on Vista
That was quite simple really, though I had to be a little bit creative perhaps. :p
With System.Reflection, you can iterate through properties of a specific class (probably you can do more but this is what I've used it for). So, I made a very little application which iterates through all properties of the ProfessionalColorTable (the colors used by the system for the ProfessionalRenderMode), and writes them into a String, with the necessary code for a property inside it (so that I didn't have to make suitable vb.net code for a property myself for each color) and writes the whole String into a text file. On Vista, the colortable has different values than on XP. So, I ran the application on XP, copied the text file on a usb stick and copied the text file into Visual Studio (which can be done immediately as the String already has suitable vb.net code).
This is the code which iterates through the properties of the ProfessionalColorTable, makes a suitable vb.net file and writes the whole into a text file:
Code:
Dim s = New ProfessionalColorTable
Dim t = s.GetType.GetProperties
Dim text = ""
For Each u As PropertyInfo In t
Dim c2 = u.GetValue(s, Nothing)
If c2.GetType.Name = "Color" Then
Dim c As Color = c2
text += String.Format("Friend Overrides ReadOnly Property {0}() as Color" + vbNewLine + "Get" + vbNewLine + "Return Color.FromARGB({1},{2},{3})" + vbNewLine + "End Get" + vbNewLine + "End Property" + vbNewLine + vbNewLine, u.Name, c.R, c.G, c.B)
End If
Next
My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\colortable.txt", text, False)
Just add a class to your project, add 'Inherits ProfessionalColorTable' and paste the text file into it.
btw, as far as I know, there is only one Office 2003 style, which is blue/orange. Office 2007 does have blue, silver and black. I found some 'implementations' of the Office 2003 style though (e.g. http://www.codeproject.com/KB/menus/...2003Menus.aspx).
If you don't have the free Krypton Toolkit already, I suggest using it, it also adds a really nice style to your applications (Office 2007), even the Form's nonclient area can be in the 3 colors of Office 2007. It also has new controls like HeaderGroup and BreadCrumb which are just great!
Re: Office 2003 ToolStrip renderer on Vista
Thanks, I think that's all I need :)
Instead of writing the properties out like you are now I simply have to set those properties (of my new instance of the color table) to the correct colors. That should work! Thanks.
Re: Office 2003 ToolStrip renderer on Vista
No problem, but I was editing my post while you replied already. Please read the last part too if you haven't already. :)
Re: Office 2003 ToolStrip renderer on Vista
On XP, if you use the silver theme, the default ToolStrip is silver with orange. I'm not sure if Office 2003 actually uses that style, I just assumed the visual Studio toolstrip would look like Office 2003 because it does in the blue style. But that doesn't matter, does it? As long as the ToolStrip is silver, your code will retrieve the silver colors right?
And I don't need the krypton toolkit as I have Infragistics controls, which all support Office 2007 looks too :)
Re: Office 2003 ToolStrip renderer on Vista
I've never tried ToolStrips with Silver (nor Olive) style on XP, but probably it works yes.
It's nice you already have a professional UI suite for .NET, but I always use everything for free (and also give my applications away for free) and it's quite difficult to get a nice look of your applications with only free toolkits, therefore I thought it might be an useful suggestion to you. ;)
Re: Office 2003 ToolStrip renderer on Vista
Found a strange bug - when I started the computer out of the sleeping mode, the renderer became the usual Office XP-like one. I really don't know the case nor a solution but perhaps it is because of my application I use it in.