Add layer to Map with “autoArrange”

April 16, 2008

One of the very common operations programmers do in ArcObjects is adding a layer to the Map. To do this there are two ways, one using IMap.AddLayer or IMapLayers.AddLayer.

IMap.AddLayer adds the new layer on the top of all the layers in the map. This is not very useful as we normally want the point layers at the top followed by polyline followed by polygon layers. Adding polygon layers at the top would mask all other layers below.

IMapLayers.AddLayer is preferable because it has an option to autoArrange the newly added layer in the table of contents. If autoArrange is set to TRUE, the layer is added in the proper position as by its weight specified via ILayerPosition::LayerWeight. By default, this means that the layers are sorted by layer type – Annotation layers on top, followed by Point geometry layers, Polyline geometry layers, and at the bottom Polygon geometry layers.


Unit Testing with ArcGIS

January 14, 2008

As a part of writing any unit-test to test the add-ins (buttons/tools/extensions) and their behavior in ArcMap, it is essential to automate starting ArcMap and running the commands. Here is a good article on how to automate ArcMap.

What’s new in Visual Studio 2008

November 13, 2007

With the release of Vs 2008 around the corner, this is a good site to know what is new in the product

Changing Bitmap on BaseCommands/Tools at runtime

October 26, 2007

A common scenario that ArcObjects developers come across is creating a button or tool in ArcMap whose image changes when clicked.

Example: Say you wish to create a “LogOn” button whose bitmap needs to change to “LogOff” bitmap once the user has logged in.

Just setting base.m_bitmap to the new bitmap does not update the bitmap in ArcMap. Instead you need to use the BaseCommand.UpdateBitmap method.

Per ESRI .Net documentation:
UpdateBitmap changes the Bitmap for the command. Call this method to update the icon used for the command at runtime, after the command has already been instantiated.

.Net Coding Guidelines

January 17, 2007

This is an excellent white paper on .Net coding guidelines. I couldn’t have written it better. A must read.

Microsoft “Blend”

December 5, 2006

Microsoft has changed the name of Expression to “Blend”. This is the third name I ‘ve heard of the product, initial being Sparkle, then Expression, now Blend.

Also, Expressions is out of beta now.