A while back earthandfire posted a thread in the VB.NET forum (thread796-1153488) about a color coding program for between the [[]code] [[]/code] tags.
There is one major advantage of having the Add-In. The Add-In doesn't have to look for keywords to color code. As an Add-In it has access to the code windows, which it sees as a RichTextBox - so it's just a matter of parsing the colors out for TGML.
I have the source, and setup available at - the only difference in how the original and this one works - is a checkbox labeled to TGML when choosing Copy As HTML from the menu (whether context or edit menus).
Here is a sample of the output:
Cheers!
This was a very cool idea and after finding the CopySourceAsHtml VS Add-In, I choose to experiment with option one. This thread is the C# version (I started with a post in VB.NET)earthandfire said:ZmrAbdulla posed a problem in thread796-1152284, which both ca8msm and I found very interesting and intriguing. In one of his replies ca8msm sugested that it would be a good idea if we could have a mechanism to embed colour tags between [[]code] [[]/code] tags.
This got me thinking. I can see two possible solutions.
1)
Create a VS AddIn. This would (hopefully) enable us to see the formatting used and then we would be able to pick up the colours and output a document with the appropriate formatting. I don't, however, see this as the easy option.
2)
Create a program that will parse a block of text looking for key features. For example the apostrophe could indicate that what follows should be green. A list of reserved words could be used to match up blue. Obviously this is a very simplistic summary, but, I think far more achievable than option 1. This could then be extended to support the rainbow of colours used in SQL Server.
I intend to experiment with option two.
I've posted this a separate topic in the hope that it will ignite some interest. I was actually quite surprised that so few contributors posted to the other thread.
There is one major advantage of having the Add-In. The Add-In doesn't have to look for keywords to color code. As an Add-In it has access to the code windows, which it sees as a RichTextBox - so it's just a matter of parsing the colors out for TGML.
I have the source, and setup available at - the only difference in how the original and this one works - is a checkbox labeled to TGML when choosing Copy As HTML from the menu (whether context or edit menus).
Here is a sample of the output:
Code:
[COLOR=blue]public[/color] [COLOR=blue]static[/color] HtmlColor ConvertColor( [COLOR=blue]uint[/color] oleColor )
{
[COLOR=blue]uint[/color] refColor = 0;
[COLOR=blue]int[/color] r;
[COLOR=blue]int[/color] g;
[COLOR=blue]int[/color] b;
[COLOR=blue]if[/color] ( OleTranslateColor( oleColor , 0 , [COLOR=blue]ref[/color] refColor ) != 0 )
{
[COLOR=blue]throw[/color] [COLOR=blue]new[/color] Exception( "OleTranslateColor failed." );
}
r = ([COLOR=blue]int[/color])( refColor [& 0xFF );]
g = ([COLOR=blue]int[/color])( ( refColor >> 8 ) [& 0xFF );]
b = ([COLOR=blue]int[/color])( ( refColor >> 16 ) [& 0xFF );]
[COLOR=blue]return[/color] [COLOR=blue]new[/color] HtmlColor( r , g , b );
}
Cheers!