目录
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