18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH WINDOWS CONTROLS<br />

8. Build and run the application. Use the map navigation tools that you added<br />

earlier to change the extent of the focus map in the PageLayoutControl. The<br />

new extent is drawn on the MapControl.<br />

This scenario’s source code is located at<br />

\<strong>Developer</strong>Kit\samples\<br />

<strong>Developer</strong>_<strong>Guide</strong>_Scenarios\<br />

Building_an_<strong>ArcGIS</strong>_Controls_Map_<br />

Viewer_ApplicationCSharp.zip.<br />

Creating a custom tool<br />

Creating custom commands and tools to work with the MapControl and<br />

PageLayoutControl is very much like creating commands for the ESRI ArcMap<br />

application that you may have done previously. You will create a custom tool that<br />

adds a text element containing today’s date to the PageLayoutControl at the<br />

location of a mouse click. You will, however, create the command to work with<br />

the MapControl and ToolbarControl as well as the PageLayoutControl.<br />

The code for this custom tool is available with the rest of this scenario’s source<br />

code. If you want to use the custom command directly, rather than creating it<br />

yourself, go directly to Step 24.<br />

1. Create a new Visual C# Class Library project from the New project dialog<br />

box.<br />

2. Name the project ‘Commands’, and browse to a location to save the project.<br />

3. Click on the Project menu and click Add Reference.<br />

4. In the Add Reference dialog box, check ESRI.<strong>ArcGIS</strong>.Carto,<br />

ESRI.<strong>ArcGIS</strong>.Display, ESRI.<strong>ArcGIS</strong>.Geometry, ESRI.<strong>ArcGIS</strong>.System,<br />

ESRI.<strong>ArcGIS</strong>.SystemUI, ESRI.<strong>ArcGIS</strong>.Utility, and<br />

ESRI.<strong>ArcGIS</strong>.ControlCommands.<br />

5. Add one class to the project, named “AddDateTool”.<br />

6. Click the Project menu and click Add Existing Item. Browse to the date.bmp<br />

file from its location in this sample’s source code and add it into your project.<br />

7. Click the date.bmp file in the Solution Explorer window to display its properties<br />

in the Properties window. Change the Build Action property to Embedded<br />

Resource. This bitmap will be used on the face of the command button.<br />

Chapter 6 • <strong>Developer</strong> scenarios • 347

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!