Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Code Colorizer with Silverlight 2 & C#

4.33/5 (4 votes)
5 May 2009CPOL1 min read 30K   527  
Colorize C# & VB codes
Image 1

Introduction

CodeColorizer is a Silverlight 2 application to colorize codes for using in web logs or websites.
You can colorize C# and VB codes.
CodeColorizer generates valid XHTML codes, but if you're using some codes with syntax errors, probably it causes generating invalid XHTML codes.

Using the Application

Before using: If you're writing something in arbitrary CSS class name's textbox, you have to define it in your CSS codes.
For example, I recommend the following CSS class:

CSS
<style type="text/css">
<!--
.pre{
	font: 400 12px consolas,'Courier New',courier,monospace;
	width:100%; 
	margin: 0; 
	min-height: 1.2em; 
	direction:ltr;
}
-->
</style>

Using this option causes CodeColorizer to generate a shorter code.

Let's see some results of the application:

  • Striped = false;
  • C# = true;
  • Line Numbers = false;
  • Add the default Styles within Pre tags = true;
  • Add Pre Tags = true;
  • Add background color to the pre tag = true;
  • TextBoxColor = "ffecd0";

Image 2

  • Striped = true;
  • C# = true;
  • Line Numbers = false;
  • Add the default Styles within Pre tags = true;

Image 3

  • Striped = true;
  • C# = true;
  • Line Numbers = true;
  • Add the default Styles within Pre tags = true;

Image 4

Finally

Probably there are some bugs or errors in the application. I would appreciate if you post them. Thanks!

History

  • 18th April, 2009: First post
  • 21st April, 2009: Updated demo and source files
  • 5th May, 2009: Updated demo and source files

License

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