GEOG 490/590

GIS Programming

Exercise 6: Buttons and Tools

In this exercise you will practice adding functionality to custom buttons and tools. This exercise adds functionality to the project we created in Lab 1 so start by finding that project. In this exercise we go back to complete the steps that we skipped in Lab 1.

This exercise makes many references to the Snippet Finder Tool which works differently in Visual Studio Professional than it does in our version of Visual Basic Express. Here are a couple of discussions in the ArcGIS user forums on how to add the Snippet Finder Tool to VB Express. These solutions are specific to the computer you use to implement them so if you switch computers, you'll have to make the changes again.

http://forums.arcgis.com/threads/15762-ArcGIS-Snippet-Finder-Where-is-it

http://forums.arcgis.com/threads/5627-ArcGIS-10-Pre-Release-Visual-Studio-Express-2008-Integration-Issues?p=45803#post45803

Alternatively, there is an alphabetical listing of the snippets available in ArcGIS help. Look down near the bottom for IDE integration snippet code > ESRI.ArcGIS.Snippets > Snippets. The snippets are listed under this heading alphabetically.

Go to the "Building custom UI elements using add-ins walkthrough" in ArcGIS 10 online help. This should look familiar as it was the basis for Lab 1. Skip to the section called Adding ZoomToLayer functionality to the custom button. As stated above, the Snippet Finder isn't going to work as advertised in this walkthrough. You can find the code for the ZoomToLayer subroutine online here. As the walkthrough states, you can call this subroutine from the OnClick() method of your custom button.

Next you'll add AddGraphics functionality to the custom tool. The AddGraphicToMap code snippet can be copied from here and the GetPolylineFromMouseClicks is available here. As the walkthrough states, you'll call these subroutines from the OnMouseDown() method of your custom tool.

You can either follow the walkthrough instructions to build and run the updated project or use the debugger. Does it work?