| Scott's profileInsertableContentSourceBlogLists | Help |
|
March 19 Two Live Services (LiveFX) Tokens. Here they are.Ok, so I’ve tried desperately to give these away on twitter, but apparently no-one seems to want to even reply to me to get them, so I’ll put them on here as a first come first serve basis. If you are successful in using one of the two codes, please leave a comment so that I know when they’re both gone. 00460-8DDB5-F79C5-E4C53-5B78D Enjoy March 03 WLWBackup Release CandidateI’m very pleased to announce the public Release Candidate of WLWBackup. This new version has been completely rewritten from the ground up, after a couple of problems were found with x64 systems and XP SP3 systems. All the relevant information regarding the program, including usage, can be found on the codeplex site for it. Feedback should also be left on the codeplex site in the relevant sections. SL February 26 Twitteriser PluginSomething that @NicoleSimon requested in a tweet and something that I’m sure many of you will use (if you use twitter that is). This plugin will convert @names into links to their twitter page, so for example @scottisafool will like to http://twitter.com/scottisafool. Just type your blog post as you would normally, the changes are done when you hit publish. There is an automatic option so you don’t have to say yes everytime, but it’s all pretty useful :) I’m sure hardcore blogger+twitter users like @stevecla and @jangles will probably like it :) The plugin can be downloaded from http://cid-fabdddc5cad93494.skydrive.live.com/self.aspx/Writer%20Plugins/TwitterRenamePlugin.zip Just drop both files into your plugins folder. SL PS, sorry about the delay with this post, I’ve been having Writer/Spaces issues for the last couple of weeks. Gave up trying in Writer, so have posted this manually. February 10 Live Writer Backup And XP Service Pack 3Through the feedback I’ve been getting recently and a bit of investigation, I have discovered that my Live Writer Backup tool does not backup settings when it’s run on XP Service Pack 3. I’m not quite sure why as the way I get the settings can be done manually, but whatever. I will be addressing this and I’ll update on here as soon as I have done, but for now, I apologise but you can’t back up on XPSP3. I’m also aware of some issues with x64 OSs, however, I’m having problems tracking down this problem as I’ve done it on both my Vista x64 and Win7 x64 machine and I can’t get the same issues. I think it has something to do with the version of cablib.dll, but I’ve given the x64 version of that dll to people and it’s not made a difference, so go figure. I’ll try and get to the bottom of that one too though. SL Whilst writing this, I was listening to Scissor Sisters - The Skins February 03 Live Framework Token GiveawayFor those that don’t know, the Live Framework was announced at PDC back in October and is part of the Windows Live Platform. At the moment, you can only actually develop using the LiveFX if you have been given a token, which you then have to redeem at http://lx.azure.microsoft.com/. So what does the LiveFX offer you? Well, at the moment, it allows you to access the contacts of a user as well as their Mesh objects (yes, this is what you need if you wish to create any MeshApps). I’ve written a few articles on LiveSide just giving some brief examples of code using the LiveFX (links below), but there are many more on the web that you can easily find. A “Quick And Dirty” Console Application Using The LiveFX And the best bit is, now you can run the Live Mesh client and the LiveFX Client simultaneously! So what do you need to get one of these tokens? Well, as twitter seems to be the Internet medium of choice at the moment, you have to do is complete the following sentence: “If I had a LiveFX token I would…” and put what you would use the LiveFX token for. For your tweet, you don’t need to include my part of the sentence, just put what you would do with the token and put #livefxtoken at the end. So for example, “Build a Mesh enabled rocket ship #livefxtoken”. It’s as simple as that. I will see those tweets and make a decision on which one I think would be the coolest to do (or makes me laugh the most, whichever). You have until 7pm GMT on 5th Feb to enter. SL January 29 Storing Live Writer’s Posts on a network share or anywhere actuallyAll of Windows Live Writer’s posts, both drafts and published posts, are stored in the “My Weblog Posts” in your Documents folder. Currently, there is no option to change this, however, there is a way you can fool Live Writer into thinking it’s still there! This means that you could save them onto a separate partition/hard drive, or even onto a network share (like on your WHS should you have one). Let me show you how you accomplish this. ***********Disclaimer************ I should also note that there may be other niggles that I haven’t seen yet, so this really is an “at your own risk” job and I take no responsibility if you screw this up A couple of things to say before we get going, saving them to a network share will only work in Windows Vista or Windows 7. You can save them to a different partition or hard drive in XP, but that is all. Because of this, I will split this post into two sections, Windows XP, and Windows Vista/7. You will also need Administrative rights to be able to do this. Windows Vista/Windows 7 Start off by completely moving your My Weblog Posts folder to the location of your choice, whether it be locally to that PC or on a network share. Make sure the original folder no longer exists. For this example, I will be putting it on my network share on my Windows Home Server.
This same method could be used if you want to have your posts on a different drive/partition on your local machine, it doesn’t just have to be for network shares. Windows XP Now, as mentioned, you can’t do this for network shares in XP, but you can move it to another location on your PC. Start off by completely moving your My Weblog Posts folder to the location of your choice. Make sure the original folder no longer exists.
And there you have it, how to fool Live Writer into letting you use another folder location. One final reminder, please read the disclaimer at the top of this post! SL November 23 Live Writer Sidebar gadget and Vista64It has recently been brought to my attention in two different ways that my Sidebar gadget for Live Writer doesn’t actually work with Vista x64 editions. The first was highlighted when I reinstalled my PC a couple of weeks ago and the gadget stopped working. The other was when someone passed me a blog entry by Ed Bott regarding the error message my gadget gives when it’s attempted to be run on an x64 system. How has no-one raised this to me before? I’m sure there must be more than just me and Ed Bott using it on x64 systems?! Anyhoo, I’m pleased to say that I have now fixed this, and in record time, Live Gallery has approved it (less than 12 hours!). Anyway, go download the new gadget if you’re running x64 systems. SL November 10 Autoreplace, You Say? Yes, I Say!About a month ago, I was digging around in the registry for something, (I forget what it was now) and I found a very interesting registry key for Live Writer. I was intrigued as this offered a great feature for Writer. I played about with it for a bit and got this mysterious [undocumented] feature working. As you can gather from the title of this post, it’s an Autoreplace feature. So, with no UI in the current Writer versions for this feature, I decided to hack together something of my own:
This feature works in the same was as the autoreplace you see in Word, replacing the words as you type them in the editor. You can download the plugin from my skydrive area, then just drop it into your plugins folder. In Writer, you will see this:
Just click on that and you will get the above screen. From there you can add what you want to replace and with what. Now, as the plugin states, these changes will take effect next time Live Writer is restarted. Once you have restarted Live Writer, then you should be good to go. *****DISCLAIMER***** Just as a note, it has been found that this feature may not be present in non-English versions of Live Writer/Windows. Would love to hear if anyone gets it working when they have a combination of non-English Live Writer or non-English Windows. The scenario we have seen so far is English Live Writer on an Italian version of Vista. SL Whilst writing this, I was listening to Girls Aloud - Live In The Country October 07 Clipboard Image PluginI often see a lot of requests for how to change the image filename of an image you have pasted straight into Writer, like a screenshot for example. Currently there is no way within Writer of changing this filename, so you will always end up with “image[x].png” in your blog posts. Well, I have now made a plugin (that will sadly only work with the current beta version) that will allow you to insert the clipboard image (ie, your screenshot) and give it a meaningful name. The picture on the left is the initial screenshot I took for the example. The picture on the left is a screenshot showing the filename. To do this, once you have taken your screenshot, just go into Writer and click on Insert Clipboard Image, you will then be prompted by the following screen: Here you can choose what name you wish to give the file, and what format (the choices are jpg or png). You can also set what the default image format will be from the options: I will be making the source code available at some point, but I’m feeling particularly lazy today, so that will have to wait. In the meantime, you can download the plugin from my SkyDrive area. SL October 03 Live Writer Wave 3 + Insert Video (Mine) = FAIL!If you are using my Insert Video plugin and the latest Windows Live Writer Wave 3 beta, you will probably find that you are getting an error when trying to insert. This is a bug, but not with my plugin. The Live Writer team somehow managed to break the API that the plugin uses. This has been raised with them and they are now aware of the problem, so hopefully that should get fixed in the next release. Apologies for any inconvenience this causes, but ‘twas not me guv’nor ;) SL Whilst writing this, I was listening to REM - The Great Beyond September 03 CS 2008 + IE8 + Windows Live Writer CTP = Fail!Some of us on Liveside have been having issues using Windows Live Writer CTP when opening some of our previous posts (or any drafts we have saved). The problem is that the post starts to open in Writer, then just dies. Completely. No error, no warning, nothing. We couldn’t work out what had changed, but after Sunshine had spoken with Joe Cheng they established that problem was being caused by Internet Explorer 8 when the posts had images in them. However, I wasn’t as easily convinced, since I could open posts from this blog and my personal blog just fine, which made me think it’s something specific to Liveside. Now, the difference between my blogs and Liveside is that we now use Community Server 2008 and my blogs use Live Spaces, so I fired up one of my test CS 2008 blogs on my machine, and tried the same thing: created a post for that blog with an image in it, then save it as a draft; close writer then reopen and try and open that draft. Sure enough, Writer just closed. So it seems it’s not something specific to Liveside, but something specific to how IE8 renders the CS code that Writer is using. Now, the good thing is, that at the moment, the workaround for this is to turn off editing with theme, so before you open a post with images for your CS 2008 post, click on View > Edit Using Theme (or just make sure it’s not ticked). Doing that disables all the CS code and opens your post just fine. I’m going to try and pass this to the relevant channels: The Writer Team, the IE Team and Telligent. Hopefully between them, they can sort it out. In the meantime, well, there’s the workaround for it. SL Whilst writing this, I was listening to John Williams - In The Devil's Snare & The Flying Keys August 29 IE8 AcceleratorsWith the release of a much more stable IE8 (beta 1 was truly, truly awful), I am now able to actually try some of the cool things that are in IE8. One of these things are the accelerators that you can install. What this means is you could highlight some text on a page and get a little icon appear in the page giving you some options for that highlighted text: Some of the accelerators are for searching on Google/Live Search, looking stuff up on maps, etc. Now, the cool thing is you can create your own, so I’ve created one that’s for IMDB that will look up the highlighted text on IMDB, whether it be actor/actress/movie. So using the above example, this will give you the following context menu: This will then take you to the IMDB results, in this case, it takes me to http://www.imdb.com/name/nm0515116/ which is Blake Lively’s IMDB page. If there are multiple people with the same name then it will give you the search results where you can choose. So how did I make it? It’s simple, head on over to the MSDN OpenService Accelerators Developer Guide and read what’s going on there. Then it’s just a case of creating your own xml file. Mine looks like this: <?xml version="1.0" encoding="UTF-8"?> <os:openServiceDescription xmlns:os="http://www.microsoft.com/schemas/openservicedescription/1.0"> <os:homepageUrl>http://www.imdb.com</os:homepageUrl> <os:display> <os:name>Look up on IMDB</os:name> <os:icon>http://www.imdb.com/favicon.ico</os:icon> <os:description>Look up someone on IMDB</os:description> </os:display> <os:activity category="Search"> <os:activityAction context="selection"> <os:execute action="http://www.imdb.com/find?s=all&q={selection}" /> </os:activityAction> </os:activity> </os:openServiceDescription> Now, the only thing about making your own accelerator is the xml file has to be hosted on an actual domain and be callable from http or https. I thought this would be fine, just stick it on my www.scottisafool.co.uk domain, job done. But no, my host (1and1) seems to not be letting me access my ftp server, so I was stuck. Then I remembered good ol' Windows Live. So both the xml file, and a simple html file are now both hosted on my SkyDrive area so you can install from there. Feel free to leave any comments or problems with it :) SL Whilst writing this, I was listening to Def Leppard - Promises August 05 Writing Plugins For Windows Live Writer – Logging ErrorsSometimes your plugin will require some kind of logging, especially when it comes to logging errors that have occurred. So rather than reinvent the wheel for this, the Live Writer API has a class for doing just this, and logs it into the Windows Live Writer log file. So if you have implemented this in your plugin and you get an email come in with it giving errors or not working, you can request the log file and check what has been written. In the following example I’ll show you the code samples needed for logging to the WLW Log file. This is a very simple thing to demonstrate, so I’ve created a simple plugin with a form and two buttons, one will call an error message box that looks like a normal Windows Live Writer error window as well as log it to the Windows Live Writer logfile. The second button will be used to try and open a file that doesn’t exist and so would normally throw an exception. So the form looks like: And when we click the first button we get: When you then look in your logfile, you will see an entry at the end that says:
Which as you can see is what is in that error window. For the second button we get: and again in the logfile:
With the second button, you’ll see that we aren’t presented with the standard Windows Live Writer error window, but a standard Windows error, the reason for this is because it’s the only way for the Writer team to get information about the error. What they then do is contact the plugin author and give them the details. Now, to add this functionality to your plugin is dead simple: private void button1_Click(object sender, EventArgs e) { // Log a general Error Message it to the user string message = "This is an error logged and displayed by the Plugin Diagnostics Plugin"; PluginDiagnostics.LogError(message); // This one will show the error to the user as well as log it PluginDiagnostics.DisplayError("Oh no, an error!", message); } private void button2_Click(object sender, EventArgs e) { // Log an exception by opening a non-existent file try { File.Open(@"c:\scottisafool.scott", FileMode.Open); } catch (Exception ex) { PluginDiagnostics.LogException(ex, "From Plugin Diagostics Plugin"); // This will display an error in the same way that Windows displays its own errors. PluginDiagnostics.DisplayUnexpectedException(ex); } }It’s as easy as that! With the first button, it’s up to you whether you display the error message or not (you might not need to). If you use the DisplayError() method, this gets written to the log file automatically, so although I show both methods in that example, it’s not necessary. This goes for the LogException() and DisplayUnexpectedException() methods too. As always, you can download the source for this little sample from my skydrive area: PluginDiagosticsExample.zip SL Whilst writing this, I was listening to Linkin Park - One Step Closer June 03 New Writer Plugins Using The New SDKAs mentioned, and demonstrated, there is a new SDK for Live Writer and true to form, I have been beavering away with them writing up new plugins. This post will showcase the 6 plugins I’ve written using the new SDK. So let’s jump straight into it. Emotify Plugin You might remember that the first plugin I ever wrote for Live Writer was my Insert Emoticon plugin, where you clicked on the insert link on the right, chose your emoticon and put it in your post. Well I always found that to just be tedious and a pain, so with this new SDK, I can now take it one step further. So I have added to the original plugin and now you can simply do a Live Messenger emoticon code in your post Now Playing There are many different plugins that allow you to put what you’re listening to into your blog and I think I’ve used each one, but this is a perfect example of a plugin that could utilise the HeaderFooterSource base class. And that’s exactly what I’ve done. The plugin itself is nothing special, it doesn’t even have its own API, but what it does allow is for you to customize what you want it to say and what parts of the song to show: Now, a couple of things about this plugin, for it to work, you need to have the Windows Media Player blogging plugin which you can download here for XP or here for Vista. If you’re using iTunes, then you don’t need to install anything else, the plugin will query iTunes itself for the currently playing information. Capitalize Title This is a very simple plugin that will check to see if your blog title is using capital letters for the first letter of each word, if this isn’t the case, then it changes that. So a blog title would look like this: A New Blog Post Entry With Capital Letters (rather than: a new blog post entry with capital letters). Signature Plugin This plugin is quite unique as it has per blog settings! What this plugin does is uses the HeaderFooterSource and at the end of the blog entry will put a signature (like SL in my case). Now sometimes you want to use different signatures for different blogs (if you have more than one configured), so this plugin allows you to have different signatures for each blog configured!! Bold Hyperlink Plugin This was a request from Steve Clayton who wanted all of his hyperlinks to be bold, so that’s what this plugin does. It checks the contents of the blog entry and makes all the hyperlinks in the blog post bold. Profanity Checker This plugin was something I discussed with the Writer team as a good example of the PublishNotificationHook base class for checking the contents of a post and cancelling the publish if certain criteria are met. So this allows you to configure what words would cancel a blog post from being published, and just to make sure they can’t easily be changed (say by a child), you have to password protect them ScottIsAFool.WriterUtilities For some of these plugins, they all required some common code, so I have started compiling my own WriterUtilities static class. Now one of the methods you’ll find is a nice little trick for your Writer plugins. In the IPostInfo interface, all the properties (like title, contents, keywords, etc) are read only, so you can’t actually change them using your code. But wait a minute, isn’t that what I’m doing with at least 3 of the above plugins? Yes, yes it is. Using this WriterUtilities class, you can also change it too, but be warned, it is unsupported by Microsoft (and me public override bool OnPrePublish(IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { string newtitle = "My New Title"; return ScottIsAFool.WriterUtils.ReplaceText(publishingContext.PostInfo, newtitle, PostItems.Title); } I also have a another method which returns an array of Blogs configured on the system (which I use for my Signature plugin). I should note that this utilities class is only compatible with the CTP and should not be used in the 1.0 SDK! Source Code As always I am making the source code for all these available on CodePlex. Codeplex page: http://www.codeplex.com/NewLiveWriterPlugins All of these plugins should be put in c:\program files\windows live\writer\plugins (or the locale/architecture equivalent). SL Whilst writing this, I was listening to Aerosmith - Lay It Down The New Live Writer SDKIn my LiveSide post, I mentioned that the Live Writer SDK had been updated as well as Live Writer itself. In this post I will show you how to build a couple of quick plugins that use the new APIs, but first, what’s changed? The big thing to note is that all the API calls in the previous version of the SDK are unchanged; the changes have been additions to the SDK. So the main two new additions are two new plugin classes: PublishNotificationHook and HeaderFooterSource. This gives us four types of plugins: ContentSource, SmartContentSource, PublishNotificationHook and HeaderFooterSource. There are also a couple of other new smaller additions, like the TaskServices class that will let you perform a task in the background whilst still keeping the Writer UI in a responsive state. But this post is going to concentrate on those two new Plugin base classes, which you can see after the jump. PublishNotificationHook This type of plugin can be used to access the post either before or after it’s published. The reason you might want to do this is to check the post for something, this can be the title, the contents or even the keywords (blog engine permitting). You would check the post for whatever you’re looking for and if it passes your check, you allow the post to be published, or else you tell Writer to stop publishing and the post remains unpublished. Let’s look at some code. The plugin starts off the same way as a ContentSource or SmartContentSource plugin in that you have to declare some WriterPlugin attributes: [WriterPlugin("07b95fc3-887e-4558-b53a-0e2a5a47f431", So now we create the plugin class and mark it as a PublishNotificationHook class: public class PublishNotificationExample : PublishNotificationHook { Like ContentSource or SmartContentSource plugins, you can override the Initialize() method (if your plugin requires settings), this is also true for HeaderFooter plugins too. With PublishNotificationHook plugins, I mentioned that you can access the post before (or after) it’s published, and we do this by overriding the OnPrePublish and OnPostPublish methods. In this very quick example, I’m going to check whether my post’s contents (ie, the body of the blog entry) contains the word “liveside”: public override bool OnPrePublish(IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { // Check the post contents to see if liveside appears, if it does, Now, the publishingContext.PostInfo is where all the cool stuff is. In this property (which is an IPostInfo object), you have access to the Contents, Keywords, Title, Categories, and even tells you whether it’s a page or not (for Wordpress users). Now with this quick check, if my post doesn’t contain the word liveside, then the OnPrePublish method will return false which will stop the post from publishing, if it does contain it, then it will return true and continue to publish. The OnPostPublish method is slightly different, this method would allow you to do something once the post has been published, for example, update your Twitter status with the blog title and permalink: public override void OnPostPublish(IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { // If this post is a draft (false), don't do anything // if it's an actual publish, then publish = true; if (!publish) return; string updateTwitter = string.Format("{0} - {1}", publishingContext.PostInfo.Title, publishingContext.PostInfo.Permalink); // Code to update Twitter } You’ll notice the variable publish that gets passed in both OnPostPublish and OnPrePublish, this will tell your plugin whether it’s being saved as a draft or as an actual published entry. This is the same for HeaderFooterSource plugins, too. And there you have it, a quick plugin that uses the PublishNotificationHook base class. HeaderFooterSource This type of plugin can be used to automatically add some html code to a blog post as either a header, or a footer. Quick examples of this could be a Digg button (header), or Social Bookmarking widget (footer). Now the cool thing about this type of plugin is you can actually specify the permalink for the post to be used, even if the post has yet to be published (I’ll cover this when I start going through the code). If you want to see what your post will look like when using this type of plugin, you just go to the Preview tab and the plugin will get loaded (there are separate methods for the Preview HTML and the Published HTML, but again, I’ll go through that in the code). Start off by creating the class and declaring it as a HeaderFooterSource plugin: public class HeaderFooterSourceExample : HeaderFooterSource { Now, as I mentioned, the cool thing about this base class is you can tell the plugin to use the post’s permalink (even though it hasn’t been published yet), but what we need to do is tell Writer that the plugin will require a [currently] non-existent permalink, we do this by overriding the RequiresPermalink boolean (whose default is false): public override bool RequiresPermalink { get { return true; } } The HeaderFooterSource base class will create two methods for us: GeneratePreviewHtml() and GeneratePublishHtml(). Now these both work in a similar way to GeneratePublishHtml() and GenerateEditorHtml() in SmartContentSource plugins. The GeneratePreviewHtml() is what shows when you switch to the Preview tab, and the GeneratePublishHtml() is what gets published. So first off the GeneratePreviewHtml(): public override string GeneratePreviewHtml(ISmartContent smartContent, IPublishingContext publishingContext, out HeaderFooterSource.Position position) { // This tells the plugin where to put your code position = Position.Header; return "Nothing to see here yet!"; } And then the GeneratePublishHtml(): public override string GeneratePublishHtml(IWin32Window dialogOwner, ISmartContent smartContent, IPublishingContext publishingContext, bool publish, out HeaderFooterSource.Position position) { position = Position.Header; string yeehaaaa = string.Format("This blog entry's link is: <br />" + "<a href=\"{0}\">{0}</a>.", publishingContext.PostInfo.Permalink); return yeehaaaa; } So if you now click on the Preview tab, your post would look like this: Notes about these plugins After you have have first added any of these plugins to Live Writer, when you click on the Publish button (or Preview for HeaderFooterSource), Writer will ask you if you want to use these plugins for the blog you’re currently using:
For these new types of plugins, you can enable or disable each plugin on a per blog basis, which you can do from the Accounts options window: And that’s about all you need to know for now. I have made some plugins of my own using these new APIs, but I will cover those in another post. As always, the source code for this can be found in my skydrive area: SL Whilst writing this, I was listening to The Lightning Seeds - Change March 18 Writing An Application That Opens Windows Live WriterEveryone knows that you can easily make a plugin for Windows Live Writer, but one of the APIs that's not as well known or spoken about is the Windows Live Writer Application API. This set of API calls will allow you to open Windows Live Writer in a particular way. What do I mean by that? Well, you can open Live Writer at the Open Post window, or the options window, as just a couple of examples. The real power with this API is the BlogThis set of calls. Some of you might be familiar with the Blog This addins for Internet Explorer (no longer available) and Firefox, which would allow you to click on the Blog This button in your browser, and it would open up Live Writer with either the page details loaded in Writer, or the highlighted text from the webpage you were viewing. Also anyone who uses my Live Writer sidebar gadget in Vista, this uses the same principle. In this article I will show you how to write a simple Windows application that uses some of the BlogThis calls. To start off, make sure you have the latest version of Windows Live Writer installed by going to http://writer.live.com/. Now, create a new project in Visual Studio and add a reference in that project to the Windows Live Writer COM assembly (C:\Program Files\Windows Live\Writer\WindowsLiveWriter.Application.dll) and then for using it we put: using WindowsLiveWriterApplicationLib;
Now we have to create an instance of the WindowsLiveWriterApplicationLibClass: WindowsLiveWriterApplicationClass wlwapp; public Form1() { InitializeComponent(); wlwapp = new WindowsLiveWriterApplicationClass(); cbOptions.SelectedIndex = 5; } Now, for this example I have just created a basic WinForms application with a series of buttons for showing the different functions, it looks like this:
This App will show a few examples, but not all, after a certain point, they're all one and the same really, just for a different use. We'll start off with the basic Open Writer button. The call that we make for this one is NewPost(), as that is effectively opening Writer as if running the program from a shortcut. So the code for this is: private void btnOpenWriter_Click(object sender, EventArgs e) { wlwapp.NewPost(); } For the Open Post button, we use OpenPost(): private void btnOpenPost_Click(object sender, EventArgs e) { wlwapp.OpenPost(); } Now for the Open Options button, we use the ShowOptions() call. This call can be made with no parameters, and it will default to the preferences tab in the options window. However, you can put in a string parameter to open a different tab from the options window, and you can choose from the following: "preferences", “accounts”, "blogthis", “spelling”, “glossary”, "plugins", "webproxy", and "pings". And you can see from my App that I have put this in a drop down: Which for the code looks like: private void btnOpenOptions_Click(object sender, EventArgs e) { string option = cbOptions.SelectedItem.ToString(); wlwapp.ShowOptions(option); } Now, the cool thing about this API is when it comes to putting images into a blog post and there are a couple of methods you can use for Images, one is for a single image, and one is for an image-set, so for multiple images. I'll start with the single image method first which uses the BlogThisImageFile() call: private void btnOpenWithImage_Click(object sender, EventArgs e) { DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { string title = string.Empty; if (!string.IsNullOrEmpty(txbxBlogTitle.Text)) { title = txbxBlogTitle.Text; } else { title = "My New Blog Post"; } string imagefile = openFileDialog1.FileName; // Open a new post using the imagefile we just selected wlwapp.BlogThisImageFile(title, imagefile, txbxComment.Text); } } And for multiple images, we use the BlogThisImageFileList() call: private void btnOpenWithFiles_Click(object sender, EventArgs e) { DialogResult result = openFileDialog2.ShowDialog(); if (result == DialogResult.OK) { string title = string.Empty; if (!string.IsNullOrEmpty(txbxBlogTitle.Text)) { title = txbxBlogTitle.Text; } else { title = "My New Blog Post"; } string[] imagefiles = openFileDialog2.FileNames; // Open a new post with the files we selected wlwapp.BlogThisImageFileList(title, imagefiles, txbxComment.Text); } } The BlogThis set of calls also has one for URLs, BlogThisLink(), which will most likely be what the Blog This add-ins for IE and FF use. The code for this is: private void btnOpenUrl_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txbxUrl.Text) && txbxUrl.Text.StartsWith("http://")) { label3.ForeColor = Color.Black; string title = string.Empty; if (!string.IsNullOrEmpty(txbxBlogTitle.Text)) { title = txbxBlogTitle.Text; } else { title = "My New Blog Post"; } wlwapp.BlogThisLink(title, txbxUrl.Text, txbxComment.Text); } else { label3.ForeColor = Color.Red; } } As I mentioned, I'm not going to go into detail about the others, but I will give a quick description of them:
There are some good examples of where these API calls have been used, and I have tried to cover the main ones in this post, although one I haven't mentioned is one I used quite frequently, which is the Live Writer System Tray App, which works in a similar way to my sidebar gadget. If you wish to download the source code for my example app, you can do so from my SkyDrive area. SL March 17 Insert Video Source Code Released!In a decision I have been mulling over for quite some time now, I have finally decided to release my Insert Video plugin's source code. The reason I hadn't released it before was because of the amount of time and effort I had put into making the plugin, it was my pride and joy, and I wasn't comfortable releasing all my hard work so freely, call it selfish if you will, I don't care If I'm honest though, the main reason I have released this isn't so people can see how I made the plugin, but to be able to add to it themselves. I have a number of projects that I'm working on at the moment and just don't have the time to maintain the plugin, to add in the video sites that people are requesting. So I figured if the source code is out there, the community themselves can actually update and build the plugin themselves with added sites. Now, I will warn any enthusiast that wants to look at the code, it's not clean, this was mainly written about 18 months ago and I was still very much finding my feet when it came to programming, having just got back into it again. There are virtually no comments, if any at all. My logic, whilst seemingly logical to me, might escape others and have them scratching their head thinking "what the f...". I don't blame you, I actually had the same problem when I did the last update So, go over to the source code now on CodePlex: http://www.codeplex.com/InsertVideo SL Whilst writing this I was listening to Oasis - 10 Cigarettes & Alcohol Insert IMDb PluginFor the longest time I've wanted to do a plugin for IMDb, but unfortunately, they don't offer any kind of API to tap into, which would mean doing a whole bunch of screenscraping, which to be honest, I really couldn't be bothered to do. Now, IMDb still doesn't offer any kind of API, but I was on CodePlex the other day and found someone has been writing a wrapper for IMDb that does all the screenscraping that I would have to have done. Great It's very easy to use, there are two methods in which you can get the film details, you can either search for the film you want, or if you have the IMDb link, you can paste the link in and get the relevant details: So now that you have the film information you want, you can choose what parts of it to put in your blog entry, so if you didn't want the description to appear, just untick it and it won't appear. Once you're ready to insert, hit Insert and you'll get something like this: Jurassic Park Sam Neill, Jeff Goldblum, Bob Peck, Joseph Mazzello, Samuel L. Jackson, Wayne Knight Scientists clone dinosaurs to populate a theme park which suffers a major security breakdown and releases the dinosaurs. Easy huh. Now, when it comes to what information you want to show, I have given three predefined templates, or you can choose a custom option: Now, as I mentioned, I'm using the IMDb wrapper from CodePlex, but I had to make a slight alteration to its code for use in the plugin, so the plugin itself comes with a slightly custom build of the wrapper. All I did was change the following line of code from: Wc.Proxy = Nothing to: Wc.Proxy = PluginHttpRequest.GetWriterProxy() This makes sure my plugin carries on like my other plugins in using Writer's proxy settings so it can be used behind a proxy. As the source code for the original wrapper is Open Source, I have also included the modified source code within my own project page on CodePlex. I should however note that the wrapper was written in .NET 3.5 which means for my plugin to use it, it had to be built in .NET 3.5 too, which was kind of annoying, but hey ho. If you want to use this plugin you have to make sure you have .NET 3.5 installed. If you don't you'll be prompted by the installer anyway. Download: http://gallery.live.com/LiveItemDetail.aspx?li=aa71d18d-e738-475d-85fa-198c64ea3987 SL Whilst writing this I was listening to Manic Street Preachers - Interiors (Song for Willem De Kooning ) March 14 My Live Writer Article for CoDe MagazineLast year at the back end of November, I got asked by CoDe Magazine if I would like to write an article for a special edition of the magazine dedicated to Windows Live that would be getting published for Mix08. Sure, I said. So I wrote my article on developing plugins for Windows Live Writer. Well, Mix was last week, and on the Wednesday, the magazine was published, complete with my article CoDe Magazine - 2008 - Vol. 5 - Issue 2 - Windows Live Developing Plugins for Windows Live Writer SL March 05 What The...?I just went to check something in the source code of one of my Live Writer projects, so I went to CodePlex, and on the front page I saw this: Notice the second one! I didn't even realise I'd put the installer up for download on CodePlex, I thought it was on Live Gallery only. Anyway, so I went to the release page to see how many downloads and was literally gobsmacked! That's almost 4 times as many downloads as my video plugin! So this makes it officially my most popular plugin, and possibly the most popular plugin, period! Wow! SL Whilst writing this I was listening to Lenny Kravitz - Little Girl's Eyes |
|
|