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 override any member, you can right-click the member of the base class in the<br />

Solution Explorer window, click Add, then click Override to stub out the member<br />

as overridden. Note that if you right-click the member of the underlying<br />

interface (ICommand or ITool) instead of the base class member, the overridden<br />

member will not include the overrides keyword, and the method will instead be<br />

shadowed.<br />

[VB.NET]<br />

Public Overrides Sub OnClick()<br />

' Your OnClick<br />

End Sub<br />

[C#]<br />

public override void OnClick()<br />

{<br />

// Your OnClick<br />

}<br />

Alternatively, to override a member of the base class, click Overrides from the<br />

dropdown list on the right in the Code Window Wizard bar, then choose the<br />

member you want to override from the left dropdown list. This will stub out the<br />

member as overridden.<br />

What do the base classes do by default?<br />

The table below shows the base class members that have a significant base class<br />

implementation, along with a description of that implementation. Override these<br />

members when the base class behavior is not consistent with your customization.<br />

For example, Enabled is set to True by default; if you want your custom command<br />

enabled only when a specific set of criteria has been met, you must override<br />

this property in your derived class.<br />

Member<br />

ICommand::Bitmap<br />

ICommand::Category<br />

ICommand::Checked<br />

ICommand::Enabled<br />

ITool::OnContextMenu<br />

ITool::Deactivate<br />

Description<br />

The given bitmap is made transparent based on the<br />

pixel value at position 1,1. The bitmap is null until<br />

set by the derived class.<br />

If null, sets the category "Misc."<br />

Set to False.<br />

Set to True.<br />

Set to False.<br />

Set to True.<br />

Working with the ESRI .NET component category classes<br />

To help register .NET components in COM component categories, ESRI provides<br />

the ESRI.<strong>ArcGIS</strong>.Utility.CATIDs namespace, which has classes that represent<br />

each of the <strong>ArcGIS</strong> component categories. Each class knows its CATID and<br />

exposes static methods (Register and Unregister) for adding and removing components.<br />

Registering your component becomes as easy as adding COM registration<br />

methods with the appropriate attributes and passing the received CLSID to the<br />

appropriate static method.<br />

The example below shows a custom Pan tool that registers itself in the ESRI Mx<br />

Commands component category. Notice in this example that<br />

Chapter 4 • <strong>Developer</strong> environments • 171

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

Saved successfully!

Ooh no, something went wrong!