【文章內(nèi)容簡介】
ment As IElement = textElement Dim elementProperties as IElementProperties elementProperties = element = Date Name = point Dim graphicsContainer As IGraphicsContainer graphicsContainer = (element,0) () End Sub 39。Find the element by name later Dim pageLayoutControl2 As IPageLayoutControl2 pageLayoutControl2 = m_element = (Date Name) Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 317 顯示選擇的 elements ?使用 SelectionTracker 來顯示 elements ?兩步 ?選擇元素 ?繪制 ?OnAfterDraw 39。 Select the element Dim graphicsContainerSelect As IGraphicsContainerSelect graphicsContainerSelect = (m_element) (esriViewDra, Nothing, Nothing) Private Sub AxPageLayoutControl1_OnAfterDraw(…) Handles If ( = ) Then If (m_element Is Nothing) Then Exit Sub 39。Draw with element as selected Dim selectionTracker As ISelectionTracker selectionTracker = (, 0, ) End If End Sub Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 318 打印版面視圖 ? IPageLayoutControl2 ? Page ? Printer ? PrinterPageCount ? PrintPageLayout () If Not Is Nothing Then 39。Set the page size = 39。Portrait orientation = 1 39。Determine page count Dim pageCount as Integer = () 39。Print page range (1,pageCount,) End If Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 319 使用地圖文檔 ? MXD 文件是結(jié)構(gòu)化的存儲文檔 ?通常由 ArcMap創(chuàng)建 ?包含持久對象 ?Maps, Layers, PageLayout, … ? MapDocument 使以下成為可能 (例子代碼SaveMapDocument) ?讀取 mxd, lyr, mxt, and pmf files ?寫新的 mxd files ?訪問 map document的內(nèi)容 Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 320 IMapDocument: 打開和保存 ?讀取和寫地圖文檔的成員函數(shù) ? Open: 打開已經(jīng)存在的地圖文檔 (mxd, mxt, lyr, pmf) ? SaveAs: 保存當(dāng)前文檔到新的文件 Public Sub OpenDocument(ByRef sFilePath As String) m_pMapDocument = New MapDocument 39。Create a new map document (sFilePath) 39。Open the map document selected 39。Set the PageLayoutControl page layout to the map document page layout = End Sub Private Sub cmdSaveAs_Click(…) Handles … sFilePath = If sFilePath = Then SaveDocument() 39。Save changes to the current document Else (sFilePath, True) 39。SaveAs a new document with relative paths OpenDocument(sFilePath) 39。Open document MsgBox(Document saved successfully!, , Saved Document) End If End Sub Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 321 IMapDocument:新建和保存 ?讀取和寫地圖文檔的成員函數(shù) ? New: 用給定的名稱( mxd) 創(chuàng)建地圖文檔 ? Save: 保存內(nèi)容到當(dāng)前文檔 Private m_pMapDocument As IMapDocument Private Sub btnNewCmd_Click(…) Handles = Save Map Document = Map Documents (*.mxd)|*.mxd = C:\Temp\ () () End SubPublic Sub SaveDocument() If () = True Then MsgBox(This map document is read only!, , Save Failed) Exit Sub End If 39。Save with the current relative path setting () MsgBox(Changes saved successfully!, , Saved Document) End Sub Developing Applications with ArcGIS Engine Copyright 169。 2022 ESRI. All rights reserved. 322 訪問地圖文檔中的對象 ?控件可以直接引用對象 (Map and PageLayout) 或訪問自己的拷貝 ? Reference ?直接 ? Copy ?使用 ObjectCopy 避免共享引用 ?深度復(fù)制 = (0) = Dim objCopy As IObjectCopy = New ObjectCopy = ((0)) = () Deve