Something I wanted to streamline for my development team was icon and bitmap management; or rather taking as much of the decision making process out of the equation. The strategies I have taken have the following benefits.

Time / Efficiency
  • I don’t want developers spending any time digging around for or capturing an icon/bitmap. Period.
  • I don’t want 10 different methods written to assign an image to a control; which would require a minimum of 10 unit tests be written, and so on.
  • I do want to be able to change an icon or bitmap in one place and have that automatically update all projects. Really, how many copies of the folder browser image do you need across projects?
  • I want a single location where our custom ArcGIS command icons are stored.
Consistent Presentation Layer
  • Icons and bitmaps should be consistent across the presentation layers. I prefer to use Windows icons to ensure user recognition of functionality and purpose. I don’t want icons from different Windows OS mixed either. Office XP icons look dated on Vista… And Office 2000 icons look like ass on XP and Vista. By the same token, if your company has spent the money and bought an icon library then you want only images from that library used in your software. The one acception to this rule is the outdated ArcGIS icon library. I will mix these into my UI for example when a button’s functionality is to select features.

What follows is a brief primer on how to get started building an icon and bitmap library, and a utility class with methods for retrieving those images.

The Utilities Assembly

I have created a sample Utilities library to be referenced by any project requiring icons or bitmaps. This includes custom Windows Forms, ArcGIS ICommand classes, custom property pages, etc. This project contains a “Resources” folder that holds the icons and bitmaps, has entries in the Resources.resx file, and an IconHelper class.

Adding Icons and Bitmaps

I started by first creating a “Resources” folder within the project. Next, I built my icon and bitmap library by adding the desired icons and bitmaps to that folder. I rename these files appending “Icon” or “Bitmap” (Example: Save.ico to SaveIcon.ico). This makes it easier to identify the image type when using the My feature in VB.NET (Example: My.Resources.SaveIcon).

The IconHelper Class

I created enums for both icons and bitmaps providing intuitive names… the actual file name minus the “Icon” or “Bitmap” you may have appended to it. Here you could do some logical groupings if you wanted for such things as EnumTextEditorIcons and such.

This is just one example that is included in the sample.

The enum:

”’ <summary>

”’ Enum for common Icons.

”’ </summary>

Public Enum EnumIcon

AddNew

Copy

Delete

ErrorProvider

Folder

Help

etc…

End Enum

The method to retrieve the icon using the enum:

”’ <summary>

”’ Gets an icon from the embedded resources.

”’ </summary>

”’ <param name=”iconImage”>The icon image.</param>

Shared Function GetIcon(ByVal iconImage As EnumIcon) As Icon

Select Case iconImage

Case EnumIcon.AddNew

Return My.Resources.AddNewIcon

Case EnumIcon.Copy

Return My.Resources.CopyIcon

Case EnumIcon.Delete

Return My.Resources.DeleteIcon

Case EnumIcon.Folder

Return My.Resources.FolderIcon

Case EnumIcon.Help

Return My.Resources.HelpIcon

etc…

Case Else

Return Nothing

End Select

End Function

Putting it all together in the UI:

‘ Assign an image to a Button control

Me.FolderBrowserButton.Image = _

IconHelper.GetIcon(EnumIcon.Folder).ToBitmap()

 

‘Add bitmap MxCommand

MyBase.m_bitmap = _

IconHelper.GetIcon(EnumCustomArcGisCommands.ReportsGenerator).ToBitmap()

The Sample

The sample illustrates how to use the utility class in a Windows Form and shows other ways to expand this idea.

Download VB.NET sample or C# sample.

Posted by: Jeff Germain | February 14, 2007

Source Code Documentation in VB.NET

I recently discovered GhostDoc which is a free add-in for Visual Studio .NET (2003 & 2005). It’s a handy tool that generates XML documentation comments. This tool was written for C# developers but has extended beta support for VB.NET. What’s nice about it is that it reinforces the idea of using full descriptive names when creating methods, properties, parameters, etc. It will create a descriptive summary by dissecting the member name and formulating a sentence. It’s about as hands free as it gets!

I’ve been using it in my VB.NET projects with much success. While it doesn’t always get it 100% right, it does get you 95% of the way there. Definitely a time saver.

If you want to use it within VB.NET you’ll need to enable this feature in the configuration dialog. Go to Tools | GhostDoc | Configure GhostDoc and select the Options tab. There you’ll find a checkbox for this feature.

I’ve barely scratched the surface of this tools capabilities. You can set it up to add the username or timestamp when documenting members. Lot’s more too! So have a look.

Posted by: Jeff Germain | February 14, 2007

Debugging Custom ArcGIS 9.1 Components in Visual Studio .NET 2003

If you have both the .NET 1.1 and 2.0 Frameworks installed on your development machine you will run into troubles when trying to debug ArcGIS 9.1 components written on the .NET 1.1 Framework. This is because ArcMap is an unmanaged application and as such when it initializes it loads the most current .NET Framework installed on the system. Not to fret though as it’s easily overcome using a configuration file.

Simply copy the following to a text file and save it as <ApplicationName>.<ApplicationExtension>.config
So, a config file for ArcMap would be named ArcMap.exe.config.

<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<startup>
<supportedRuntime version=”v1.1.4322″ />
</startup>
</configuration>

Save this file to the ArcGIS bin directory. The default location for this directory is C:\Program Files\ArcGIS\Bin.

Now you’re set to debug .NET 1.1 components. When you need to debug .NET 2.0 components simply rename the file to ArcMap.exe.config.xxx.

You can read more from ESRI here.

Posted by: Jeff Germain | February 2, 2007

Task Manager Missing Tabs

I’ve had an annoying problem for a while now and finally got around to looking into it. My Task Manager was missing all it’s tabs. In fact, it was getting displayed without being hosted within its usual Windows Form. I had know idea what I did to  deserve this. See below.

Task Manager Issue

Anyways, it’s an easy fix. Simply double-click anywhere around the border to viola! it’s back!. Double-click again and it goes back into this minimalist mode.

Task Manager Fix

Task Manager Fixed

Categories