34
ArcGIS Pro SDK for .NET: An Introduction Christopher Zent

New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

ArcGIS Pro SDK for .NET:An IntroductionChristopher Zent

Page 2: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Session Overview

• Brief Overview of the Pro SDK• Main extensibility patterns

- ArcGIS Pro Module Add-ins - ArcGIS Pro Managed Configurations

• Basic asynchronous programming- Use of async and await- Introduction to QueuedTask

• Using existing ArcGIS Pro functionality in your Add-in

Page 3: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

What is the ArcGIS Pro SDK?

Page 4: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Build Add-Ins for Pro with the ArcGIS Pro SDK for Microsoft .NET

• Provides powerful capabilities for customizing and extending ArcGIS Pro• Three patterns:

- Add-Ins – Develop new tools and functionality, and customize UI- Configurations – Deeper customization, branding, start-up experience, streamline UI- Plug-in data sources – Develop new data source formats

Page 5: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

What is the ArcGIS Pro SDK for .NET?

• Development is with Microsoft Visual Studio 2015 / 2017• Includes Visual Studio project and item templates.• Installation is integrated with Visual Studio Marketplace• ArcGIS Pro API comes with ArcGIS Pro out-of-box

Page 6: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

What is the ArcGIS Pro SDK for .NET?

• ArcGIS Pro SDK features and patterns- WPF (Windows Presentation Foundation) with .NET 4.6.1 +

- MVVM pattern (Model View ViewModel)

- Asynchronous Patterns: Multiple threads

Page 7: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

What can you do with the Pro SDK?

• Framework – customize the Pro UI and manage the ribbon with context, extend with solution configurations

• Content – manage Pro project items and connections to Portal to consume and integrate online data

• Editing – develop powerful editing tools and create and manage editing operations

• Geodatabase – access file and enterprise datasets, and manage queries, searches and selections, as well as versions

• Geometry – build and manage feature geometries and perform spatial operations

• Geoprocessing – run geoprocessing tools and python scripts from add-in tools and routines

Page 8: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

What can you do with the Pro SDK?

• Layouts – build custom layouts and elements, manage layout views and selections

• Map Authoring – author maps, manage layers, define and set layer renderers

• Map Exploration – build and manage animations, control the camera and build new map tools

• Raster – work with raster datasets, layers and colorizers

• Sharing – access and search content, folders, and groups of a portal or online organization

• Tasks – access and manage Tasks within the UI

• Utility Network – create custom utility network tools, traces and workflows

Page 9: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

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:\Users\<UserName>\Documents\ArcGIS\AddIns\ArcGISPro

Page 10: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

What is an ArcGIS Pro add-in? (Continued)

• Uses a declarative-based framework (config.daml)• The Module class

- Hub and central access point for a subsystem- Similar to the Extension object used in the ArcObjects 10.x framework- Singletons instantiated automatically by the Framework

Page 11: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

ArcGIS Pro SDK for Microsoft .NET

• Many online guides, code samples and other resources• Pro APIs are growing with every release

Page 12: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Config.daml• Declarative add-in definition• Configuration file that contains framework elements (buttons, dockpane, galleries)• Can add, modify, delete any default ArcGIS Pro User Interface element• Uses XML Syntax

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

Page 13: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Demo: Building an Add-in

Page 14: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

What is an ArcGIS Pro Configuration?

• Includes all functionality of an add-in plus- Change the application title and icon- Change the application splash, start page, and about page- Conditional customization of the UI

• Packaged within a single, compressed file with a .ProConfigX file extension- C:\Users\UserName\Documents\ArcGIS\AddIns\ArcGISPro\Configurations

Default start page Custom start page

Page 15: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

What is an ArcGIS Pro Configuration?

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

- 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 16: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Demo: Configurations

Page 17: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Asynchronous Programming

• ArcGIS Pro is a multi-threaded 64 bit application

• A key motivation to use Asynchronous Programming is to keep the User Interface responsive

• There are two asynchronous programming patterns for the SDK:- Use of Async / Await functionality in C# or VB .Net

- Using the ArcGIS Pro Framework’s QueuedTask class

Page 18: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

ArcGIS Pro Internal Threading Model

• ArcGIS Pro multi-threading incorporates asynchronous language features from Microsoft

• Implements a threading infrastructure tailored to reduce complexity

• ArcGIS Pro SDK developers only need to worry about two threads: - The GUI thread – the Graphical User Interface thread- The Main CIM Thread (MCT) – A single specialized worker thread called Internally, ArcGIS Pro

uses a large number of threads for:- Rendering, data management, editing, geoprocessing- Isolated from the API and from the developer

• Simplifies coding and ensures the consistency of the ArcGIS Pro state

Page 19: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Asynchronous Programming

• To understand Pro multi-threading we have to understand two Categories of Methods in the ArcGIS Pro API- Coarse-grained asynchronous methods:

- Can be called on any thread- Once called these methods return to the caller immediately but

execute asynchronously in the background- Fine-grained synchronous methods:

- Must be called using the QueuedTask class- These methods are ‘blocking’ and return to the caller when the method

is finished doing its work

Page 20: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Coarse-Grained Methods• Can be called from any thread, usually called from the GUI thread• Coarse-grained methods execute in the background on Pro internal threads• Coarse-grained methods use the ‘Async’ naming convention:

- method names end with ‘Async’

• Caller uses the async / await semantic

//Execute a Geoprocessing Toolawait Geoprocessing.ExecuteToolAsync("SelectLayerByAttribute_management",

new string[] {"parcels","NEW_SELECTION", "description = 'VACANT LAND'"});await MapView.Active.ZoomToSelectedAsync(new TimeSpan(0, 0, 3));

Page 21: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Demo: Coarse Grained Methods

Page 22: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Fine-Grained, Synchronous MethodsSynchronous Methods Must be called using the QueuedTask class- There is a much greater number of fine grained methods and classes - No async / await. Runs on the MCT (Main CIM Thread managed by ArcGIS Pro)- Designed for use in your own coarse-grained async methods- In other words: this allows you to write your business logic as a ‘background’ task

await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>{

var layers = MapView.Active.Map.FindLayers("Parcels").OfType<FeatureLayer>().ToList();

var parcels = layers[0] as FeatureLayer;QueryFilter qf = new QueryFilter(){

WhereClause = "description = 'VACANT LAND'",SubFields = "*"

};parcels.Select(qf, SelectionCombinationMethod.New);

});

Page 23: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

QueuedTask Class • QueuedTask uses the Pro framework’s custom Task scheduler• Used to run synchronous ArcGIS Pro SDK methods in the background • Synchronous API methods that require QueuedTask are listed in the API Help

and VS IntelliSense using the following text in the description: “This method must be called on the MCT. Use QueuedTask.Run”

• Example of synchronous methods in Pro: - GetSpatialReference, QueryExtent, Geometry operations

• Usage:Task t = QueuedTask.Run(() =>{

// Call synchronous SDK methods here});

Page 24: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Demo: Fine-Grained Methods

Page 25: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Using Existing ArcGIS Pro Elements in Your Add-in

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

• Use the Unique Element Id of any existing ArcGIS Pro Control and add it to your config.daml markup

• Example: Navigate Bookmarks button (see screenshot)- DAML button references existing Element ID:

esri_mapping_bookmarksNavigateGallery

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

</group>

Page 26: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Use Existing ArcGIS Pro Commands in Your Add-in• Use the ArcGIS Pro Framework’s “GetPlugInWrapper” method with any ArcGIS Pro element’s Id

to get the IPlugInWrapper interface• All buttons implement the ICommand interface - with Execute() and CanExecute()

• Using the above pattern you can use any ArcGIS Pro button functionality in your code

// ArcGIS Pro's Create button control DAML ID.var commandId = DAML.Button.esri_mapping_createBookmark;// get the ICommand interface from the ArcGIS Pro Button// using command's plug-in wrapper// (note ArcGIS.Desktop.Core.ProApp can also be used)var iCommand = FrameworkApplication.GetPlugInWrapper(commandId) as ICommand;if (iCommand != null){

// Let ArcGIS Pro do the work for usif (iCommand.CanExecute(null))

iCommand.Execute(null);}

Page 27: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Demo: Hook Existing Commands

Page 28: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Resources

• Landing page – main resource page -

Go to pro.argis.com and click on “SDK” tab

• Doc Wiki – primary documentation site with concept and guide docs, and much more

• Community Samples – ready to use code solutions categorized by functional area

• GeoNet Pro SDK Group – developer community

• Dev Summit – best conference for training sessions

Dev Summit Session Recordings – from past Dev Summits

Page 29: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Feedback

• We need your input and feedback on the Pro SDK- New requirements and the workflows these would support

- Feedback and suggestions on the SDK documentation, code samples and snippets

• Sending feedback:

- Product manager, Chris Zent, [email protected]

- Account / Partner manager

- ArcGIS Pro SDK Group on GeoNet

Page 30: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Other Pro SDK Sessions

Time Technical Session Location

11:30 am – 12:15 pm Demonstrating Pro Extensibility with Add-Ins 209A

4:30 pm - 5:15 pm Demonstrating Pro Extensibility with Add-Ins 209B

Page 31: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

ArcGIS Security Update – TLS 1.2

• Esri is committed to using the latest industry standards and best practices for security protocols

• On April 16, 2019, we are updating ArcGIS Online to enforce the use of TLS (Transport Layer Security) version 1.2

• What Does This Mean For You?- Users of most ArcGIS software or custom solutions using Esri technology may be affected

by this planned update - If you have not updated and validated your system's support for TLS v1.2 only, you may lose your ability to connect to ArcGIS Online.

• What Do You Need to Do?- Go to the Esri TLS Support page for information, patches, and instructions for updating

software:

support.esri.com/en/tls

Page 32: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Please Take Our Survey on the AppDownload the Esri Events app and find your event

Select the session you attended

Scroll down to find the feedback section

Complete answersand select “Submit”

Page 33: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS

Questions?

Page 34: New ArcGIS Pro SDK for .NET:An Introduction · 2019. 3. 14. · Session Overview • Brief Overview of the Pro SDK • Main extensibility patterns-ArcGIS Pro Module Add -ins -ArcGIS