Click here to Skip to main content
15,883,831 members
Articles / Programming Languages / C#

Code Colorizer with Silverlight 2 & C#

Rate me:
Please Sign up or sign in to vote.
4.33/5 (4 votes)
5 May 2009CPOL1 min read 29.7K   527   14   3
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)


Written By
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
SuggestionOnline C# Code Colorizer Pin
Pavel Vladov27-Aug-12 0:21
Pavel Vladov27-Aug-12 0:21 
GeneralColoriser's use in web pages Pin
Dmitri Nеstеruk18-Apr-09 17:17
Dmitri Nеstеruk18-Apr-09 17:17 
GeneralRe: Coloriser's use in web pages Pin
Mohammad Dayyan19-Apr-09 1:38
Mohammad Dayyan19-Apr-09 1:38 

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.