Click here to Skip to main content
13,298,348 members (48,458 online)
Click here to Skip to main content
Add your own
alternative version


99 bookmarked
Posted 15 Jul 2008

An advanced rendering class

, 15 Jul 2008
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 (Senior)
United Kingdom United Kingdom
I began developing at age 12, in 2002, when I learned to code basic HTML, CSS and JavaScript. I soon moved on to PHP web-development with MySQL to create interactive websites for personal projects and clients.

Later, in 2005, I explored developing in VB6 before advancing to VB.NET. After much resistance, I picked up C# development, and never turned back. Shortly afterward, I was introduced to C and C++ after working on an open-source game project. I contributed to this for several years, before hanging up my pointer->pants.

In 2008 I decided to join the growing community of Java developers, and began learning to code in this alternative model for cross-platform application development. Eventually, I would end up entering a job comprised of both Java and C# development.

Continue? Insert 20p..

You may also be interested in...

Comments and Discussions

Questionabout the tooltip Pin
rojaldearintok17-Jan-15 22:11
memberrojaldearintok17-Jan-15 22:11 
QuestionAppearance almost identical?? Pin
i0021-Oct-14 2:10
professional i0021-Oct-14 2:10 
Questiondrop down arrow (grippy) color Pin
ivanicin4-Jul-12 12:11
memberivanicin4-Jul-12 12:11 
QuestionComboBox Pin
dherrmann13-Oct-11 12:46
memberdherrmann13-Oct-11 12:46 
GeneralMy vote of 3 Pin
Dave Kreskowiak21-Jun-11 17:46
mvpDave Kreskowiak21-Jun-11 17:46 
GeneralF***ing Cool !!! Pin
iccb101315-Jul-09 17:46
membericcb101315-Jul-09 17:46 
QuestionForm Background? Pin
LukeFrankin.com8-Oct-08 1:14
memberLukeFrankin.com8-Oct-08 1:14 
AnswerRe: Form Background? Pin
viciouskinid9-Apr-09 14:43
memberviciouskinid9-Apr-09 14:43 
GeneralQuestion about the Menu Pin
rikidude5-Sep-08 6:56
memberrikidude5-Sep-08 6:56 
GeneralGenius! Pin
rokoprc26-Jul-08 22:50
memberrokoprc26-Jul-08 22:50 
GeneralBehaviour differ from standard renderers Pin
Eugene Sichkar20-Jul-08 13:48
memberEugene Sichkar20-Jul-08 13:48 
GeneralContextMenuStrip item with subitems drawn incorrectly Pin
tonyt16-Jul-08 13:24
membertonyt16-Jul-08 13:24 
GeneralProblem with checked menu items Pin
tonyt15-Jul-08 11:20
membertonyt15-Jul-08 11:20 
GeneralRe: Problem with checked menu items Pin
Epoque16-Jul-08 1:17
memberEpoque16-Jul-08 1:17 
GeneralOutstanding [modified] Pin
tonyt15-Jul-08 7:04
membertonyt15-Jul-08 7:04 
GeneralRe: Thanks. Pin
Epoque15-Jul-08 7:07
memberEpoque15-Jul-08 7:07 
GeneralRe: Outstanding Pin
LukeFrankin.com7-Oct-08 23:57
memberLukeFrankin.com7-Oct-08 23:57 
GeneralCool Pin
leppie15-Jul-08 1:38
memberleppie15-Jul-08 1:38 
GeneralRe: Cool Pin
Roberto Collina15-Jul-08 2:41
memberRoberto Collina15-Jul-08 2:41 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 15 Jul 2008
Article Copyright 2008 by Chris Copeland
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid