I thought it might be fun to convert an old VFP app. I wrote when I was playing around with web services inside of VFP to work inside of Visual Studio. It was a simple program which connected to a webservice which serves up a new Dilbert comic every day, then it displays it in the VFP desktop. I've been thinking about doing it for a while - my initial thought was to modify and/or customize the RSS feed which Visual Studio uses to display it's latest news. Unfortunately, I couldn't figure out how to get it to display images - it seems to reformat the feed and strip out any of the markup. A bunch of googling didn't turn up much either.
I briefly looked at the Visual Studio SDK a while back but the licensing cost was prohibitive (something like $10K). I could use it for development and on my machine, but I wouldn't be able to distribute it w/o the license. However, Microsoft just recently changed all of that with the latest release; ran across this via Code Magazine's Focus issue on Visual Studio Extensibility. You can download the magazine for free from: http://www.code-magazine.com/focus/Index.aspx. I downloaded the SDK and got it installed with VS 2007 Beta 2 (yeah, yeah, VS 2008 was just released). Then I kind of lost momentum and didn't do much with it.
This morning, while I had a bit of dead-zone time (that's the time between interruptions that you KNOW are going to occur on some days, and they're going to be spaced so close together that it's not worth getting involved in anything too mentally strenuous). I ran Visual Studio Integration Package wizard and had a stub project up in running in a few minutes (I picked the "Tool Window" option). It creates a MyControl.cs form with a button on it, so I just deleted the button and added a PictureBox in it's place.
Then I just did almost a straight port of my VFP code which checks to see if it's already downloaded the comic (and if so, it checks the dates to see if a newer one should be available). If necessary, it downloads the file and dumps it into the PictureBox. They've set things up so you can just "run" this project and it will automatically start up a new instance of VS to test in, which is really nice. If you've never used a web service in VS, it's really simple - add a reference, enter the address of the web service and it builds a nice simple wrapper class for you. I guess I could have done this via WCF, but I really didn't want to complicate things.
My first test seemed OK - I selected View > Other Windows and picked my new Dilbert A Day option. The toolbar window appeared with the latest comic - so far, so good. It docks like any other VS tool, so I docked it to the bottom of the screen. I closed my debugging instance of VS and restarted it to see if it still worked. Nope. No image. I ended up having to move the code which downloaded the new comic out of the control and into the class which instanciates the form (MyToolWindow.cs). Once I had that working, I decided it really needed to have a custom Dilbert icon. I snagged an image from the Dilbert site, cropped it and resized it down to 16x16. There are two resources embedded in the project which include a strip of icons. I was lazy, so I just replaced the second icon (which seems to be the default selected inside of the pre-generated code) in both of the BMP files.
Here's what it ended up looking like docked at the bottom of VS:
Here's it expanded:
And the new menu option:
I'm pretty happy with how this came out - this took me literally 20 minutes to put together. Granted, this is hardly a taxing application - I could easily be swearing at the SDK if the example were any more complex. But they at least did a nice job to help get you up and running pretty quickly.
OK, I admit it, this post is a bit of a tease. I had hoped to get this posted as a installable component w/source tonight. I figured I could get the installer working (ideally as a "ClickOnce" app, since this gives me an excuse to play with that, although I'm not even sure it can be deployed this way) relatively quickly. However, once I started looking at what was necessary for deployment I came across the fact that I need to get some sort of Package Load Key (PLK) from Microsoft, which requires me to sign up for the Microsoft Visual Studio Industry Partner Program website. That's actually pretty painless, and it looks like they've got a simple interface to request this key:
At that point, it wants me to answer a bunch of questions about the download location, product logo, etc. that I wasn't really ready to deal with. The final deployment aspect of all of this also seemed to be missing in the docs I've read. I ended up having to do some more digging through the Code Focus issue and came across this link which has a video which covers deployment (yeah!). I'll have to watch the full video (it's around 20 minutes) before I can finish this thing up.
I'll follow up with that in another post, along with a bit of code from the project and maybe a simple comparison of the VFP code vs the .NET code. I guess I'll also have to put up a downloads section to make it easier to find all of this stuff, especially if I need to provide all of that to generate a PLK. Let's hope this 20 minute quickie project doesn't turn into some huge odyssey - unfortunately, that seems to happen a lot in development, doesn't it?
Links:
http://www.code-magazine.com/focus/Index.aspx http://msdn2.microsoft.com/en-us/vstudio/aa700819.aspxhttp://www.vsipmembers.com/http://msdn2.microsoft.com/en-us/vstudio/aa700829.aspx
Remember Me
a@href@title, b, i, strike