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.
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.
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!
No comments:
Post a Comment