Thursday, November 27, 2008

Windows Live Writer Plugin Development

Windows Live Writer is a cute small free blog publishing desktop application. If you are tired of the browser based tools to post your blogs, you must try Writer where you can create rich content posts offline and then publish to your blog hosting server when you are online.
lwplugin0
Windows Live Writer can be easily installed by double clicking the downloaded WLinstaller.exe file. To The initial wizard during the startup will help to configure to an existing blog or to create a new blog. There are no other additional configurations or settings involved.
Plugins helps in extending the capabilities of Writer to insert, edit, and publish new types of content. It is very easy to develop a plugin if you are a .NET developer. For the plugin development no separate SDK is required as all the APIs comes with the installation and will be available in the installation folder typically at C:\Program Files\Windows Live\Writer.
lwplugin4
lwplugin1
lwplugin2
lwplugin3
There are two types of content source plugins a) Simple (inserts custom html) and b) Smart (inserts custom html with editing options).
Content created by both simple and smart content sources can originate from an Insert dialog box, a URL, or Live Clipboard data. Each content source plugin can support creating content from one or all of these contexts.
In this post, we will see how we can develop a Simple Content Source Plugin through Insert Dialog Box. You can use Visual Studio 2008 or 2005 or 2003.
  • Launch Visual Studio and start a new Class Library Project in C#.
  • Add a reference to the WindowsLive.Writer.Api assembly (located in the directory C:\Program Files\Windows Live\Writer).
  • Create a new class derived from ContentSource base class from this API.
  • Apply the WriterPluginAttribute to the new class that will define the plugin properties. (Use a new GUID to identify this plugin. If an image is specified in the attribute, add this image as an embedded resource to the project. The publisher URL and description will appear in the Plugins options in Writer).
  • Apply the InsertableContentSourceAttribute to the new class that will define the plugin content. This will appear as the menu name under Insert menu.
  • Override the CreateContent method and code the required functionality there.
  • Add a Post Build event to the project to copy plugin dll to the Writer plugins directory after it is built (XCOPY /D /Y /R "$(TargetPath)" "C:\Program Files\Windows Live\Writer\Plugins\").
  • Build the project and then run Windows Live Writer to test and debug. New plugin will appear under Insert menu.
The complete code snippet for a hello world plugin is given below:
using System.Windows.Forms;
using WindowsLive.Writer.Api;

namespace LiveWriterPlugin
{
[WriterPluginAttribute
("8CFEFA0C-6366-419f-9590-20A6590728DC",
"My Sample Plugin",
ImagePath = "mypluginimage.png",
PublisherUrl = "http://ctlabs.blogspot.com",
Description = "A sample plugin that can insert hellow world in your blog posts")]

[InsertableContentSourceAttribute("My Sample Plugin Content")]
public class MyPlugin: ContentSource
{
public override DialogResult CreateContent(IWin32Window dialogOwner, ref string newContent)
{
DialogResult result = MessageBox.Show("Do you want to insert this sample content?","My Plugin",MessageBoxButtons.OKCancel);

if (result == DialogResult.OK)
{
newContent = "Hello World from Plugin";
}

return result;
}
}
}

That's it. Look at the above images to see this plugin in action. Happy plugin development!

Thursday, November 06, 2008

Innovation Days Again At Kochi

It was just 5 months back we had an Innovation Days event at Kochi from Microsoft. Seeing the great response from the IT enthusiasts at Kochi, Microsoft has come back today with yet another session packed event. This time the location was at Taj Residency at Marine Drive.  Kochi techies showed their interest by turning up in large numbers, making it a house-full event.

The day started with a keynote address from Vikram Rajkondawar, Architect Advisor at Microsoft (India). He spoke in detail about the Software + Services mantra Microsoft is transitioning to, and clarified myths around Cloud computing and briefly explained Windows Azure and other latest technologies. There was a Live Mesh demo that showed connected devices (two laptops and a mobile) synchronizing files between them.

The session on SQL Server performance issues by Praveen was in-depth as he discussed internals of SQL Server and how a query is parsed, algebrized and optimized before execution. He did mention that from SQL Server 2005 onwards it doesn’t matter if you are using stored procedures or inline SQL queries as both gives similar results on a performance point of view.

Nahas Mohammed did a short session on Internet Explorer 8 and demonstrated its new features like Accelerators and Web Slices.

Chandrashekar’s session on .NET debugging tools helped in understanding some of those rarely used, but highly useful debugging tools like Fusion Log Viewer (fuslogvw.exe), NGen, SoS.dll, ILDAsm, ILAsm, and Managed Debugging Assistance (MDA).

Praveen concluded the event with a session on Rich Internet Applications (RIA) and spoke about ASP.NET MVC, AJAX, jQuery integration and Silverlight.

Between the technical tracks, there was a short session on Innovate On partnership program that Microsoft launched last time. A guy from TIE (The IndUs Entrepreneurs) spoke about their institution and inspired us to think on entrepreneurship.

There were lots of goodies (T-Shirts, books) given out besides a great lunch. I enjoyed the overall event and could meet many friends/ex-colleagues as well as some new people from the Kochi developer community. As I had registered for the Innovate On program last time, I received my first kit containing a T-Shirt, Technology Specialist certificates, and CDs containing technical resources.