【文章內(nèi)容簡介】
s reserved. 1220 Lesson overview ? Tool 工具的事件 ?使用 IDisplayTransformation轉(zhuǎn)換屏幕坐標(biāo)到地圖坐標(biāo) ?使用 IGraphicsContainer來管理圖形元素 ?怎么刷新顯示 Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1221 Tool 工具事件 ? Tools 工具擁有一些事件過程 ?用于用戶交互的事件 ?Mouse events: MouseUp, MouseMove, MouseDown, DblClick ?Keyboard events: KeyUp, KeyDown ?用于定義工具行為的事件 ?Enabled ?CursorID ?ToolTip ?Message BuiltIn Cursors Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1222 怎么在事件中使用 X和 Y ?相關(guān)的鼠標(biāo)事件 ?MouseUp, MouseDown, MouseMove ?返回的是屏幕單位 (pixels) Private Sub UIToolControl1_MouseDown(ByVal button As Long, _ ByVal shift As Long, ByVal x As Long, ByVal y As Long) MsgBox X = amp。 x MsgBox Y = amp。 y End Sub Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1223 Display transformation ?在地圖單位和屏幕單位之間轉(zhuǎn)換所用到的方法 ?ToMapPoint: 轉(zhuǎn)換一個(gè)屏幕坐標(biāo)點(diǎn) (pixels)到一個(gè)地圖坐標(biāo)點(diǎn) ?FromMapPoint: 轉(zhuǎn)換一個(gè)地圖坐標(biāo)點(diǎn)到屏幕坐標(biāo)點(diǎn) ?使用鼠標(biāo)輸入 ?捕獲鼠標(biāo)點(diǎn)擊的象素值 ?使用地圖點(diǎn) Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1224 轉(zhuǎn)換屏幕坐標(biāo)系到地圖單位 ?使用 IDisplayTransformation的 ToMapPoint方法 ?返回一個(gè)地圖單位的點(diǎn) Dim pMxApp As IMxApplication Set pMxApp = Application Dim pPnt As IPoint Set pPnt = (x, y) MsgBox Longitude = amp。 MsgBox Latitude = amp。 Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1225 Example: Rubberbanding ?在模塊層定義變量 ?在 tool’s Select 事件中初始化 ?在 tool’s MouseDown 事件中輸入以下代碼 ?把返回值保存在一個(gè)對(duì)象中 Private m_pRubberBand As IRubberBand Set m_pRubberBand = New RubberLine 39。or RubberPolygon or RubberEnvelope Dim pLine As IPolyline Dim pSymbol As ISymbol Set pSymbol = New SimpleLineSymbol Dim pMxApp As IMxApplication Set pMxApp = Application Dim pDisplay As IScreenDisplay Set pDisplay = Set pLine = (pDisplay, pSymbol) Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1226 IGraphicsContainer對(duì)象 ?有 Map 和 PageLayout支持 ?也可以使用 IActiveView 的 GraphicsContainer屬性來獲得 Pa geLa y outMxDocume ntMap*I Graphic s C ont ainerI Graphic s C ont ainer?用來修改圖形元素的顯示順序 ?BringToFront, BringForward ?SendToBack, SendBackward ?PutElementOrder ?用來管理圖形元素 ?AddElement, AddElements, ? DeleteElement, DeleteAllElements Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1227 管理圖形元素 39。Remove all elements from the Map –or Layout Set pMxDoc = ThisDocument 39。Add an element to the Layout Set pMxDoc = ThisDocument Dim pGC As IGraphicsContainer Set pGC = pElemArea, 0 39。Send selected graphics to the back on Layout Dim pGCSelect As IGraphicsContainerSelect Set pGCSelect = pGC ?QI Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1228 如何刷新顯示 ?使用 IActiveView的 Refresh方法 ?刷新所有的顯示 (但是不刷新 TOC表 ) ?使用 IScreenDisplay的 Invalidate的方法 ?只刷新指定的范圍 (envelope) ?使用 IMxDocument的 UpdateContents方法 ?通報(bào)該文檔對(duì)象包含的內(nèi)容發(fā)生了變化 ?刷行了內(nèi)容表對(duì)象( TOC) Introduction to Programming ArcObjects with VBA Copyright 169。 2020, 2020 ESRI. All rights reserved. 1229 部分刷新顯示 ?也許你只需要刷新部分的顯示區(qū)域 ?被新圖形元素覆蓋的區(qū)域 ?比直接刷新整個(gè)文檔的效率高 ?使用 IActiveView的 PartialRefresh方法 ?用于 Layout 視圖或者 Data view ?指定什么需要刷新 (., graphics) ?指定哪里需要刷新 (an envelope) Copyright 169。 2020, 2020 ESRI. All rights reserved. Introduction to Programming ArcObjects with VBA Data management(III)