Wednesday, June 24, 2009

The birth of CodeEmbed4Web

I've been blogging here for some time now and I've been active on many forums and in several communities and I've always been annoyed by the fact that non of the media used has decent support for adding different kinds of source code and other technical content to them. Sure, a there are a lot of suggestions as how to do this, but they never really met my expectations. They either take to much effort or the result is not looking good enough.

Thinking about this the other day made me decide to make my own tool for this. I sad down, thought about my process of using technical content and I came up with how I felt the flow should be. Here is what I figured will work the best for me:
  1. Copy some code from Visual Studio
  2. Click a button in my tool / press some short-cut key combination
  3. Paste the result in whatever
Using these steps would have the least impact on my normal working flow and therefor make the most sense. There are some challenges, however. I would need the tool to detect whatever I put in to it and I would need it to know what format to convert it into. Especially that last step seems to be impossible. How would it know what I'm planning to paste my code into?
Thinking about that some more, I decided to scrap that last bit and add a small step to the flow:
  1. Copy some code from Visual Studio
  2. Choose a target if necessary
  3. Click a button in my tool / press some short-cut key combination
  4. Paste the result in whatever
Obviously I can still optimize that by making available more buttons or short-cut key combinations, but I didn't want to put in that much effort right at the beginning.

As I'm experienced in buildin Silverlight 2.0 applications I decided to use WPF as my technology. This allows me to access the clipboard and it has better keyboard support then Silverlight. Also, having to open a web application, has been one of the causes that using some of the existing tools takes to much effort.

I've been playing around with WPF and the clipboard and found out that VS (at least 2008) copies it's content to the clipboard using the RTF format. This drew me towards the RichTextBox control, so I placed one in my window and pasted the content into it and it looked great. I studied the documentation on the underlying FlowDocument technology and decided to run with it.

Now I've already built code to convert RTF to a FlowDocument instance (without the RichTextBox control, obviously) and then to XML, which will allow me to build several XSLT templates on top of that XML, which I can then apply to the XML to get to the end result.

Next steps will be:
  1. Test this with XAML
  2. Build templates for C# and XAML to convert to HTML (and maybe XAML?)
  3. Brush up the user interface
  4. Build a setup
  5. Release Beta 1
You've read that right. I will release this tool, and for free (at least for now). So if you're interested in this tool, please come back to my blog for more news or better yet, subscribe to my RSS feed on the top-right of this page.
If you have any question, suggestions or comments, you know the drill (that means, leave them below).

No comments:

Post a Comment

Post a Comment