<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SharpLab. &#187; BlogThisPlugin</title>
	<atom:link href="http://blog.sharplab.net/category/computer/cprograming/windowslivewriter/blogthisplugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sharplab.net</link>
	<description>Shiroicaが学び、経験したことを綴る個人サイト。</description>
	<lastBuildDate>Thu, 12 Jan 2012 00:57:03 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>BlogThisPluginよもやま話</title>
		<link>http://blog.sharplab.net/blog/2008/09/23/1131/</link>
		<comments>http://blog.sharplab.net/blog/2008/09/23/1131/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 09:52:11 +0000</pubDate>
		<dc:creator>shiroica</dc:creator>
				<category><![CDATA[BlogThisPlugin]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Windows Live Writer]]></category>

		<guid isPermaLink="false">http://blog.sharplab.net/computer/cprograming/windowslivewriter/blogthisplugin/1131/</guid>
		<description><![CDATA[とりあえずWindows Live Photo Galleryのプラグインを作るぞー！ということでサクッと作ってみたBlogThisPlugin。書くことが無さ過ぎて、前のエントリは無駄に英語で書いてみたりしてみましたが、このエントリでは、このBlogThisPluginを作るにあたってWindows Live Photo Gallery Publishing Plug-in Platformを調べて分かったことを記したいと思います。ちなみに、Windows Live Photo Gallery Publishing Plug-in PlatformとはWindows Live Photo Galleryの拡張をホストする機能のことで、これを使えば「投稿」メニューに独自の項目を追加することが出来ます。 Windows Live Photo GalleryのPublishing Plug-in（以下Publishing Plug-in）の作成はIPublishPlugin Interfaceを実装したクラスを作成し、そのアセンブリのパスやIPublishPlugin Interfaceを実装したクラスの完全限定名などをPublishing Plug-in Registry Settingsに従ってレジストリに登録すれば出来上がり、という流れです。属性を活用していたWLWに比べると、ちょっとレガシーですね。IPublishPlugin Interfaceを実装するにあたってはPublishing Plug-in Architectureを参照し、どのメソッドがどのタイミングで呼び出されるかを確認するとよいでしょう。メソッドの呼び出しの合間に、Live Photo Galleryが進捗状況を表示するダイアログを挟みこんできたりするので…。また、Publishing Plug-in Platformは、IPublishPluginのメソッドを呼び出す際、IPublishPlugin Interfaceを実装したクラスのインスタンスを使いまわさず、インスタンスを生成し直してくる場合があるので、その点にも注意した方がよいでしょう。 折角なので、BlogThisPluginのソースコードを晒してみます。 using System; using System.Collections.Generic; using System.Text; using System.Xml; using Microsoft.WindowsLive.PublishPlugins; using WindowsLive.Writer.Api; namespace SharpLab.BlogThisPlugin { public [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.sharplab.net/wp-content/uploads/2008/09/image10.png" rel="lightbox"><img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin-left: 0px; margin-right: 0px; border-right-width: 0px" height="184" alt="image" src="http://blog.sharplab.net/wp-content/uploads/2008/09/image-thumb10.png" width="304" align="right" border="0" /></a> とりあえずWindows Live Photo Galleryのプラグインを作るぞー！ということでサクッと作ってみた<a href="http://blog.sharplab.net/computer/cprograming/windowslivewriter/blogthisplugin/1128/">BlogThisPlugin</a>。書くことが無さ過ぎて、<a href="http://blog.sharplab.net/computer/cprograming/windowslivewriter/blogthisplugin/1128/">前のエントリ</a>は無駄に英語で書いてみたりしてみましたが、このエントリでは、このBlogThisPluginを作るにあたって<a href="http://msdn.microsoft.com/en-us/library/cc967070.aspx">Windows Live Photo Gallery Publishing Plug-in Platform</a>を調べて分かったことを記したいと思います。ちなみに、Windows Live Photo Gallery Publishing Plug-in PlatformとはWindows Live Photo Galleryの拡張をホストする機能のことで、これを使えば「投稿」メニューに独自の項目を追加することが出来ます。</p>
<p>Windows Live Photo GalleryのPublishing Plug-in（以下Publishing Plug-in）の作成は<a href="http://msdn.microsoft.com/en-us/library/cc967062.aspx">IPublishPlugin Interface</a>を実装したクラスを作成し、そのアセンブリのパスや<a href="http://msdn.microsoft.com/en-us/library/cc967062.aspx">IPublishPlugin Interface</a>を実装したクラスの完全限定名などを<a href="http://msdn.microsoft.com/en-us/library/cc967074.aspx">Publishing Plug-in Registry Settings</a>に従ってレジストリに登録すれば出来上がり、という流れです。属性を活用していたWLWに比べると、ちょっとレガシーですね。<a href="http://msdn.microsoft.com/en-us/library/cc967062.aspx">IPublishPlugin Interface</a>を実装するにあたっては<a href="http://msdn.microsoft.com/en-us/library/cc967073.aspx">Publishing Plug-in Architecture</a>を参照し、どのメソッドがどのタイミングで呼び出されるかを確認するとよいでしょう。メソッドの呼び出しの合間に、Live Photo Galleryが進捗状況を表示するダイアログを挟みこんできたりするので…。また、Publishing Plug-in Platformは、IPublishPluginのメソッドを呼び出す際、<a href="http://msdn.microsoft.com/en-us/library/cc967062.aspx">IPublishPlugin Interface</a>を実装したクラスのインスタンスを使いまわさず、インスタンスを生成し直してくる場合があるので、その点にも注意した方がよいでしょう。</p>
<p>折角なので、BlogThisPluginのソースコードを晒してみます。</p>
<div class="wlWriterEditableSmartContent" id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:39505842-5f3f-4ffe-89b5-6dc4ee66ced9" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre name="code" class="c#">using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using Microsoft.WindowsLive.PublishPlugins;
using WindowsLive.Writer.Api;

namespace SharpLab.BlogThisPlugin {
    public class PublishPlugin : IPublishPlugin{

        public bool HasPublishResults(System.Xml.XmlDocument sessionXml) {
            throw new NotImplementedException();
        }

        public bool HasSummaryInformation(System.Xml.XmlDocument sessionXml) {
            throw new NotImplementedException();
        }

        public void LaunchPublishResults(System.Xml.XmlDocument sessionXml) {
            throw new NotImplementedException();
        }

        public bool PublishItem(System.Windows.Forms.IWin32Window parentWindow, string mediaObjectId, System.IO.Stream stream, System.Xml.XmlDocument sessionXml, IPublishProperties publishProperties, IPublishProgressCallback callback, System.Threading.EventWaitHandle cancelEvent) {
            throw new NotImplementedException();
        }

        public void ShowSummaryInformation(System.Windows.Forms.IWin32Window parentWindow, System.Xml.XmlDocument sessionXml) {
            throw new NotImplementedException();
        }

        public bool ShowConfigurationSettings(System.Windows.Forms.IWin32Window parentWindow, System.Xml.XmlDocument sessionXml, System.Xml.XmlDocument persistXml, IPublishProperties publishProperties) {
            if(!WriterApplication.IsInstalled){
                System.Windows.Forms.MessageBox.Show(parentWindow, "Windows Live Writer is not Installed.", "BlogThis Plugin",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            else{
                blogThis(parentWindow, sessionXml);
            }
            return false;
        }

        private void blogThis(System.Windows.Forms.IWin32Window parentWindow, System.Xml.XmlDocument sessionXml) {
                XmlNodeList items = sessionXml.SelectNodes("/PhotoGalleryPublishSession/ItemSet/Item[PerceivedType="image"]/FullFilePath");
            if(items.Count==0){
                System.Windows.Forms.MessageBox.Show(parentWindow, "Please select at least one image.", "BlogThis Plugin",
                    System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                return;
            }
            string[] fileNames = new string[items.Count];
                for (int i = 0; i &lt; items.Count; i++) {
                    fileNames[i] = items[i].InnerText;
                }
                WriterApplication writer = new WriterApplication();
                writer.BlogThisImageFileList(null, fileNames, null);            

        }
    }
}</pre>
</div>
<p>うわぁNotImplementedExceptionばっか。。。BlogThisPluginでは、最初に呼び出されるShowConfigurationSettingsメソッドの段階でfalseを返してしまうことにしました。これは、写真のアップロードを直接するわけではないため、Live Photo Galleryの挟みこんでくるダイアログが邪魔だったからです。まぁ、こういうのもありかもね、ということで。そのうちにPublishing Plug-inのアーキテクチャに沿ってWordPressにXMLRPC-APIを使って画像やらを投稿するプラグインも試作してみたいと思います。</p>
<p>ちなみにソリューション全体はこちらにアップしています。<br />
  <br /><a href="http://depot.sharplab.net/CSharp/WLWPlugin/BlogThisPluginSln.zip">http://depot.sharplab.net/CSharp/WLWPlugin/BlogThisPluginSln.zip</a> </p>
<p>真っ当に実装された<a href="http://msdn.microsoft.com/en-us/library/cc967071.aspx">MS謹製のFlickerのプラグイン</a>より簡単に弄れるたたき台としてどうぞ。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharplab.net/blog/2008/09/23/1131/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BlogThisPlugin</title>
		<link>http://blog.sharplab.net/blog/2008/09/23/1128/</link>
		<comments>http://blog.sharplab.net/blog/2008/09/23/1128/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 07:59:43 +0000</pubDate>
		<dc:creator>shiroica</dc:creator>
				<category><![CDATA[BlogThisPlugin]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Windows Live Writer]]></category>

		<guid isPermaLink="false">http://blog.sharplab.net/computer/cprograming/windowslivewriter/blogthisplugin/1128/</guid>
		<description><![CDATA[What&#8217;s this? This is a simple plugin that adds “BlogThis” menu to Windows Live Photo Gallery. You can click this menu and launch Windows Live Writer with a new BlogThis post that contains selected images. Download BlogThisPluginSetup.zip System Requirements Microsoft Windows XP SP2 or later, or Windows Vista Minimum 512 MB of RAM (based on [...]]]></description>
			<content:encoded><![CDATA[<h3>What&#8217;s this?</h3>
<p><a href="http://blog.sharplab.net/wp-content/uploads/2008/09/image8.png" rel="lightbox"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" border="0" alt="image" align="right" src="http://blog.sharplab.net/wp-content/uploads/2008/09/image-thumb8.png" width="244" height="201" /></a>This is a simple plugin that adds “BlogThis” menu to Windows Live Photo Gallery. You can click this menu and launch Windows Live Writer with a new BlogThis post that contains selected images.</p>
<h3>Download</h3>
<p><a href="http://depot.sharplab.net/CSharp/WLWPlugin/BlogThisPluginSetup.zip">BlogThisPluginSetup.zip</a></p>
<h3>System Requirements</h3>
<ul>
<li>Microsoft Windows XP SP2 or later, or Windows Vista </li>
<li>Minimum 512 MB of RAM (based on the profile of Windows Live Photo Gallery) </li>
<li>Microsoft .NET Framework 2.0 or higher </li>
<li>Latest version of Windows Live Photo Gallery </li>
<li>Latest version of Windows Live Writer </li>
</ul>
<h3><a href="http://blog.sharplab.net/wp-content/uploads/2008/09/image9.png" rel="lightbox"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" border="0" alt="image" align="right" src="http://blog.sharplab.net/wp-content/uploads/2008/09/image-thumb9.png" width="244" height="222" /></a>How to install</h3>
<p>Please unzip BlogThisPluginSetup.zip, and execute setup.exe.</p>
<h3>How to uninstall</h3>
<p>Please uninstall by “Add or Remove Programs” utility in the Control Panel.</p>
<h3>Releases</h3>
<p>2008-09-23 Initial version released.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sharplab.net/blog/2008/09/23/1128/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

