【文章內(nèi)容簡介】
ects 接口 ? QueryInterface的不同技巧 ? Implicit casting( 常用) ? Explicit casting( 語法復雜且易丟失數(shù)據(jù),不常用) ? TypeOf以避免處理 Implicit Casting帶來的InvalidCastException 異常( C中通常使用 as符) geometry = point ‘Implicit cast geometry = CType(point, IGeometry) ‘Explicit cast Dim point As New PointClass Dim geometry As IGeometry If (TypeOf point Is IGeometry) Then geometry = point End If Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 217 .NET 出接口 ?連接 COM 對象和接收事件 ?出接口后面加上“事件” ?例如 : IActiveViewEvents_Event ?技巧 ? WithEvents: 用來表示默認出接口 ? Delegate: 訪問非默認出接口 Private SelectionChanged As IActiveViewEvents_SelectionChangedEventHandler Public Overrides Sub OnClick() 39。Create an instance of the delegate, add it to SelectionChanged event SelectionChanged = New IActiveViewEvents_SelectionChangedEventHandler(AddressOf OnSelectionChanged) AddHandler , SelectionChanged End Sub Private Sub OnSelectionChanged() 39。Event handler (Selection Changed) End Sub Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 218 其它 ?異常處理 ?應該明確處理所有 COM 異常 ?垃圾收集 ?可能需要調(diào)用 ReleaseCOMObject Exception handling and garbage collection (ReleaseCOMObject) in dispose Try Dim env As IEnvelope = New EnvelopeClass() (0D, 0D, 10D, 10D) Dim trans As ITransform2D = env (, 1D) Catch ex As (Error: + ) 39。 Perform any tidy up of code. End Try Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 219 ? ArcGIS Engine 和 Desktop 在功能上相似 ?兩級許可 ?產(chǎn)品 ? ArcView, ArcEditor 和 ArcInfo ? Engine standard 和 GDB Update ?擴展 ? Spatial, 3D, StreetMap USA ArcGIS 產(chǎn)品許可模型 Desktop Extensions ArcSDE Edit ArcInfo ArcEditor Geodatabase Update Option Standard ArcView Standard Engine 3DAnalyst… 3DAnalyst… Engine Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 220 ArcGIS Engine 運行許可 : 產(chǎn)品 ?所有的應用必須在運行時初始化一個產(chǎn)品許可 ?使用 esriSystem::AoInitialize 初始化產(chǎn)品許可 ?可獲得的產(chǎn)品許可 ? ArcView ? ArcEditor ? ArcInfo ? Engine ? EngineGeoDB Private m_pAoInitialize As IAoInitialize Private Sub Form_Load() Set m