CH3COOH(酢酸)のさくっと393

VB.NET(VS2003)でお仕事中.Windows Mobile大好きです。

ホーム 連絡をする 同期する ( RSS 2.0 ) Login
投稿数  413  : 記事  0  : コメント  7803  : トラックバック  93

ニュース

CH3COOH(酢酸)の実験室 or SOFTBUILD

書庫

日記カテゴリ

amazonの商品へのリンクを貼るのが面倒だなぁ……
と思ったので、Windows Live Writerのプラグインの作成に挑戦してみました。

 

すぐに手順を忘れてしまいそうなので、ざっくりと書き残しておきます。

  1. クラスライブラリのプロジェクトを新規作成
  2. Windows Live Writerをインストールしたフォルダ(僕の場合C:\Program Files\Windows Live\Writerでした)にある、WindowsLive.Writer.Api.dllを参照させる。
  3. Class1にContentSourceを継承させる
  4. CreateContent()をオーバーライド
  5. string contentへhtml文を挿入する。
  6. ビルドして出来たアセンブリを、Windows Live Writerをインストールしたフォルダの直下にあるPluginsフォルダ(僕の場合C:\Program Files\Windows Live\Writer\Pluginsでした)へコピーする。

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using WindowsLive.Writer.Api;

namespace amazonInsert
{
    [WriterPlugin("{63491BAF-A37A-4167-AEE7-E261CF453F83}", "amazonリンク")]
    [InsertableContentSource("amazonリンク")]
    public class Class1 : ContentSource 
    {
        public override System.Windows.Forms.DialogResult CreateContent(System.Windows.Forms.IWin32Window dialogOwner, ref string content)
        {
            //フォームを表示してASINを入力させる
            Form1 form = new Form1();
            DialogResult dr = form.ShowDialog();

            if (dr == DialogResult.OK)
            {
                string asin = form.asin;
                string id = "sakunekonikki-22";
                string text = "";

                //てきとーにhtml文をこしらえる
                text += "<";
                text += "iframe src=\"http://rcm-jp.amazon.co.jp/e/cm?t=";
                text += id;
                text += "&o=9&p=8&l=as1&asins=";
                text += asin;
                text += "&fc1=000000&IS2=1<1=_blank&";
                text += "lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr\"";
                text += "style=\"width:120px;height:240px;\" ";
                text += "scrolling=\"no\" marginwidth=\"0\" ";
                text += "marginheight=\"0\" frameborder=\"0\">";
                text += "<";
                text += "/iframe>";

                content = text;
            }

            form.Dispose();

            return dr;
        }
    }
}

自分の作成したプラグインがちゃんと表示されて

20080104_01

選択するとASIN入力フォームが表示されて、

20080104_02

ASINを入力してOKを押すと、商品がちゃんと表示される。

20080104_03

僕でも簡単にプラグインを作ることが出来ましたヽ(゚∀゚)メ(゚∀゚)メ(゚∀゚)ノ


投稿日時 : 2008年1月4日 16:55

コメント

# re: [C#]Windows Live Writerのプラグインを作ってみた 2008/01/05 23:33 けろ-みお
おもしろそうですね。そのまま頂こうかしらw
強いて言うならば、textは、Stringじゃなくて、StringBuliderで
AppendかAppendFormatさせて欲しかったです・・・

# re: [C#]Windows Live Writerのプラグインを作ってみた 2008/01/06 1:24 CH3COOH(酢酸)
>強いて言うならば、textは、Stringじゃなくて、StringBuliderで
>AppendかAppendFormatさせて欲しかったです・・・

おぉ?StringBuliderなんてのがあるのですね。
調べてみたら文字列の連結を高速に出来るとか。

これからはStringBuliderも使っていきたいと思います('∀`)

# ???????????? WordPress HTML????????????????????????(1) | i-soft ???????????? 2012/07/08 5:09 Pingback/TrackBack
???????????? WordPress HTML????????????????????????(1) | i-soft ????????????

Post Feedback

タイトル
名前
Url:
コメント