以前總是抱怨arcengine 難學,類庫太多,不知道如何下手,到網上也搜不到適合的例子,也不能運行例子。其實Esri爲了減少開發者學習成本,做了很多工作,我們所要做的是利用Esri提供的資源。
裝上ArcEngine 之後 在arcgis 的安裝目錄裏有這些資源:
1 /ArcGIS/DeveloperKit/SamplesNET/Engine vs 平臺下的Engine 的例子
2 /ArcGIS/DeveloperKit/SamplesNET/data Engine 例子對應的數據
3 /DeveloperKit/Diagrams ArcEngine 的類庫文檔,非常有用,關鍵是要看懂它。
4 /ArcGIS/DeveloperKit/Help Help 當安裝了Engine 和vs之後,打開 vs 的“幫助” -> 如何實現,出現幫助文檔。這也是一個很好的入門材料。
下面說說 Engine 裏面的例子。如果你用vs 打開 有些能運行,有些運行完了沒有什麼結果。如果是Form 這樣的程序,你運行完了會有windows 界面出現,有些程序是生成dll文件的。那麼有人會問如何使用dll文件,它有什麼作用?據我現在知道,生成按鈕,到處使用。
以Engine 下面的例子 ExportActiveView爲例。雙擊ExportActiveViewCS_Net2005.sln 把項目導入到vs2005 中.
在 /ExportActiveView/CSharp/ExportActiveViewCS_Net/bin/Debug 目錄下 會多出幾個文件。
其中ExportActiveViewCS_Net.dll 是我們最關心的。
當我們生成這個dll文件時,dll 文件已經註冊了。現在 打開arcmap
點擊Tools 菜單->Customize 按鈕 。點擊Commands選項卡的.點擊Developer Samples category 對話框如下
點擊 Export Active View CS 拖動它到任何合法的工具條中。結果如下
最右邊的工具條中出現了一個像兔子一樣的工具按鈕。點擊它 會產生一張jpg 圖片
運行結果如下:
這樣就算明白了 dll 文件的作用了,簡單的說就是封裝了一個工具按鈕。能在arcmap arccatalog 等各種arcgis 產品中使用 和編程中使用。
最後告訴大家 一個很好的例子 把下面的地址輸入到 vs的幫助文檔 url 中
ms-help://ESRI.EDNv9.3/NET_Engine/7bd52ed1-18ae-4aa7-8cde-e9eaed9537fe.htm
裏面詳細介紹了
Loading the ArcGIS Engine controls
Embedding the ArcGIS Engine controls in a container
License initialization using the LicenseControl
Loading map documents into MapControl and PageLayoutControl
Setting the ToolbarControl and TOCControl buddy controls
Handling form resize
Adding commands to the ToolbarControl
Creating a pop-up menu for the PageLayoutControl
Creating a palette of tools
Managing label editing in the TOCControl
Drawing shapes on the MapControl
Creating a custom tool
Customizing the ToolbarControl
Saving and loading ToolbarControl items
Printing the page layout
照着它做一遍 ,基本的開發流程就明白了