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 />

Events<br />

The type library importer creates several types that enable managed applications<br />

to sink to events fired by COM classes. The first type is a delegate that is named<br />

after the event interface plus an underscore followed by the event name, then the<br />

word EventHandler. For example, the SelectionChanged event defined on the<br />

IActiveViewEvents interface has the following delegate defined:<br />

IActiveViewEvents_SelectionChangedEventHandler. The importer also creates an<br />

event interface with an ‘_Event’ suffix added to the end of the original interface<br />

name. For example, IActiveViewEvents generates IActiveViewEvents_Event. Use the<br />

event interfaces to set up event sinks.<br />

Non-OLE automation-compliant types<br />

COM types that are not OLE automation compliant generally do not work in<br />

.NET. <strong>ArcGIS</strong> contains a few noncompliant methods, and these cannot be used<br />

in .NET. However, in most cases, supplemental interfaces have been added that<br />

have the offending members rewritten compliantly. For example, when defining<br />

an envelope via a point array, you can’t use IEnvelope::DefineFromPoints; instead,<br />

you must use IEnvelopeGEN::DefineFromPoints.<br />

[VB.NET]<br />

Dim pointArray(1) As IPoint<br />

pointArray(0) = New PointClass<br />

pointArray(1) = New PointClass<br />

pointArray(0).PutCoords(0, 0)<br />

pointArray(1).PutCoords(100, 100)<br />

Dim env As IEnvelope<br />

Dim envGEN As IEnvelopeGEN<br />

env = New EnvelopeClass<br />

envGEN = New EnvelopeClass<br />

' Won't compile<br />

env.DefineFromPoints(2, pointArray)<br />

' Doesn't work<br />

env.DefineFromPoints(2, pointArray(0))<br />

' Works<br />

envGEN.DefineFromPoints(pointArray)<br />

[C#]<br />

IPoint[] pointArray = new IPoint[2];<br />

pointArray[0] = new PointClass();<br />

pointArray[1] = new PointClass();<br />

pointArray[0].PutCoords(0,0);<br />

pointArray[1].PutCoords(100,100);<br />

IEnvelope env = new EnvelopeClass();<br />

IEnvelopeGEN envGEN = new EnvelopeClass();<br />

// Won't compile<br />

148 • <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!