Almost immediately after I published the WLW WordPress.com Syntax Highlighter to CodePlex a little voice inside my head was telling me that I can do better than that. Luckily for me, that voice was right.
You can find it here: WLW WordPress.com Syntax Highlighter Plugin
The problem with the initial version of the plugin was the fact that I could not get around the "auto-encoding" feature from WLW. This basically meant that any time you wanted to have quotes or angle brackets in your code it would get encoded. Worse still was you had to go to the "Source" tab, correct the encoded characters and then remember to not go back to the "Edit" tab. Sounds like a great plugin to me…
To resolve this issue I switched from using the ContentSource base class to using the SmartContentSource base class. This base class provides you with the ability to have two sets of content: the "Editor" version and the "Publish" version. The "Editor" version is obviously what you see within WLW while the "Publish" version is what is sent to your blog.
Two methods… how simple is that?
Well… when you start off using the ContentSource and WPF… not so simple. The SmartContentSource has what is called an "Editor" which appears in the right pane of WLW when the content is selected. This "Editor" must inherit from SmartContentEditor which in turn inherits from Windows.Forms.UserControl.
Rather than attempting to fight that battle I found it was simpler to just pull out the WPF stuff and go directly with a Forms version.
Funny how the original intent was to show how to create a plugin for WLW using WPF only to rip it out. Live and learn… I guess.