HotDog's Blog

Hotdog (Robert Verpalen) about C# and vb.net

This blog hosted by:
http://blogs.vbcity.com      
  Home :: Syndication  :: Login

NovDecember 2005Jan
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Articles

Archives

Topics

CONTACT

Fun but useful linkies

General

VS 2005

Wolfenstein ET

Friday, December 30, 2005 #

(First introduced here: http://blogs.vbcity.com/hotdog/archive/2004/09/11/280.aspx , )
This is the second version of the AutoFormatter. Mainly intended for easily posting code blocks to .. let's say a blog, it can also be used for rtf conversion in general.


DOWNLOAD/INSTALL

Run exe (22-1-2006) The other options all want to access the internet to check for updates. Download or run this exe to use a version that does not try to do so. That also means of course that you might not use the last version

---While testing the .application extension link did not seem to be processed properly, so you might have some problems with the links below
Run directly Run AutoFormatter directly from the internet. You can visit this page first to check if the required framework is installed or for more info on ClickOnce deployment.

Setup Setup application to run on your local machine. If installed this way updates can be automatically downloaded.



SOURCE CODE
AutoFormatter.zip (version 7-1-2006) The zip contains the source code. Written visual C# 2005 express edition. This executable may from time to time be newer than the executable, because well... it's too much work to update the source as well for some minor changes :p


Requirements: .net framework 2.0 (click here for the msdn download page) If the setup file is used, a check for the framework is automatically performed


Screenshots:
rtf
Advanced options
Preview



Note to upgraders from 1.0 : AF2.0 uses the improved applicationsettings functionality of the .net 2.0 framework and no longer the xml dataset. That means old settings are not ported, but they weren't that many, so hopefully that won't be seen as a drawback.

Some development info:

At first the AF was a quick and dirty way to be able to post code onto my blog, but since more people than just me seem to be using it (maybe just 2 people, but hey, that's still more than just me), decided to try and make it a 'complete' tool with better functionality. Also rewritten and cleaned most of it up, so that expanding shouldn't be too much of a problem.
The AutoFormatter contains custom objects that can parse themselves to html format. Eg there's a style class with a minimum of properties/attributes, which are the ones being used by the codeblock, such as background-color and onClick. The properties/attributes themselves are fields of the class type CanAppend, which is parsed automatically if a value is set. Other properties are therefore easily added in the html classes without having to add any parsing code.
I'm pretty content with how it turned out now. Some features will be added in the future, but I like its current look and feel.
The original plan was to use the .net 2.0 build in html elements (of System.Windows.Forms, used in the browser control), but they turned out to be insufficient adaptable for the set goal. Turned out those objects in turn used mshtml objects in the background. Those had all the html options with them and are included in the framework. Rewrote the code to use mshtml which worked great. Unfortunately, some of its behaviour I did not like. The goal was to keep the produced code to a minumum and the mshtml sometimes bloated for example the border settings. Besides that it was a tad slower (not much really, mainly the initializing the first time) . All and all I wanted to keep total control and went back to creating custom classes. Just wanted to say that here in case you were wondering why the available options weren't used ;-)


TODO (per 17/1/2006):
-Create file directly
-Upload the file
-Support (embedded) images. This will be done in combination with the creating/uploading of a file
-custom replacements from rtf characters to html tags
-custom style settings (implemented on a basic level per 7-1-2006)
-Assigning class ids so css sheets can be used to set the default styles (and ability to create css info)
-ColorPicker should support choosing transparant. (Implemented per 7-1-2006)
-Unicode characters (Implemented per 22-1-2006)
-Bullet list
-Keywords (C#,TSQL,VB, and any custom set)

About the keywords. That is, defining sets of keywords that get a specific formatting (eg for TSQL: “select“,“from“,“update“, etc. get a style of “color:blue“) Not too big a problem, but still much work. The real problem is if people really need it? What this would do, is format keywords after the rtf formatting is applied, so as an extra. The setup would be to simply select 'none' or a file of keyword settings to apply. The keyword file would contain pairs of keywords and style settings, where the style is the normal html style tag. (and cascading to quickly apply a style to multiple keywords).
So, if any of you are interested in such features, please drop me a note, so I know it wouldn't be a useless feature. cheers.

posted @ 12:14 PM