18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

.NET APPLICATION PROGRAMMING INTERFACE<br />

To simplify this process, ESRI provides classes for each component category<br />

<strong>ArcGIS</strong> exposes with static functions to register and unregister components. Each<br />

class knows the GUID of the component category it represents, so registering<br />

custom components is greatly simplified. For more details on using these classes,<br />

see the ‘Working with the ESRI .NET component category classes’ section below.<br />

Simplifying your code using the ESRI.<strong>ArcGIS</strong>.Utility assembly<br />

Part of the <strong>ArcGIS</strong> developer kit includes a number of .NET utility classes that<br />

facilitate .NET development by taking advantage of a few .NET capabilities<br />

including object inheritance and static functions.<br />

Working with the ESRI .NET base classes<br />

ESRI provides two abstract base classes (BaseCommand and BaseTool) to help you<br />

create new custom commands and tools for <strong>ArcGIS</strong>. The classes are abstract<br />

classes (marked as MustInherit in Visual Basic .NET), which means that although<br />

the class may contain some implementation code, it cannot itself be instantiated<br />

directly and can only be used by being inherited by another class. Both base classes<br />

are defined in the ESRI.<strong>ArcGIS</strong>.Utility assembly and belong to the<br />

ESRI.<strong>ArcGIS</strong>.Utility.BaseClasses namespace.<br />

These base classes simplify the creation of custom commands and tools by providing<br />

a default implementation for each of the members of ICommand and ITool.<br />

Instead of stubbing out each member and providing implementation code, you<br />

only have to override the members that your custom command or tool requires.<br />

The exception is ICommand::OnCreate; this member must be overridden in your<br />

derived class.<br />

Using these base classes is the recommended way to create commands and tools<br />

for <strong>ArcGIS</strong> applications in .NET languages. You can create similar COM classes<br />

from first principles; however, you should find the base class technique to be a<br />

quicker, simpler, less error-prone method of creating commands and tools.<br />

Syntax<br />

Both base classes also have an overloaded constructor, allowing you to quickly set<br />

many of the properties of a command or tool, such as Name and Category, via<br />

constructor parameters.<br />

The overloaded BaseCommand constructor has the following signature:<br />

[VB.NET]<br />

Public Sub New( _<br />

ByVal bitmap As System.Drawing.Bitmap _<br />

ByVal caption As String _<br />

ByVal category As String _<br />

ByVal helpContextId As Integer _<br />

ByVal helpFile As String _<br />

ByVal message As String _<br />

ByVal name As String _<br />

ByVal tooltip As String)<br />

[C#]<br />

public BaseCommand(<br />

168 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!