Click here to Skip to main content
Click here to Skip to main content

An advanced rendering class

, 14 Jul 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
A rendering class with full customizations for novice or advanced users.



Many beginners in the C# or VB.NET development category sometimes want to be able to apply themes or styles to their application. This rendering class allows you to easily customize the appearance of your C#/VB.NET applications.


This was inspired by the Office2007Renderer, which enables you to apply a multitude of Office 2007 styles to an application. After I began using Office2007Renderer, I found that some of the drawing functions caused severe lag on my applications. So, I took it into my own hands to develop a new Office2007Renderer of my own. From there, it developed into a fully editable class.

Using the code

The EasyRender class is easy to use and easy to customize. Unlike other rendering classes, I have divided each section of the renderer into sub-classes that you can then edit further.

public Main()

      EasyRender Render = new EasyRender();

      ToolStripManager.Renderer = Render;

Basically, this initializes the rendering class and applies it to the ToolStripManager, and by default, Office2007 is the default theme style. Changes can be made via the Render variable though.

public Main()

      EasyRender Render = new EasyRender();
      Render.Toolstrip.Curve = 2;
      Render.Toolstrip.BackgroundTop = Color.FromArgb(255, 255, 255);
      Render.Toolstrip.BackgroundBottom = Color.FromArgb(230, 230, 230);

      ToolStripManager.Renderer = Render;

This modification will adjust the background gradient colors for the Toolstrip control. The Curve property simply means the curve of the borders of the Toolstrip. It's suggested you don't enter a value over 4 for the Curve property, otherwise it becomes distorted.

You may want to alter the way the gradient is displayed. There are two key properties in almost every class, named BackgroundBlend and BackgroundAngle.

  • BackgroundAngle simply enables you to alter the direction in which the background gradient will be drawn.
  • BackgroundBlend is a System.Drawing.Drawing2D.Blend property. If you set this value to null, then no blending will occur. Otherwise, you can set it to a Blend value and it will draw the background with the specified blend. See below for a better idea.
  • Blend backBlend = new Blend();
    backBlend.Positions = new float[] { 0, 0.1, 0.4, 0.8, 1 };
    backBlend.Factors = new float[] { 0, 0.3, 0.6, 0.7, 0.2 };
    Render.Toolstrip.BackgroundBlend = backBlend;

For those who are not familiar with the Blend class, it simply works like an advanced gradient manager. Positions is an array of float values. Each value within it represents a position (0 to 1 means 0% to 100% of the overall length).

The Factors property specifies the intensity of the Color2 color of the gradient brush used to draw the background. So, a factor of "0" means the color is fully Color1 (or BackgroundTop), and "1" means the color is fully Color2 (or BackgroundBottom). Very handy indeed.

The rest is very easy to work out. SmoothText simply applies a smoothing effect to all text on any control that has ManagerRenderMode applied to it (which you have to apply to the StatusBar and ContentPanel controls). AlterColor simply denotes that all text affected by the renderer should use a set color, which can be defined by the OverrideColor property.

Points of Interest

A little note you may need to bear in mind is that I lost interest in this project around two months ago, so I haven't touched it since then. After I checked the code again, I saw that practically everything was in-tact. But, some of the features may not be fully implemented just yet, or there may be conversion or casting errors. If you find any, please do let me know and I'll fix it up immediately.

So, experiment with this if you want. I'll be adding an export feature when I get the time, and I'll also be adding a "Save as theme file" feature, so you can export them to a file and share them if you want.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Chris Copeland
Software Developer
United Kingdom United Kingdom
Began web-development in HTML and CSS in 2001, moving onto PHP using MySQL and Zend in 2002. Eventually moved on to basic VB6 in 2004, before transitioning to VB.NET in 2005. Around 2007, moved forward to C# 2.0 and Java development for desktop applications, before diverging into C and C++ development (using Visual Studio and GCC environments for compilation.)

Comments and Discussions

QuestionAppearance almost identical?? Pinprofessional i0021-Oct-14 1:10 
Questiondrop down arrow (grippy) color Pinmemberivanicin4-Jul-12 11:11 
QuestionComboBox Pinmemberdherrmann13-Oct-11 11:46 
GeneralMy vote of 3 PinmvpDave Kreskowiak21-Jun-11 16:46 
Generalf***ing Cool !!! Pinmembericcb101315-Jul-09 16:46 
QuestionForm Background? PinmemberLukeFrankin.com8-Oct-08 0:14 
AnswerRe: Form Background? Pinmemberviciouskinid9-Apr-09 13:43 
GeneralQuestion about the Menu Pinmemberrikidude5-Sep-08 5:56 
GeneralGenius! Pinmemberrokoprc26-Jul-08 21:50 
GeneralBehaviour differ from standard renderers PinmemberEugene Sichkar20-Jul-08 12:48 
GeneralContextMenuStrip item with subitems drawn incorrectly Pinmembertonyt16-Jul-08 12:24 
GeneralProblem with checked menu items Pinmembertonyt15-Jul-08 10:20 
GeneralRe: Problem with checked menu items PinmemberEpoque16-Jul-08 0:17 
GeneralOutstanding [modified] Pinmembertonyt15-Jul-08 6:04 
GeneralRe: Thanks. PinmemberEpoque15-Jul-08 6:07 
GeneralRe: Outstanding PinmemberLukeFrankin.com7-Oct-08 22:57 
GeneralCool Pinmemberleppie15-Jul-08 0:38 
GeneralRe: Cool PinmemberRoberto Collina15-Jul-08 1:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.141022.2 | Last Updated 15 Jul 2008
Article Copyright 2008 by Chris Copeland
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid