Creating a Windows Live Writer Plug-in using C# Part 2

First we will start off with the Plug-in class that inherits from ContentSource.  Please note from Part 1 that “InsertForm” is a class we will create.


   1: using System;

   2: using System.Collections.Generic;

   3: using System.Linq;

   4: using System.Text;

   5: using WindowsLive.Writer.Api;

   6: using System.Windows.Forms;


   8: namespace AmazonQuickLinkPlugin

   9: {

  10:     [WriterPlugin(

  11:         "93DD80D7-9327-4375-A9D8-777C0549C1C8", 

  12:         "Amazon Quick Link", 

  13:         PublisherUrl="",

  14:         Description="Creates a Amazon Quick Link url",

  15:         ImagePath="Images.Shazam.png")]


  17:     [InsertableContentSource("Amazon Quick Link")]

  18:     public class Plugin : ContentSource

  19:     {

  20:         public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)

  21:         {

  22:             using (InsertForm form = new InsertForm())

  23:             {

  24:                 DialogResult result = form.ShowDialog();

  25:                 if (result == DialogResult.OK)

  26:                     content = form.Link;


  28:                 return result;

  29:             }


  31:         }

  32:     }

  33: }

Now that we have the basics lets create the “InsertForm” form.  First a capture of what I made it look like and then the code.


   1: using System;

   2: using System.Collections.Generic;

   3: using System.ComponentModel;

   4: using System.Data;

   5: using System.Drawing;

   6: using System.Linq;

   7: using System.Text;

   8: using System.Windows.Forms;


  10: namespace AmazonQuickLinkPlugin

  11: {

  12:     public partial class InsertForm : Form

  13:     {

  14:         public string ASIN { get; set; }

  15:         public string Category { get; set; }

  16:         public string SearchTerm { get; set; }

  17:         public string InnerText { get; set; }

  18:         public string Link { get; set; }


  20:         public InsertForm()

  21:         {

  22:             InitializeComponent();

  23:         }


  25:         private void btnOK_Click(object sender, EventArgs e)

  26:         {

  27:             AssignProperties();

  28:             this.Link = CreateAmazonQuickLink();

  29:             this.DialogResult = DialogResult.OK;

  30:             Close();

  31:         }


  33:         private void btnCancel_Click(object sender, EventArgs e)

  34:         {

  35:             this.DialogResult = DialogResult.Cancel;

  36:             Close();

  37:         }


  39:         private void AssignProperties()

  40:         {

  41:             //TODO: Add validation of ASIN format

  42:             this.ASIN = txtASIN.Text.Trim();

  43:             //TODO: Get categories from Amazon

  44:             this.Category = txtCategory.Text.Trim();

  45:             this.SearchTerm = txtSearchTerm.Text.Trim();

  46:             this.InnerText = txtInnerText.Text.Trim();

  47:         }


  49:         private void btnPreview_Click(object sender, EventArgs e)

  50:         {

  51:             AssignProperties();

  52:             txtPreview.Text = CreateAmazonQuickLink();

  53:         }


  55:         private string CreateAmazonQuickLink()

  56:         {

  57:             StringBuilder s = new StringBuilder();

  58:             s.Append("<a type=\"amzn\" ");


  60:             if (ASIN != string.Empty)

  61:                 s.Append("asin=\"").Append(ASIN).Append("\" ");

  62:             else

  63:             {

  64:                 if (SearchTerm != string.Empty)

  65:                 {

  66:                     s.Append("search=\"").Append(SearchTerm).Append("\"");

  67:                     if (Category != string.Empty)

  68:                         s.Append("category=\"").Append(Category).Append("\"");

  69:                 }

  70:                 else

  71:                     return string.Empty;

  72:             }


  74:             s.Append(">").Append(InnerText).Append("</a>");


  76:             return s.ToString();

  77:         }


  79:     }

  80: }

I’ve added a few TODO’s but for the most part it is done and works great.  One other thing I might note.  I never did get the XCOPY command they give you in the documentation to work after the first compile.  I had to keep deleting the DLL I created in the WindowsLive Writer plug-in directory.

Here is the Amazon Quick Linker plug-in in action.  Let me recommend one of my favorite books on estimation.  Steve McConnell just knows how to put it in a way I understand.  When I read his book Software Estimation: Demystifying the Black Art (Best Practices (Microsoft)) it really opened my eyes and made my programming more enjoyable.  I hope it will do the same for you.

Creating a Windows Live Writer Plug-in using C# Part 1

There are a few example out there already for ContentSource but after trying to use them I found some glaring omissions.  For instance, two of the examples I looked at use InsertForm.  I just assumed that because we were using the namespace System.Windows.Forms that is where it was coming from.  Because the example were in the 2.0 Framework I thought maybe I was just missing some thing.  So when I got the error “The type or namespace name ‘InsertForm’ could not be found (are you missing a using directive or an assembly reference?)” I assumed it was just a matter of finding the reference I needed.  It was!  But to a class I should and would create.  I also had a hard time with the ImagePath property of the WriterPlugin attribute.  For starters the png file must be 16×16 despite what the documentation says, 20×18 didn’t work.  Also don’t forget to set the Build Action property on the image to Embedded Resource.  Its a minor detail that the documentation has but the examples leave out.  Please don’t go looking for a SDK to download despite what is said in the other example.  The WindowsLive.Writer.Api is in the root directory of WindowsLive Writer.

To Summarize:

  1. Your project will need a Windows Form Class added (Name if “InsertForm.cs” just for the fun of it)
  2. Make sure your image is 16×16.
  3. Make sure you set the Build Action on the image to Embedded Resource.
  4. The WindowsLive.Writer.Api file is found in C:\Program Files\Windows Live\Writer
  5. WindowsLive Writer SDK Documents

In Part 2 of this post I will share the plug-in I create and use it in the post.

Pre-Planning – A Key to a Successful Trade

You should always get a game plan in place before making a trade.  Getting caught on a emotional roller coaster is a sure way to end up penniless.

Points to Know:

  • What is my maximum risk?
  • What is my maximum reward?
  • What is my break even point?

Make a plan:

  • What is my entry point?
  • What is my exit point . . .
    • For taking profit or
    • For stopping losses.

The most important part of your plan is to make a good plan and stick to it!  Don’t let greed or fear over come you.  It isn’t easy.  I know.  If you go outside the plan you will wish you hadn’t later.  Remind yourself of that when the going gets tough.  In the end you will thank your self, feel a sense of accomplishment, and control if you stick with it.

Attributes of a Successful Investor and Trader – Perseverance

When I say perseverance I’m not saying keep throwing your money away until you get it right.  I’m saying persevere in your obtaining skills, knowledge, and technique.  In short development toward a successful trader and investor.  Warren Buffet didn’t make his billions over night.  We all know it yet the get-rich-quick schemes are as prevalent as ever.  Knowing how to persevere is a attribute that you can use in more then financial skill matters.  It is something most of us already have to some degree.  The key is to strengthen it and nature it when it come to combating our biggest weakness, “The Quick Fix”.  Greed is another name for it in the trading world.  We want the win now without doing the work to get it.  Persevere in your development and you will become a success.    

Jumping for Jiu-Jitsu – Jump Roping to Increase Stamina

What can I do to increase my wind or stamina in my Brazilian Jiu-Jitsu class?  This is a goal of mine that has been plaguing me.  Two things I might note right off.  Do not tie your belt tight.  Keep it lose and down toward your hips.  Second don’t tie your pants tight.  I noticed that both seem to constrict my breathing while rolling.  I’ve decided to try jump roping to see if that will give me more aerobic exercise and increase my wind.  I purchased a Harbinger 331600 9-Foot Beaded Jump Rope.  It wasn’t expensive.  The plan is to just take a few breaks during the day and jump.  I also understand that jumping helps increase your bone density.  Who knows it might also increase my vertical leap for basketball.

I have started with 10 minute jumps.  That gets my heart rate up in no time and is a nice break from work.  Yes, I get a few stares and yes, I skip like a school girl right now but in time I’ll have the rhythm and look like Muhammad Ali preparing for the next fight or Rocky going for the championship.

Jump roping teaches timing and timing is a essential part of Jiu-Jitsu.  It can mean the difference between a successfully executed escapes or submissions.


Ginastica Natural – Jiu-Jitsu and Yoga

How do I improve my muscle memory, stamina, and strength for Brazilian Jiu-Jitsu?  I’m not a little guy at 214 lb but that puts me in the lower end of the heavy weight division.  I end up with the 275 lb guys.  I need a way to speed up my learning while increasing my body strength.  I hate doing what I call mindless aerobics or movement for movements sake.  I want something from it even if it means peddling a stationary bike that produces electricity.  Because I don’t always have some one to do BJJ with I have started looking into Ginastica.  Here is a video of it on YouTube: Ginastica Natural in Action.  It combines Jiu-Jitsu moves with Yoga and claims to help in the three categories I want to improve.  I just ordered it from  I will let you know how it works out for me.  I am hoping it will help me also reach my goal weight of 200 lb (10 more pounds then what I weighted in High School).

Attributes of a Successful Investor and Trader – Patience

What are the attributes, qualities, or criteria for becoming a successful investor and trader?  There is a famous quote from the book “Reminiscences of a Stock Operator” that says “Patience, Self-discipline, and mind-set of detachment” make a good trader.  I am also reading a book called “Options Make Easy” it lists “patience, perseverance, knowledge, honesty, pre-planning, and discipline” as the criteria for successful investing.  I will do a post on each.

Patience – Money and the thought of making large amounts of money causes people to become excited.  When you are excited your judgment becomes flawed.  Lean to be patience in your pursuit of wealth.  I would liken it to a fighter pilot in a dogfight.  Plan your attack, stick to your plan, wait until the target it in your sights before firing.

Patience pays off.  Don’t expect to be a millionaire over night.  Consider compounding profits.  Each good trade or investment gives you a return which you can use to compound your wealth.  A steady 1% return a week will compound to be 67% in 1 years.   Let your profit accumulate and be happy with little wins.  Over time the big ones will come but first learn to walk before you try to run.

eBay Google Base Data Feed – How to Configure and Setup

I wanted to create a Google Base feed for my eBay store.  Sounds simple doesn’t it.  It wasn’t for me so I’m going to share how I did it.

  1. In your eBay account go to Marketing Tools.  This is on the left side about mid way down.
  2. Pick the “Make a file of your Store inventory listings available” and click apply.   Note the URL supplied here.  You will use it in setting up your data feed.
  3. Go to Google Base and Register a Google-base xml data feed file with the name: yourstorename.xml
  4. Click on the "Settings" tab;
  5. Under "Website URL (Optional)", replace the existing URL with your store’s XML link generated by eBay.
  6. Click the "Data feeds" link on your "My Items" tab;
  7. Edit your "schedule" beside your "data feed";
  8. Under "URL of file," replace the existing URL with the eBay generated link.  Click "Update Schedule" to confirm your changes;

This should do it.  It won’t happen all at once.  Google Base takes some time to process the file and it won’t get it until your scheduled time.  You can test it all out with a manual upload.

  1. Right click on the eBay generated URL in your eBay account and choose “Save link as”.  It will give you the file to save.
  2. Choose the “Manual: File Upload” that was below the “Schedule”.  Pick where you downloaded the file to and it will be uploaded.

Wait a while and see if it processed.

Amazon Categories or Search Index Matrix

How do I find the Amazon categories or Search Index Matrix?  That was a real devil of a question to solve!  I didn’t find any helpful links, only dead ends.  On top of it all I had no idea they were called Search Indexes.  Lets not also leave out the fact that they vary depending on locations in the world.  Here is where I found them: Search Index and ItemSearch Parameter CombinationsYou will need to expand the tree “API Reference” –> “Search Index and ItemSearch Parameter Combinations” .  Does anyone reading this most not have to retrieve them programmatically?

My Knee Injury and the Road to Recovery

I tore my MCL (Medial Collateral Ligament) on my left knee on March 9, 2009 while practicing take-downs at my Brazilian Jiu-Jitsu class.  It was the Monday night class.  We had done our warm-ups and had just got started.  This wasn’t the first time this had happened to me.  About 7 years ago I tore something in the same knee far worse while playing indoor soccer.  I had a good idea of what to start doing right off.

  1. Rest
  2. Ice
  3. Elevation
  4. Compression

R.I.C.E is the acronym and it has helped me remember it throughout the years.  I think my first aid has made all the difference in my recovery time.  I started by stacking pillows up to put my leg on, wrapping the knee with a ACE Bandage and putting ice on it.  I also took some ibuprofen for the pain and to help get the swelling down.  After about 3 days the swelling went down.  I was on my back nearly the whole time.

It has been a month this Monday since the knee injury.  I can walk but my knee doesn’t want to bend beyond 90 degrees.  If I leave my knee bent or straight for too long it is hard to get it out of that position.  It is as if there is fluid in the knee and it needs time to push it to some other location.  Last night my left leg was stiff from lack of use and I flexed it in my sleep.  Oh, mama!  That hurt.  This morning my wife suggested I lay on my back and do a peddling motion.  It worked great!  The peddling motion got a nice burn in my leg muscles and I was even able to get my knee to bend beyond 90 degrees.  I’m going to do it throughout the day to help increase my flexibility and exercise the muscles without causing greater injury.

I have purchased a book to help me called Treat Your Own Knees – Simple exercises to build strength, flexibility, responsiveness, and endurance.  I will let you know how it helps in my recovery.