Visual Studio Add-Ins: Explorer

My next find for a Visual Studio Add-In is called Explorer, and is another free one available from http://www.codeproject.com/csharp/Explorer.asp . Explorer is easy to install and use.

After you download, extract the two files to your My Documents/Visual Studio 2005/Addins directory (create the Addins directory if it doesn’t exist). Then launch Visual Studio, click on Tools, Add-in Manager, and make sure Explorer is loaded.

Using Explorer is quite simple, just right click on the Solution, Project, or a folder and you’ll see a new menu option, Explorer.

[Picture of Explorer Menu]

 Explorer has a submenu with two options, “Open folder” and “Execute this application”. Open folder opens up a windows explorer folder in the same directory where the item you clicked on resides. This is a very handy way to quickly navigate to the directory where your project resides.

Note the “Execute the application” option only appears when you are on a project, not the solution. However, this is handy when you have a test project that is not your main application. Using this menu option keeps you from having to go through the effort of changing your startup project to run a rest program that is part of your solution.

Be aware this does not build the project, it runs the last built exe you created. If you’ve made changes to the project you want to run be sure to do a build before using this menu option.

If you are interested in writing your own add-ins, you should also check out the available source code. It’s a nice example of how to hook into the menu structures for writing your own add-ins.

Arcane Searches

One of the things I really like about WordPress is that you can see the search engine terms that lead people to your site. In the lists I see some search terms that occur frequently. I thought it might be fun to take a guess at what the googlers were looking for, and take a stab at answering them.

exit full screen remote desktop

Move your mouse to the top, center of the display. A little yellow bar will scroll down, with the machine name. On the left is a push pin you can use to make it stick. On the right is the traditional Min / Max buttons you see on a window.

virtual pc exit full screen

Alt + Enter will exit full screen, but it has to be the Alt key on the right side of the keyboard. (This assumes you haven’t changed you hot key mappings).

command to close virtual pc

There’s several ways to close a virtual pc. The simplest, and best is to do a shutdown of what ever OS you are running. When the guest OS shuts down, the Virtual PC exits.

You can also select Action, Close on the menu, VPC will prompt you to see if you want to close and save state (sort of like Hibernate on a laptop) or exit and discard changes. If you are running a Windows OS, VPC will also give you the option to shut down. You can get the same prompt by clicking the X (cancel) button on the window your guest OS is running in.

eventtoaster

This is one that shows up a lot in my searches. Event toaster is part of the Visual Studio Enhancements Add-In from Microsoft. See my entry on November 15th (https://arcanecode.wordpress.com/2006/11/15/visual-studio-add-ins-ms-visual-studio-enhancements/ or http://shrinkster.com/kdt ) for more info.

virtual computer usb

Virtual PC does not support USB in either version 2004 or Server 2005. And, despite being the most asked for item in Virtual PC 2007, Microsoft still does not have any plans to include it in the next version.

VMWare, on the other hand does support USB. In the VMWare Server product, USB is not entered by default. You can add it, however by Editing the Virtual Machine Settings. In the dialog under Hardware click Add, and pick USB.

zone alarm remote desktop client

Another one that appears frequently, I’m guessing there’s a need to know how to get remote desktop to cooperate with Zone Alarm. Open the Zone Alarm settings panel, and click on Firewall. By default the Internet Zone Security is set to High. Drop this to Medium to get it to work with remote desktop. You will also need to go into Program Control and put checks for Remote Desktop Connection for all four columns.

defrag a single file

Use the SysInternals Contig tool. See https://arcanecode.wordpress.com/2006/11/06/sysinternals-contig/ for more info.

There’s a few of the top searches from my history, hopefully I’ve answered questions for a few of you out there!

Visual Studio Add-Ins: SmartOutline

SmartOutline is a tool for creating regions in your code without having to use Region / EndRegion tags. Available at http://submain.com/default.aspx?nav=products.smartoutline, this tool took third place in the Microsoft Visual Studio Extensibility Contest packages category.

SmartOutline is a product that’s easier to show you how it works than describe, so let’s look at a few pictures. Let’s say I have a simple if statement. Highlighting it gives me a new pop up, as you can see below.

[SmartOutline 1]

Clicking on the Create new SmartOutline Region command brings up the following dialog, where you key in the name for your region.

[SmartOutline 2]

In this example I’ve keyed in “My If Statement” for the name. Assuming I then check the “Collapse region” box, my code will update as you see below.

[SmartOutine 3]

 

Clicking the + button will expand my region back to the original state, as you can see.

[SmartOutine 4]

SmartOutline is useful for hiding long lengths of code that add safety but not value. For example, you might have to do a lot of validation to input parameters, but they don’t add to the real purpose of the method. SmartOutline is a great way to hide that.

You might assume that SmartOutline is altering the source files using Region tags and intercepting them. Not so, as this command window dump of the source file proves:

[SmartOutine 5]

 

Some useful situations to use SmartOutine to hide code segments might include:

  • Lengthy error handlers
  • Long parameter checks
  • Long comments
  • Code that is commented out, perhaps something for a future version or older version that you’re not sure you want to delete
  • Using (or Imports) sections
  • Entire Methods

These are just a few ideas, feel free to post a comment with your own thoughts.


My one complaint / wish list item for enhancement is that SmartOutline left aligns the name you give to the smart region. This breaks up the visual flow of indents. You can add spaces yourself when you give the name, for example I could have keyed in six spaces then “
My If Statement”, but if I were to indent the code later SmartOutline doesn’t change to reflect this. You should also know this is a VS2005 tool only, sorry 2003 users.


Overall a useful tool for adding to the readability of your code, well worth the download, and like many of the other tools mentioned so far, it’s free.

Visual Studio Add-Ins: VSCmdShell

VSCmdShell is a handy add-in that places a Command window inside of Visual Studio. Available at http://www.codeplex.com/Wiki/View.aspx?ProjectName=VSCmdShell, after a simple install you can launch the command window from the View, Shell Window command. By default it launches as free floating, I chose to dock mine down at the bottom with the Command and Output windows.
[Picture of default VSCmdShell]

From here, you can issue your typical array of commands, such as getting a directory, but the cool thing I use it for is my deployment scripts. I have a cmd file (sort of the new version of a batch file) that compiles my web apps then deploys to the development server.

VSCmdShell has some nice customizations. It has the things you might expect, like being able to change the text and background colors, but you can also select the shell. For example, you could install the new Windows PowerShell, and use it as your default shell window.

To get to VSCmdShell’s options, click on Tools, Options. Scroll down to “Power Toys”. Note if you previously installed the Visual Studio Enhancements (which I blogged about at https://arcanecode.wordpress.com/2006/11/15/visual-studio-add-ins-ms-visual-studio-enhancements/) you’ll actually have two entries for power toys. The “PowerToys” (no space) is from the enhancements, the “Power Toys” (with a space) is from the VSCmdShell. Here’s a quick shot of the dialog:

[VSCmdShell Options Dialog]

As you can see, you can change the font and colors, the shell, and even set the initial directory for the command shell. Best of all, VSCmdWindow automatically sets up all the VS variables for you. If you ever have need of a command prompt, this free tool is well worth the download.

Visual Studio Add-Ins: Paste As…

If you are like most programmers, you tend to fiddle with your SQL in some tool where you can run, test, and optimize your SQL before you paste it into your app. Or perhaps you have some long static text info (such as instructions) that you need to display to the user. You type it all in, then you have to mess around with getting it onto a string. You break it into multiple lines, perhaps you are using a string builder to hold it. The whole time you’re thinking there’s got to be an easier way. Well, there is!

The great add on, Paste As… from

http://weblogs.asp.net/alex_papadimoulis/archive/2004/05/25/Smart-Paster-1.1-Add-In—StringBuilder-and-Better-C_2300_-Handling.aspx (or if you like shorter URLs, I’ve shrinksterized it, http://shrinkster.com/jut ).

This add-on takes whatever text you have in the buffer and pastes it into your code in one of four ways: as a comment, as a string, as a string builder, or as a region. Let’s take a fake SQL statement and render it the various ways. First, here is a SQL Statement that you’ve worked on inside your SQL tool (it’s fake, but you’ll get the idea.)

select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate, HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit

Here it is as a comment:

//select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate,

//HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit

Now here it is as a string:

@”select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate, “ +

@”HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit”

All you have to do is put “myString = “ on the front, and (if you are in C#) a ; at the end and you’re done. Now here it is as a StringBuilder. Note it will prompt you for the name of your StringBuilder variable, and how cool is it that it automatically calculates the size of the string for you (in this case 147).

StringBuilder myStringBuilder = new StringBuilder(147);

myStringBuilder.AppendFormat(@”select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate, “);

myStringBuilder.AppendFormat(@”HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit”);

 

The final option is Paste As Region. While you would not typically paste a single SQL statement as a region, let’s see how it looks anyway:

#region myRegion

select FirstName, MiddleInit, LastName, Street, City, State, Zip, PayRate, HireDate from SomeEmployeeTable order by LastName, FirstName, MiddleInit

#endregion

In the context we’ve presented above probably not something you’d do. Where this would come in handy is when you’ve copied a bunch of code to the clipboard, and want to paste it into a new region. Since it does no reformatting, this makes it an easy way to bring in new code to your application.

This tool works with both VS2003 and VS2005, and works in both C# and VB.Net. It has quickly reached the top of my “indespensible” list and is one of the first I install when setting up a new instance of VS. And it’s free! How cool is that.

Visual Studio Add-Ins: Copy Source as HTML

Our next tool is very handy for those of us who blog, or perhaps just want to share code snippets with friends using HTML enabled e-mail. Copy Source as HTML, available at http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/ does just what it says. It takes the lines of source code you have highlighted in your Visual Studio editor and copies them to the clipboard as HTML.

For an example, I’ve pasted this simple HTML into my blog so you can see what it looks like. This is HTML text, not a picture:

 

    9 namespace WinTest1

   10 {

   11     public partial class Form1 : Form

   12     {

   13         public Form1()

   14         {

   15             InitializeComponent();

   16         }

   17     }

   18 }

 

 

There are several options, as you can see from the dialog below.

[Copy Source as HTML Options Dialog]

You can have line numbers (as I’ve done above), set the line number to start at, or omit them entirely. You can activate word wrap, over ride the default tab size, font and font size. If you’re a CSS guru there are even tabs for entering your own CSS for both the entire section (surrounded in DIV tags) or the individual line.

Another great free add-in, it has both 2005 and 2003 versions. If you ever need to convert your code to HTML this is a great, easy way to do it.

Visual Studio Add-Ins: DPack

DPack is an add-on I’ve used for quite some time, coming in both VS2003 and VS2005 versions. Available from USysWare (http://www.usysware.com/dpack/) this add-on has a wide variety of tools including Code Browser, File Browser, Solution Browser, Framework Browser, Numbered Bookmarks, Surround With, Code Navigation, Solution Statistics, and Solution Backup.

Some of the items, like the browsers have some overlap with other tools mentioned already. For example, I find the solution browser from Microsoft (see my previous post) easier to use. However, the DPack browsers add a lot of useful statistics that the other tools don’t.

Surround With is probably the tool I use the most. Right clicking highlighted text and picking Surround With produces a pop up window.

[Picture of DPacks Surround With feature.]

As you can see here, I selected for from the list:

[Pic of Surround With in action.]

Solution Backup is another tool I use frequently. Whenever I reach a milestone in my code, such as completing a bug, I use Solution Backup to take the entire project and save it to a ZIP file.

Take a look at the website, USysWare has some good demonstrations and snapshots of the tools included in the pack. Like the other tools, it’s totally free, so worth adding to your toolkit.

Visual Studio Add-Ins: MS Visual Studio Enhancements

The next add-in I guess technically isn’t an add-in, since it doesn’t reside in the Add-Ins window, but it’s close enough. Coming from Microsoft itself, this handy download is named Visual Studio 2005 IDE Enhancements, but I notice the file name is vssdk_powertoys. Cool.

You can download this set of five tools from http://www.microsoft.com/downloads/details.aspx?familyid=cd7c6e48-e41b-48e3-881e-a0e6e97f9534&displaylang=en or http://shrinkster.com/jwx .

The first, and incredibly useful tool in this free add-in is the Source Outliner. Seen in the window below, it builds a source tree that resides in a window with the toolbox and server explorer. To activate, click on View, Other Windows, Source Outliner.

You can quickly and easily navigate through your project using the tree. On a large project or class this will be very useful, I can tell this is a tool that will get a lot of work out in my environment.

[Picture of Source Outliner]

Next is a collection of Visual C++ snippets. Great if you’re a C++ guy, just sort of there if you’re not.

Third is something they call Indexed Find. This uses the Microsoft Index Service to provide advanced search capabilities. You indicate what you want to look for, what directory (or directories) to look in, file types, and away it goes.

I can see where this would be handy, let’s say you have another project that you know you’ve written a routine in, but can’t recall which file it’s in. Whip out this handy tool and let it look for you. Like the other tools here, it’s available via the View, Other Windows menu.

Fourth up is the Super Diff Utility. Just what you’d expect from the name, it will let you specify two source files and does a compare, highlighting differences. Very handy when you want to look back upon a previous version you’ve pulled from your source repository, or perhaps you’ve got conflicting versions on different disk drives and want to determine which you should be using.

The final tool in the pack is the Event Toaster Utility. Unlike the other tools, this one is access via the Tools, Options dialog. Down in Power Toys, EventToaster you can see a list of VS events you can hook into.

[Picture of EventToaster.]

As you can see, there are a wide variety of tasks you can launch, from something as simple as a sound to something as complex as a macro.

Microsoft has done a nice job with these tools, extending the Visual Studio IDE in some very useful ways.

Visual Studio Add-Ins: SlickEdit Gadgets

We’ve spent a while talking about tools you can use outside Visual Studio to help you with your application development. It’s time now to look at some tools we can use inside Visual Studio.

First up is a brand new set of VS Add-Ins from SlickEdit (http://www.slickedit.com/content/view/441), called SlickEdit Gadgets. This free add-in comes with five tools: Editor Gadgets, Command Spy, File Explorer, Data Object Analyzer, and the SLOC Report.

The first tool, Editor Gadgets, contains four useful items. First, there is an Indentation Guide that draws a line down the screen at the current indent level for your cursor. Next is a Line Ruler, that highlights the current line and displays the tab settings. Both of these are illustrated in the following graphic:

[Indent and current line bar tools.]

Third is a very useful feature called Auto-Copy. When text is selected with the mouse, it’s automatically copied to the clipboard. To paste, click with the middle button (or scroll wheel, if you have a clickable scroll wheel).

The final option is the ability to place a graphic over the editor window. In the example on their website they have a green bar paper image behind the editor text. These various features can be enabled and disabled via the options window inside Visual Studio. For example, I thought the blue background and black border on the Ruler Line to be distracting, so I reset to a white background and light gray border.

[Muted bar.]

As you can see, much less distracting. I also opted to turn off the indentation line.

Next up is the Command Spy. If you are a VS Macro writer, you’ll find this tool indespensible. Command Spy is a small window (you can dock it with the Output and other windows). As you activate various commands in VS, Command Spy shows you the command in the window. Again, very useful if you want to write macros.

The third is what I consider to be the most useful tool, right behind Auto Copy: File Explorer. It’s just what it sounds like, it puts a File Explorer tab into your VS environment.

[File Explorer Tool]

You can then drag any of these items into your project solution window. I can see where this handy tool will get used a lot.

Next up is the Data Object Analyzer. This tool lets you examine what you put on the clipboard, see it’s properties, and generate code to handle it. How useful this will be remains to be seen, if you find creative uses for it feel free to post a comment.

The final tool in this free kit is the SLOC report. SLOC stands for Source Lines of Code, it creates a Pie Chart style report that shows you the ratio of comments, white space, and actual lines of code. You can run the report for individual files or entire projects.

This can be handy if you need some quick statistics, perhaps you are doing a code review and want to be sure the ratio of code to comments is respectable. Most times though you won’t find this tool all that useful.

One thing to note, it only works with VS 2005, if you are still in the 2003 environment you’re out of luck.

There you go, a new tool from Slick Edit that’s free and adds several useful features to Visual Studio. Please leave a comment, I’m curious what your favorite features are and how you are using the tool.