Click here to Skip to main content
15,174,232 members
Articles / Programming Languages / C#
Article
Posted 17 Apr 2009

Stats

28.7K views
520 downloads
14 bookmarked

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
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)

Share

About the Author

Mohammad Dayyan
Iran (Islamic Republic of) Iran (Islamic Republic of)
No Biography provided

Comments and Discussions

 
SuggestionOnline C# Code Colorizer Pin
Pavel Vladov27-Aug-12 1:21
MemberPavel Vladov27-Aug-12 1:21 
GeneralColoriser's use in web pages Pin
Dmitri Nеstеruk18-Apr-09 18:17
MemberDmitri Nеstеruk18-Apr-09 18:17 
GeneralRe: Coloriser's use in web pages Pin
Mohammad Dayyan19-Apr-09 2:38
MemberMohammad Dayyan19-Apr-09 2: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.