目錄
1、基本介紹
使用ArcGIS Pro SDK for .Net能夠對ArcGIS Pro進行擴展。ArcGIS Pro SDK for .Net基於Add-in和配置擴展的方式進行開發。結合net的一些新特性譬如Task異步(TAP)、LINQ、WPF Binding和MVVM等使用Pro API編寫2D/3D插件
2、開發要求
2.1 ArcGIS Pro
最高版本2.2。
之前的版本:
2.2 支持的操作系統
- Windows 10 (Home, Pro, Enterprise) (64 bit)
- Windows 8.1 (Pro, and Enterprise) (64 bit)
- Windows 7 SP1 (Ultimate, Professional and Enterprise) (64 bit)
2.3 .Net FrameWork
Microsoft .NET Framework 4.6.1 Developer Pack
下載地址:https://www.microsoft.com/net/download/thank-you/net461-developer-pack
2.4、IDE
- Visual Studio 2017 (Professional, Enterprise, and Community Editions)
- Visual Studio 2015 (Professional, Enterprise, and Community Editions)
3、安裝ArcGIS Pro SDK for .Net
- 打開VS2015在工具-擴展和更新界面下載,下載後重啓VS。
- 說明:
Name |
File |
Functionality |
ArcGIS Pro SDK for .NET |
proapp-sdk-templates.vsix |
創建ArcGIS Pro插件的項目和項目模板集合 |
ArcGIS Pro SDK for .NET (Utilities) |
proapp-sdk-utilities.vsix |
幫助創建ArcGIS Pro插件的工具集合 |
- 模板安裝成功
- SDK更新:
4、ArcGIS Pro API
ArcGIS Pro API分爲三部分:核心API、ExtentionAPI、ESRI未發佈的API。
常見問題解答:https://github.com/Esri/arcgis-pro-sdk/wiki/FAQ
4.1 核心程序集
核心程序集存放在目錄: {ArcGIS Pro Installation folder}\bin.
Assembly |
Description |
ArcGIS.Core.dll |
提供CIM、地理數據庫、幾何和實用網絡api。 |
ArcGIS.CoreHost.dll |
Provides Host.Initialize to initialize ArcGIS.Core.dll for stand-alone use. |
ArcGIS.Desktop.Framework.dll |
提供應用程序框架,包括插件契約、DAML支持和基類。這個程序集必須被每個插件引用。 |
4.2 擴展程序集
ArcGIS Pro的一些子系統組織爲Extention單元,存放在目錄: {ArcGIS Pro Installation folder}\bin\Extensions 以及其子目錄。
Assembly |
Description |
ArcGIS.Desktop.Catalog.dll |
Provides access to project content items (map items, layout items, style items, folder items, and so on). |
ArcGIS.Desktop.Core.dll |
Provides functionality to create and manage projects, access to events associated with the current project, and the ability to execute geoprocessing tools. |
ArcGIS.Desktop.DataReviewer.dll |
Provides functionality to establish and manage Reviewer Results, Sessions and Batch Jobs in a project. |
ArcGIS.Desktop.Editing.dll |
Provides access to the editing environment and core editing functionality required for custom edit tool implementations. |
ArcGIS.Desktop.Extensions.dll |
Provides extension methods for other ArcGIS Pro classes. Provides a base class for custom map tools. |
ArcGIS.Desktop.Geoprocessing.dll |
Provides access to geoprocessing history items stored in the project. (Note: Adds a reference to ArcGIS.Desktop.Core.dll to execute geoprocessing tools.) |
ArcGIS.Desktop.Layouts.dll |
Provides functionality for manipulating elements on a layout and exporting to a variety of image formats. |
ArcGIS.Desktop.Mapping.dll |
Provides types to create maps and layers, label features, perform query operations, and visualize them in 2D or 3D. Provides a raster API to create raster layers and customize raster rendering, and an API to manage styles, style items, and symbols. |
ArcGIS.Desktop.TaskAssistant.dll |
Provides the Tasks framework, allowing developers to access, open, close, or export task items. |
ArcGIS.Desktop.Workflow.dll |
Provides functionality to create, configure, and execute Workflow Manager jobs and queries. Provides functionality to retrieve configuration information from the Workflow Manager database. |
5、ArcGIS Pro 配置
5.1 DAML介紹
DAML是Desktop Application Markup Language的縮寫。是ESRI基於XML標準自定義的UI配置文件。插件和配置的聲明性部分是在DAML文件中定義的,其中包含了描述應用程序術語中的定製的框架元素(主要是插件)的集合。聲明性部分還包含框架所需的信息,以便在適當的時候激活(創建)相關的對象。
這種對聲明性和編程方面的分析增加了靈活性,簡化了定製的部署和分發,減少了需要編寫的代碼量,並更好地利用了即時(JIT)策略來實現智能激活和資源利用。
5.2 DAML元素介紹
參考地址:https://github.com/Esri/arcgis-pro-sdk/wiki/ArcGIS-Pro-DAML-ID-Reference
5.3 根節點介紹
defaultAssembly:該配置代表的插件所在的程序集名稱。
defaultNamespace:該配置代表的插件所在的命名空間名稱。
5.4 Module節點介紹
模塊作爲其子系統的中心和中心訪問點;如果您需要訪問子系統中的功能,那麼就從模塊開始。模塊是由框架自動實例化的單例,當在執行代碼中顯式地請求訪問時,或者當模塊因上下文切換而變得“相關”時。作爲模塊一部分的所有程序元素都被顯式地聲明爲;這些元素包括ribbon按鈕、工具、畫廊、組合框、編輯框、調色板和其他控件,以及應用程序窗格和對接窗格。
模塊是在根ArcGIS元素中聲明的,但是必須在模塊的容器元素中進一步封裝。自動加載器屬性用於控制模塊是否加載及時(JIT)——默認值——或者在應用程序啓動時自動加載。在幾乎所有的情況下,自動加載都應該被設置爲假。
5.5 條件和狀態
狀態被命名爲布爾值,它表示應用程序整體狀態的一個特定方面;例如,一個特定的視圖是否活動,或者是否選擇了特定類型的特性。狀態被聲明爲使用普通字符串。爲了避免名稱衝突,它們通常使用插件命名約定來命名。
條件是由一個或多個狀態組成的DAML表達式,例如(A或B),其中A和B都是狀態。條件本身被命名,以便它們可以被那些允許使用條件的DAML元素引用;例如,當一個地圖視圖處於活動狀態時,一個定製的ribbon選項卡可以自動顯示出來,並且當任何其他類型的視圖都處於活動狀態時,它就會被隱藏起來。
示例:
5.6 Plug-ins
一些定製,比如菜單,純粹是聲明性的——它們在DAML中的定義是框架創建和呈現它們所必需的。然而,大多數定製都有一個活動的(後臺代碼)組件,其中大部分都是從通用基類插件繼承的。
5.7 刪除已有功能
5.7.1 介紹
DAML中CT_Delete類型用於刪除已經定製的功能、選項卡、菜單等等。
5.7.2 示例:刪除Tab頁中的分組
deleteTab元素聲明爲CT_Delete元素,用於刪除Tab頁。
- 原有配置
定義收藏夾分組的Pro配置文件及配置內容。
- 自定義配置
注意:updateModule的refID必須是原有定義該分組的insertModule的ID。
- 最終Pro界面效果
5.8 替換已有功能
5.8.1 介紹
Pro已有功能可能不符合我們的思維方式或者業務情況,我們可以開發自己相同命令或者工具替換掉原有的工具。
以自定義圖層菜單中屬性功能爲例:
備註:我期待的是在自己的配置中使用updateModule、updateMenu、updateButton來替換Pro的功能,不知爲何使用updateButton節點無法替換已有的按鈕,以下是在自定義的配置中的配置內容,其中必有玄機。
5.8.2 更新圖層菜單的屬性選項
假如圖層菜單的屬性選項不符合我們的要求,需要重新定製開發。
(1)打開圖層菜單配置
Pro配置ADMapping.daml定義了打開圖層快捷菜單。
(2)在自定義的配置文件中新增自定義屬性按鈕
(3) 在Pro的ADMapping中配置
(4)最終效果(隱藏原有功能)
6、 項目設置
6.1 目標框架
6.2 目標平臺
AnyCPU和x64都行。
6.3 調試設置
調試時啓動ArcGIS Pro進行調試。
7、 參考文檔及地址
ESRIwiki文檔:https://github.com/esri/arcgis-pro-sdk/wiki#requirements
ArcGIS Pro幫助文檔:http://pro.arcgis.com/zh-cn/pro-app/sdk/
ArcGIS Pro API參考:http://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic1.html