Writing Plugins For Windows Live Writer – Working With Forms

Most plugins for Live Writer will have a form appear when you click on the Insert link within Live Writer, this form will perform the functionality of the plugin and return the code or text that will be put in the blog entry. Within this form, you can do whatever you want the plugin to do, but for this example I will be keeping it simple and showing the basics, letting you code the rest of the plugin and change whatever settings for your form that you want.

Open up your project (I will be continuing with the "MyNewPlugin" example from the previous posts), and create a new form in your project (for this example I will be calling the form frmMyForm). For this example, my form will have only a text box, an insert button and a cancel button, and all it will do is allow the user to enter some text and have it appear in the blog entry when you press insert. In your form, add a textbox and two buttons (I have also added a label to describe what the textbox does), you should have something like this:

Any other properties of this form can be changed as you wish. Except for the textbox which I have called txbxText, I have kept all the original names that get given when the form items are created.

Now we need to tell the buttons what they are going to be done. We’ll start with the cancel button; in the properties of the form, there is a property called CancelButton, just set that to be the cancel button (in this case Button2). For the Insert button, double click it and Visual Studio will create the method for you, we can then add our code into that method. Before we do this though, at the top of the Class (before the initializing method), we need to declare a string variable, so just put in string text;.

In this plugin, all we need to do for the Insert button is assign the DialogResult value, set the text and close the form. So the code we need to put in is:

            DialogResult = DialogResult.OK;
text = txbxText.Text;
this.Close();

Note how we are assigning the text string to equal the text from the textbox. The last thing we need to do for this plugin is just create a string method that returns the text string, this will be called later from the main plugin class.

        public string getText
{
get { return text; }
}

Now, in the main class where we overrode the CreateContent method, we need to add in a new section, so before we had just newContent = "Some text"; we now need to tell the plugin that we want to use our new form:

using (frmMyForm form = new frmMyForm())
{

Now, you might remember in the last post that I mentioned about the DialogResult section (and I also touch upon it above), this is where it actually comes in to play. Once we have told the plugin to use the form, we need to create a new DialogResult that opens up our newly called form, so we insert the next line:

                DialogResult result = form.ShowDialog();

In the form when we click on the Insert button, we set the DialogResult to equal DialogResult.OK, this signifies that an OK was pressed in a dialog, so we can check for this by using an if statement. Within that if statement, we are going to set the newContent value to equal the getText string from the form:

                if (result == DialogResult.OK)
{
newContent = "You entered: " + form.getText + ".";
}

We now need to close off all open sections (using a } ) . Hopefully you can see where everything falls into place, form.getText is the public string that we set to return the text string in the form, and the text string gets the value of the textbox, which is what finally gets inserted into the blog entry.

Any questions about this post please feel free to leave a comment, as this one is a little more involved that the previous two steps.

Download Source Code: here.

SL

<< Previous – Adding an Icon

Advertisements
  1. #1 by Unknown on January 21, 2008 - 3:41 pm

    wow gold wow gold wow power leveling wow power leveling wow powerleveling wow powerleveling wow power leveling wow gold wow gold World of Warcraft Gold rolex replica wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling power leveling power leveling power leveling rolex rolex power leveling power leveling power leveling wow powerleveling wow powerleveling wow powerleveling wow powerleveling wow powerleveling wow powerleveling powerleveling powerleveling powerleveling wow gold powerleveling powerleveling powerleveling World of Warcraft Gold World of Warcraft Gold World of Warcraft Gold World of Warcraft Gold World of Warcraft Gold rolex replica Warcraft Gold Warcraft Gold Gold wow Gold wow Gold wow Gold wow Warcraft Gold Warcraft Gold 货架 机票 灭蟑螂 租房 租房 北京租房 北京租房 搬家公司 北京搬家 北京搬家公司 上海机票 上海机票 上海打折机票 上海打折机票 上海特价机票 上海特价机票 搬家公司 搬家公司 北京搬家公司 北京搬家公司 中高年 転職 アルバイト 求人情報 ブライダル 転職 競馬 FX ダイエット お見合い 競馬 予想 新築マンション 新築マンション コンタクトレンズ 婚約指輪 合宿免許 人材派遣 東京都 墓地 派遣会社 人材派遣 パチンコ 攻略 おなら xgchvmbm

  2. #2 by Unknown on April 8, 2008 - 4:33 am

    welcome to visit RF online blog Mmo blog Mmo guide blog Internet game guideTales of pirates forum ,it will give your some help.EVE online isk cheap EVE isk Guild wars gold Guild wars money GW gold Rs Money Wow gold Wow World of warcraft Gold Wow eu gold Wow us gold Maplestory mesos WOW GOLD worlf of warcrraft  World of warcraft gold Runescape RS gold RF online RF online cp RF online dalant  RF online disena  RF online money RF online gold Lotro gold Buy lotro gold  WOW gold  Cheap wow gold on sale. and you can sell your gold to us.

  3. #3 by on April 15, 2008 - 9:03 am

    wow gold!All US Server 29.99$/1000G on sell! wow gold,WOW Power Leveling-We supply the cheapest WOW PowerLeveling Service Online,with cheapest price and fastest of World Of Warcraft Gold and World Of Warcraft Power Leveling when purchaseing Honor Points/Professions Skills/Rep/World Of Warcraft PowerLeveling.
    Alcohol Tester purchasing center is a professional enterprise Breathalyser,Breathalyzer specializes in breath Gas Alarm consulting,Gas Detector through internet.Co Detector,Co Alarm always have been designed to alarm.
    数据恢复公司是北京市最大的仓储式弹簧销售企业,经销各种不锈钢弹簧。济南市龙威液压机械有限公司是专业生产液压升降机,是国内领先的升降机及升降平台的生产厂家。

  4. #4 by Unknown on April 26, 2008 - 10:37 am

    wow gold cheap wow gold buy wow gold world of warcraft gold wow world of warcraft wow gold WoW Warrior WoW Hunter WoW Rogue WoW Paladin WoW Shaman WoW Priest WoW Mage WoW Druid WoW Warlock maple story maple story mesos maplestory mesos maplestory maple story mesos maple story cheats maple story hacks maple story guides maple story items lotro lotro gold buy lotro gold lotro cheats lotro guides power leveling powerleveling wow power leveling wow powerleveling google排名 google左侧排名 google排名服务 百度推广 百度排名 wow guides wow tips 商业吧 网站推广 福州热线 体育博客 股票博客 游戏博客 魔兽博客 考试博客 汽车博客 房产博客 电脑博客 powerlin518 logo design website design web design 商标设计 办理上网文凭 高考答案 窃听器 手机窃听器

  5. #5 by Unknown on May 6, 2008 - 12:50 pm

    キャッシング 比較
    銀行系キャッシング
    融資シミュレータ
    消費者金融 審査
    キャッシング比較
    信販系キャッシング
    ローン
    即日融資
    消費者金融
    レディースローン
    融資
    学生ローン
    即日融資
    おまとめローン
    キャッシング ローン
    低金利キャッシング
    キャッシング 申込
    一本化
    即日 キャッシング
    大口 融資
    低金利 キャッシング
    高額 融資
    低金利 ローン
    大口 ローン
    おまとめローン
    消費者 金融 審査 甘い
    カード キャッシング
    主婦 キャッシング
    ネット キャッシング

  6. #6 by Unknown on May 19, 2008 - 6:06 am

    欢迎到访雪矢的观雪轩
    个人原创文学
    诗词歌赋
    观海赋
    蝴蝶飞
    尘埃
    夕阳怀歌
    系列连载
    和那颗星星有个约会
    散文杂感
    偶然心动 -30032982571168

  7. #7 by Unknown on July 14, 2008 - 12:10 am

    主婦 キャッシング 銀行系 キャッシング キャッシング 即日融資 女性専用 キャッシング 一本化 ローン 一本化 借金 一本化 まとめ 一本化 銀行 おまとめローン カードローン 審査 ローン 借り換え 銀行系 カードローン レディースローン カードローン 低金利 即日融資 大口融資 高額融資 消費者金融 即日融資

  8. #8 by on August 7, 2008 - 6:51 am

    それは人材紹介ランキング使おう。人財派遣も同じく人材派遣ランキングを使おうね。
    トルコリラ比較もね
    fx比較の投資は外為比較によって大きく左右される投資家ならまだしもfx初心者は一番存。トルコリラもよいしね

  9. #9 by Unknown on October 31, 2008 - 9:11 am

    Genuine TOSHIBA PA3465U-1BRS Laptop Battery PABAS069 laptop battery
    Battery for Toshiba PA3399U-1BRS PA3399U-2BAS 1BAS laptop battery
    6.6ah Battery for Toshiba B491 PA3166U laptop battery
    Battery For PA3383 TOSHIBA Satellite PA3383U-1BRS 12cells laptop battery

    Battery Fit Toshiba PA3382U-1BRS PA3384U-1BRS laptop battery
    6.6ah Battery Fit Toshiba PA3382U-1BRS PA3384U-1BRS laptop battery
    Toshiba PA3356U-3BAS PA3356U-3BRS PA3456U-1BRS Battery laptop battery
    Battery For Toshiba Portege M200 M205 PA3128U PA3191U black laptop battery
    Battery For Toshiba Portege M200 M205 PA3128U PA3191U white laptop battery

  10. #10 by Unknown on November 7, 2008 - 4:03 am

    dell inspiron 6000 battery
    dell inspiron 9200 battery
    dell inspiron 9300 battery
    dell inspiron 9400 battery
    dell inspiron e1705 battery

    dell latitude d810 battery
    dell precision m70 battery
    dell y4367 battery
    dell latitude d410 battery
    dell w6617 battery
    dell y6142 battery
    dell inspiron 300m battery
    dell latitude x300 battery
    dell inspiron 1300 battery

    dell inspiron b120 battery
    dell inspiron b130 battery
    dell xd187 battery
    dell inspiron 1501 battery
    dell inspiron e1505 battery
    dell inspiron 6400 battery
    dell latitude 131l battery
    dell inspiron 630m battery
    dell inspiron 640m battery

    dell inspiron e1405 battery
    dell xps m140 battery
    dell latitude d620 battery
    dell latitude d820 battery
    dell latitude d420 battery
    dell latitude d430 battery
    dell xps m1210 battery
    dell inspiron 1420 battery
    dell vostro 1400 battery

    dell inspiron 1520 battery
    dell inspiron 1720 battery
    dell vostro 1500 battery
    dell vostro 1700 battery
    dell latitude d620 battery
    dell inspiron 1000 battery
    dell inspiron 1200 battery
    dell inspiron 2200 battery
    dell latitude x200 battery

    dell 6000 battery
    dell 9200 battery
    dell 9300 battery
    dell 9400 battery
    dell e1705 battery
    dell latitude x1 battery
    dell t6840 battery
    dell 7012p battery
    dell latitude cs battery

    dell latitude csx battery
    dell latitude csx battery
    gateway s62044l battery
    gateway 4000 battery
    gateway m320 battery
    gateway m325 battery
    gateway m360 battery
    gateway m460 battery
    gateway m680 battery

    hp f2024a battery
    hp f2024b battery
    hp pavilion 5000 battery
    hp n3000 battery
    hp n3490 battery
    hp f1739a battery
    hp f1739b battery
    hp omnibook xe battery
    hp omnibook xe2 battery

    hp hstnn-db02 battery
    hp hstnn-db03 battery
    hp hstnn-ib04 battery
    hp presario r3000 battery

  11. #11 by Unknown on November 19, 2008 - 12:39 pm

    探偵 調査

    素行調査

    身辺調査

    妻浮気

    悩み相談

    探偵紹介

    探偵事務所

    行動調査

    追跡調査

    結婚式

    電話占い

    性生活

    オナホール

    TENGA

    バイブ

    コスチューム

    大人のおもちゃ

    アダルトグッズ

    アダルトグッズ

    FX

    アダルトグッズ

    オナホール

    エアコン 東京

    ガーデンファニチャー

    システムキッチン

    洗面化粧台

    洗面台

    オーガニックアロマ

    翻訳会社

    大人のおもちゃ

    アダルトショップ 

    エネマグラ

    オナホール 

    仮性包茎

    アナル

    電マ

  12. #12 by Unknown on November 19, 2008 - 12:39 pm

    ダッチワイフ

    まつげエクステ

    アダルトグッズ

    英会話 教材

    競馬

    フラワーアレンジ

    ブリザーブドフラワー

    バラ

    供花

    誕生花

    誕生日プレゼント 花

    北欧家具

    エッセンシャルオイル

    ブライダルエステ 代官山

    大人のおもちゃ通販

    結婚式

    結婚式準備

    結婚式の髪型

    ウェディングドレス

    アダルト サンプル 動画

    アダルト
    ダウンロード

    熟女
    アダルト

    巨乳
    アダルト

    素人
    アダルト

    ニューハーフ
    アダルト

    FX ランキング

    FX 比較

    キャッシング 申込

    債務整理

  13. #13 by Henry on August 18, 2009 - 12:50 am

    good job

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: