|
|||||||||||||||||||||||||
|
|||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
![]() IntroductionAt SlickEdit, we've put several "advertorials" out now on The Code Project about our Tools for Visual Studio product. I'm one of the developers on the Tools team [profile], and I love The Code Project for learning how to do new things, especially because I learn best by seeing examples of how something's done. However, in order to see the sample code for an article, you have to:
I also love convenience, and that's why I made this add-in. It lets you browse The Code Project directly in Visual Studio 2005 or 2008. When you click on a link that would normally download a zip file, it asks you instead if you'd like to open the sample up using The Code Project Browser. If you say yes, the add-in will download the file, unzip it to a base My Documents\My Code Project Samples directory, then load it directly. It also provides a sidebar where you can view, reload and delete all of the projects you've downloaded. How It's UsedOnce installed, you will have a Tools > Code Project Browser menu item. Clicking that will bring up the add-in, which runs by default as a tabbed document (you can change that by right clicking the tab). NOTE: You may need to use the add-in manager if it doesn't initially show up.
Downloading ProjectsYou can browse The Code Project normally using the add-in. Once you click on a sample zip file link, the following will happen:
The Downloaded Projects View
This area allows you to view, reload and delete any of the projects you've downloaded from The Code Project. To go to the "Downloaded Projects" view, click the "Downloaded Projects View" toolbar button. It's a sidebar tree view that shows all of the directories in the My Documents\My Code Project Samples directory and shows all of the solutions and projects they contain. You can reload any project or solution from this view by double clicking on the item you want to load. There is a context menu available for all items that lets you browse to the project's article or its containing directory. You can also delete projects by selecting the directory node and pressing the delete key, or by right clicking and selecting Delete. The Toolbar
Using the CodeAll of the code for this add-in is included in the sample project at the top of this article. Because there are several articles already about writing add-ins, I'll go over some of the things that I found particularly interesting while working on this project. SharpZipLibThis code uses the The Tool Window "Shim"I hadn't been working on this for 15 minutes before I hit a major roadblock. I had no idea how to do something so simple as create a tool window as part of my add-in. This was unbelievably frustrating; how could this be so hard? Thirty minutes of Help browsing came up with nothing and it wasn't until I went on the Web that I found Carlos Quintero's article about how to do this. In a nutshell, creating a tool window involves using a homegrown "shim" or pseudo-host for the tool window contents, written by Craig Skibo from the Visual Studio team. I'd like to thank both of them for their published work. I later found this article, which describes the new way to do this in Visual Studio 2005 without using the shim. Apparently, the shim was required for Visual Studio 2003, but not Visual Studio 2005. All of this goes to show one thing that I've learned from doing add-in and VSIP work... the solutions to most problems are rarely obvious or intuitive and the importance of community contributors is huge. Downloading and Being Logged InAgain, I thought that something that would be very straightforward turned out to be quite a challenge. I intercept the Web browser's "Navigating" event and if the URL has a *.zip extension, then I assume that it is sample code and prompt the user whether or not they want to open it directly in Visual Studio. If they say yes, then I use the Unfortunately, The Code Project requires that you are logged in to download samples. If you log in through the Web browser, then the Web browser has established a session with The Code Project and identifies its session with a cookie, obtained at the time of the log in. Without that cookie, The Code Project thinks that the request is coming from an unknown source, and redirects to the login page. Because of this, trying to download files this way resulted in lots of downloaded login pages. It wasn't until I found this post by Durgaprasad Gorti that I learned how this could be done using the Those who used the The Code Project Browser before remember that there used to be a special separate login to use the add-in. I recently found a way to parse the needed cookies directly from the Web page owned by the Web Browser control. That means that the separate login is no longer required and you log in through the Web site, which is how I wanted it originally. Reporting Download ProgressBoth logging in and downloading files are done asynchronously using the DTE OperationsFinally, a word about the DTE. I needed to use this object to have Visual Studio load any downloaded projects or solutions. The I tried invoking the Points of InterestI use this add-in all the time since writing it. Here's a few tips you may find useful:
History
|
||||||||||||||||||||||||