arcgis pro sdk for .net: learning customization and ... · arcgis pro managed configurations- ......

33
Mark Jagt & Maarten van Hulzen ArcGIS Pro SDK for .NET: Learning Customization and Extensibility

Upload: others

Post on 11-Jul-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Mark Jagt & Maarten van Hulzen

ArcGIS Pro SDK for .NET:Learning Customization and Extensibility

Page 2: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

What is the ArcGIS Pro SDK for .NET?

• ArcGIS Pro SDK for .NET extends ArcGIS Pro using .NET• Extensibility patterns provided by Pro SDK:

- ArcGIS Pro Module Add-ins - ArcGIS Pro Managed Configurations- ArcGIS Pro Plug-in Datasource (new in Pro 2.3)- ArcGIS Pro CoreHost Application

• Includes Visual Studio item templates for most UI elements• Installation is integrated with Visual Studio Marketplace• ArcGIS Pro API comes with ArcGIS Pro out-of-box

- File based references (No Global Assembly Cache)

Page 3: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

What is the ArcGIS Pro SDK for .NET?

• ArcGIS Pro SDK features and patterns• 64-bit platform• UI based on WPF (Windows Presentation Foundation) / .NET 4.6.1 +- Note: .NET 4.8 at ArcGIS Pro release 2.5

• MVVM pattern (Model-View-ViewModel)• Asynchronous Patterns: Multiple threads

Page 4: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

What is an ArcGIS Pro add-in ?

• Extends ArcGIS Pro through:- Buttons- Tools- Dockpanes- Embeddable control- ..

• Packaged within a single, compressed file with an .esriaddinX file extension

- c:%Homepath%\Documents\ArcGIS\AddIns\ArcGISPro

Page 5: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

GUI - Ribbon

• 1 Ribbon- Multible Tabs

- Multiple Groups- Multiple Controls

Page 6: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

GUI – Context aware

Page 7: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

What are the ArcGIS Pro Add-in core components?

• Declarative-based framework to define the UI elements - Declarative framework is defined in a config.daml file- XML formatted, contains ArcGIS Pro framework elements (buttons,

dockpane, galleries) and Add-in UI elements• The Module class

- Hub and central access point for each add-in- Similar to the Extension object used in the ArcObjects 10.x

framework- Singletons instantiated automatically by the Framework

Page 8: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Demo: Add-in

Page 9: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

<ArcGIS defaultAssembly="WorkingWithDAML.dll" defaultNamespace="WorkingWithDAML"xmlns="http://schemas.esri.com/DADF/Registry"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://schemas.esri.com/DADF/Registryfile:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">

<AddInInfo id="{c6226a24-d69b-46c6-b5e7-9eee4ddad45d}" version="1.0" desktopVersion="1.1.2850">…</AddInInfo><modules>

<insertModule id="WorkingWithDAML" className="Module1" autoLoad="false" caption="Module1"><tabGroups>

<!--The new Tab Group is created here--><tabGroup caption="Example State Solution" id="working_with_DAML_ExampleStateTabGroup">

<color A="255" R="238" G="170" B="90" /><borderColor A="0" R="251" G="226" B="195" />

</tabGroup></tabGroups>

Declarative Markup for Pro UI Elements: DAML• Add-Ins use “Declarative Markup” (DAML) language for UI Elements

- Buttons, Dockpane, Galleries, Property Sheets, Tools, …

• DAML uses XML Syntax - stored in a Config.daml file• Using DAML, you can add, modify, delete any User Interface element • Pro also uses DAML: <Install Location>\bin\Extensions folder

Page 10: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Declarative Markup for Pro UI Elements: DAML• DAML is transactional and is processed in the order the Pro Extension or Add-in is

loaded- 3 distinct actions: Insert, Update, and Delete- The type of action is determined by the element name: updateModule, updateGroup,

deleteButton

<updateModule refID="esri_mapping"><groups>

<updateGroup refID="esri_mapping_navigateGroup"><deleteButton refID="esri_mapping_bookmarksNavigateGallery“ /><insertButton refID="working_with_DAML_ToggleStateButton" />

</updateGroup></groups>

</updateModule>

In the DAML transactional model the ‘last’ transaction wins !

Page 11: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

How to use existing Pro UI elements in Your Add-in

• Use any existing ArcGIS Pro framework elements on your Add-in tab including Buttons, Tools, Galleries

• Find the Unique Element Id of any existing ArcGIS Pro Control and use the Id in your config.daml markup to add, delete, modify that Element

• Example: Add Pro’s Navigate Bookmarks button to my Add-in toolbar- button tag references existing Element ID:

esri_mapping_bookmarksNavigateGallery

<group id="HookingCommands_Group1" caption="Hooking Commands" keytip="G1"><button refID="esri_mapping_bookmarksNavigateGallery" />

</group>

Page 12: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

How to find Exiting ArcGIS Pro Element Ids

• SDK Help: ArcGIS Pro DAML ID Referencehttps://github.com/Esri/arcgis-pro-sdk/wiki/ArcGIS-Pro-DAML-ID-Reference

• Pro Generate DAML Ids tool in Visual Studio- Allows Intellisense to find Ids:

i.e. DAML.Button.esri_mapping_addDataButton

• ArcGIS Pro ‘Customize the Ribbon’: Show IDs option

Page 13: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

States en conditions (1)

• Make the add-in “context-aware”

• A State can be activated

Page 14: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

States en conditions (2)

• Conditions:Can be True if one or more states are activated or deactivated

Page 15: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

States en conditions (3)

• Conditions:Can be True if one or more states are activated or deactivated

- UI Elements can react to this

Page 16: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

WorkingWithDAML project

Demo: Add-in using ArcGIS Pro Buttons, States & Conditions

Page 17: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

What is an ArcGIS Pro Managed Configuration?

• Includes all functionality of an add-in plus- Change the application title and icon- Change the application splash, start page, and about page- Optionally customize and streamline the UI (the Pro Ribbon) for a specific workflow

• Packaged within a single, compressed file with a .ProConfigX file extension- c:%Homepath%\Documents\ArcGIS\AddIns\ArcGISPro\Configurations

Default start page Custom start page

Page 18: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

What is an ArcGIS Pro Managed Configuration?(Continued)

• Running an ArcGIS Pro Managed Configuration- Use the ArcGIS Pro “/config” command-line option or shortcut

- Only one configuration can run per instance of Pro

• ConfigurationManager class - Defined in DAML (generated automatically by the template)- Provides a set of methods by which a developer can override “that” aspect of Pro

public abstract class ConfigurationManager {protected internal virtual Window OnShowSplashScreen();protected internal virtual FrameworkElement OnShowStartPage();protected internal virtual FrameworkElement OnShowAboutPage();...

C:\ArcGIS\bin\ArcGISPro.exe /config:Acme

Page 19: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Demo: Configurations

Page 20: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

What is an ArcGIS Pro CoreHost Application?

• Stand-alone application with a subset of Pro Assemblies- ArcGIS.CoreHost assembly – API to manage CoreHost functions- ArcGIS.Core assembly – Includes Geodatabase and Geometry

classes• CoreHost Applications have 64-bit access to

- Geodatabase and - Geometry classes used by ArcGIS Pro

• CoreHost Applications can be - Windows Console application - WPF application

Page 21: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

How to create an ArcGIS Pro CoreHost Application

• CoreHost Project Template for Console 64 bit application (optional WPF standalone application)

• Uses COM single-threaded apartment (STA) threading model • ArcGIS Pro has to be installed & licensed• Call Host.Initialize ()

Page 22: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

C:\Data\Admin\AdminData.gdb

Demo: CoreHost Sample App

Page 23: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

What is an ArcGIS Pro Plugin DataSource?

• ArcGIS Pro supports data from a large variety of data sources and formats from shape files to Oracle databases, but not all formats are supported

• The Plugin Datasource framework allows developers to make custom datasources available for use in Pro- Access in Pro is read-only- Access is in form of tables or feature classes- Access is file based (my data source is a file)

• Plugin DataSources allow access to other data sources like relational databases such as MySQL, non-relational databases such as MongoDB, and a myriad of other proprietary or obscure file-based data stores

Page 24: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Examples of Custom data sources

• SQL Server Express- An example of a free relational database that contains data copied

from classic personal geodatabases • Jpg photos with GPS metadata

- Smart phone and digital cameras have the option to capture GPS information when a photo is taken

• Gpx File data- GPX (the GPS eXchange Format) is a data format for exchanging

GPS data between programs and implemented by many GPS tracking devices

Page 25: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Providing a plugin datasource for your custom data

• First a look at how basic high-level data access objects work in ArcGIS Pro:- Datasource is a specific instance of a data store

- Used to open one or more tables or feature classes- Tables or Feature classes contain data rows

- Can be queried and return a cursor- Cursors can be used to iterate through data rows

Page 26: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Implementing plugin datasource for your custom data

• The Plugin Project Template will stub out all code for you• Create three concrete classes that inherit from these API classes

- PluginDatasourceTemplate- Used to manage one or more tables or feature classes

- PluginTableTemplate- Can be queried and return a cursor

- PluginCursorTemplate- Data Rows are returned by iterating using a cursor

• Update config.daml to register your Plugin Datasource with ArcGIS Pro

<ArcGISPro><PluginDatasources><PluginDatasource id="MyPluginDatasource" class="MyPluginDatasourceTemplate" />

</PluginDatasources></ArcGISPro>

Page 27: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Using a custom plugin datasource in ArcGIS Pro• Define a connection to a data source instance

- Use PluginDatasourceConnectionPath with the PluginDataSource name and the path to the data source file

• Use the connection to create a datastore to your data source instance• Use the datastore to access tables and feature classes

var conDb = new PluginDatasourceConnectionPath("MyPluginDatasource", filePathUri);QueuedTask.Run(() =>{

using (var pluginDb = new PluginDatastore(conDb)){

foreach (var tableName in pluginDb.GetTableNames()){

using (var fc = pluginDb.OpenTable(tableName) as FeatureClass){

//Add as a layer to the active map or sceneLayerFactory.Instance.CreateFeatureLayer(fc, MapView.Active.Map);

}}

}});

Page 28: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Demo: Plugin DataSource Sample

Page 29: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

ArcGIS Pro SDK for .NET – Technical Sessions

Date Time Session Location

Mon, Nov 04 1:00 pm – 1:45 pm Learning Customization and Extensibility Salon Durieux

Tue, Nov 05

9:00 am – 9:45 am Understanding the CIM, a Guide for Developers Salon Humboldt

2:00 pm – 2:45 pm Intermediate Editing Salon Durieux

4:00 pm – 4:45 pm Advanced Customization Patterns Salon Durieux

Wed, Nov 06 2:00 pm – 2:45 pm Learning Customization and Extensibility Salon Humboldt

Page 30: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Complete answersand select “Submit”

Scroll down to find the feedback section

Select the session you attended

Download the Esri Events app and find your event

Please Take Our Survey on the App

Page 31: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

https://esrinederland.github.io

Page 32: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework

Learning Customization and Extensibility

• Questions?

- https://github.com/esri/arcgis-pro-sdk/wiki/tech-sessions#2019-berlin

Page 33: ArcGIS Pro SDK for .NET: Learning Customization and ... · ArcGIS Pro Managed Configurations- ... • Declarative-based framework to define the UI elements -Declarative framework