ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI...

34
Sean Jones Narelle Chedzey ArcGIS Pro SDK for .NET Advanced Editing with Focus on UI Customization

Transcript of ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI...

Page 1: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Sean JonesNarelle Chedzey

ArcGIS Pro SDK for .NETAdvanced Editing with Focus on UI Customization

Page 2: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Session Overview

• Create construction tool• Create construction tool with tool options• Create an editing tool

- Using the sketch- Placing in the modify features pane- Providing a UI for the tool

Page 3: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Construction tools create features- Appear under each feature template in the Create Features Pane

- Use the sketch to create a geometry- Examples: Line, Polygon, Trace, Circle

• Editing tools- Appear on the ribbon or the Modify Features Pane

- Use the sketch to provide geometry for an EditOperation- Examples: Split, Reshape

Editing customizations

Page 4: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Construction Tool – Implementation• Implement using the Pro SDK “Construction Tool” Item Template:

Page 5: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Change construction tool type by modifying the DAML categoryRefID (geometry type of destination feature class).

• Supported categories are- esri_editing_construction_point- esri_editing_construction_polyline- esri_editing_construction_polygon- esri_editing_construction_multipoint- esri_editing_construction_annotation- esri_editing_construction_dimension

Construction Tool – config.daml

<controls><tool id="SimpleConstructionTool" categoryRefID="esri_editing_construction_point"

caption="SimpleConstructionTool"className="SimpleConstructionTool" loadOnClick="true"smallImage="Images\GenericButtonRed16.png" largeImage="Images\GenericButtonRed32.png">

<tooltip heading="ArcGIS Pro SDK">Default construction tool.<disabledText /></tooltip></tool>

<controls>

Page 6: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Construction Tool – tool file

internal class SimpleConstructionTool : MapTool{

public SimpleConstructionTool (){

IsSketchTool = true;UseSnapping = true;SketchType = SketchGeometryType.Point;

}

/// Called when the sketch finishes. This is where we will create the sketch operation and then execute it.protected override Task<bool> OnSketchCompleteAsync(Geometry geometry){

if (CurrentTemplate == null || geometry == null)return Task.FromResult(false);

// Create an edit operationvar createOperation = new EditOperation();createOperation.Name = string.Format("Create {0}", CurrentTemplate.Layer.Name);createOperation.SelectNewFeatures = true;

createOperation.Create(CurrentTemplate, geometry);return createOperation.ExecuteAsync();

}}

Page 7: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• In the Config.daml, tool is registered in the relevant construction tool category via categoryRefID

- Adds your tool to the correct Create Pane construction tool palettes- Category should match your destination feature class.

• Supported categories are- esri_editing_construction_point, esri_editing_construction_polyline- esri_editing_construction_polygon, esri_editing_construction_multipoint- esri_editing_construction_annotation, esri_editing_construction_dimension

Construction Tool – Palette Placement

<controls><tool id="ConstructionFacilitiesTool" categoryRefID="esri_editing_construction_point"

caption="ConstructionFacilitiesTool" ...></tool>

<controls>

Page 8: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• In the Config.daml, tool is registered in the relevant construction tool category via categoryRefID

- Adds your tool to the correct Create Pane construction tool palettes- Category should match your destination feature class.

• Supported categories are- esri_editing_construction_point, esri_editing_construction_polyline- esri_editing_construction_polygon, esri_editing_construction_multipoint- esri_editing_construction_annotation, esri_editing_construction_dimension

Construction Tool – Palette Placement

<controls><tool id="ConstructionFacilitiesTool" categoryRefID="esri_editing_construction_point"

caption="ConstructionFacilitiesTool" ...></tool>

<controls>

Page 9: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• In the Config.daml, tool is registered in the relevant construction tool category via categoryRefID

- Adds your tool to the correct Create Pane construction tool palettes- Category should match your destination feature class.

• Supported categories are- esri_editing_construction_point, esri_editing_construction_polyline- esri_editing_construction_polygon, esri_editing_construction_multipoint- esri_editing_construction_annotation, esri_editing_construction_dimension

Construction Tool – Palette Placement

<controls><tool id="ConstructionFacilitiesTool" categoryRefID="esri_editing_construction_point"

caption="ConstructionFacilitiesTool" ...></tool>

<controls>

Page 10: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Control placement on the palette with a <content … /> child element in the Config.daml

- Add a placeWith=daml_id, insert=before | after attribute- Default placement is “after” if no insert attribute is specified.

Construction Tool – Palette Placement

<controls><tool id="ConstructionFacilitiesTool" categoryRefID="esri_editing_construction_point"

caption="ConstructionFacilitiesTool" ...><content insert="before" placeWith="esri_editing_SketchPointTool"/>

</tool><controls>

Page 11: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Control placement on the palette with a <content … /> child element in the Config.daml

- Add a placeWith=daml_id, insert=before | after attribute- Default placement is “after” if no insert attribute is specified.

Construction Tool – Palette Placement

<controls><tool id="ConstructionFacilitiesTool" categoryRefID="esri_editing_construction_point"

caption="ConstructionFacilitiesTool" ...><content insert="before" placeWith="esri_editing_SketchPointTool"/>

</tool><controls>

Page 12: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Control placement on the palette with a <content … /> child element in the Config.daml

- Add a placeWith=daml_id, insert=before | after attribute- Default placement is “after” if no insert attribute is specified.

Construction Tool – Palette Placement

<controls><tool id="ConstructionFacilitiesTool" categoryRefID="esri_editing_construction_point"

caption="ConstructionFacilitiesTool" ...><content insert="before" placeWith="esri_editing_SketchPointTool"/>

</tool><controls>

Page 13: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Construction Tool

Demo

Page 14: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Custom UI for providing configurable “settings” for use with your construction tool edits

- Eg default buffer distance, proximity distance, use of overrides, etc.- Hosted on the Active Template pane when its related construction tool(s) is/are

activated*

- Implement using an Embeddable Control (Pro SDK item template)

- *And/or on Template Properties Dialog to persist custom settings in the template

Construction Tool – Tool Option UI

Page 15: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Procedure- Add an Embeddable Control (run the Pro SDK item template)- Register Embeddable control in the esri_editing_tool_options category in the Config.daml- Implement the UI (standard WPF)- Implement IEditingCreateToolControl (on the embeddable control)

Construction Tool – Tool Option UI

Page 16: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Add an EmbeddableControl. • Update daml

- embeddable control is registered with "esri_editing_tool_options"- Add toolOptionsID attribute to content tag for tool

Construction Tool with Options

<controls><tool id="ConstructionToolWithOptions_BufferedLineTool" categoryRefID="esri_editing_construction_polygon"

caption="Buffered Line" className="BufferedLineTool" loadOnClick="true"smallImage="Images\GenericButtonRed16.png" largeImage="Images\GenericButtonRed32.png" >

<tooltip heading="Buffered Line">Create a polygon with a fixed buffer.<disabledText /></tooltip><content toolOptionsID="ConstructionToolWithOptions_BufferedLineToolOptions" />

</tool></controls><categories><updateCategory refID="esri_editing_tool_options">

<insertComponent id="ConstructionToolWithOptions_BufferedLineToolOptions"className="BufferedLineToolOptionsViewModel">

<content className="BufferedLineToolOptionsView" /></insertComponent>

</updateCategory></categories>

Page 17: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• ViewModel file- Implement IEditingCreateToolControl

- InitializeForActiveTemplate, InitializeForTemplateProperties methods provide a ToolOptionsvariable – collection of key-value pairs for option values

Construction Tool with Options

private ToolOptions ToolOptions { get; set; }

/// <summary>/// Called just before ArcGIS.Desktop.Framework.Controls.EmbeddableControl.OpenAsync/// when this IEditingCreateToolControl is being used within the ActiveTemplate pane./// </summary>/// <returns>true if the control is to be displayed in the ActiveTemplate pane.. False otherwise</returns>bool IEditingCreateToolControl.InitializeForActiveTemplate(ToolOptions options) {// assign the current optionsToolOptions = options;// initialize the viewInitializeOptions();return true; // true <==> do show me in ActiveTemplate; false <==> don't show me

}

Page 18: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• ViewModel file- View elements bind to properties in the ViewModel which add or update values to

ToolOptions

Construction Tool with Options

// binds in xamlprivate double _buffer;public double Buffer {get { return _buffer; }set {

if (SetProperty(ref _buffer, value)) {_isDirty = true;// add/update the buffer value to the tool optionsif (!ToolOptions.ContainsKey(BufferOptionName))

ToolOptions.Add(BufferOptionName, value);else

ToolOptions[BufferOptionName] = value;// ensure options are notifiedNotifyPropertyChanged(BufferOptionName);

}}

}

Page 19: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Tool file- Get options from the CurrentTemplate and use within the OnSketchCompleteAsync

Construction Tool with Options

private ReadOnlyToolOptions ToolOptions => CurrentTemplate?.GetToolOptions(ID);

private double defaultBuffer = 20;private double BufferDistance => (ToolOptions == null) ? defaultBuffer :

ToolOptions.GetProperty("BufferDistance", defaultBuffer);

protected override Task<bool> OnSketchCompleteAsync(Geometry geometry) {// Create an edit operation...

// create the buffered geometryGeometry bufferedGeometry = GeometryEngine.Instance.Buffer(geometry, BufferDistance);// Queue feature creationcreateOperation.Create(CurrentTemplate, bufferedGeometry);

// Execute the operationreturn createOperation.ExecuteAsync();

}

Page 20: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Construction Tool – Tool Options

Demo

Page 21: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Editing Tools – Using the Sketch• Map Tool (aka “Sketch Tool”) used for editing features

- By convention, hosted on the ribbon- Uses the sketch geometry to edit features

- Integrate in Edit Operation, Inspector- Can host on the Modify Features Dockpane via Config.daml

Page 22: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Use Visual Studio Map Tool template• To add the editing tool to the Modify Features pane

- Set CategoryRefID attribute to “esri_editing_CommandList”- Set group attribute in content element

Editing Tool

<controls><tool id="InspectorTool_UseInspectorTool" caption="Select Inspector Tool"

loadOnClick="true" className=“UseInspectorTool"smallImage="Images\GenericButtonRed16.png"largeImage="Images\GenericButtonRed32.png"categoryRefID="esri_editing_CommandList"><tooltip heading="Inspector Tool">Select point features and explore/modify the attributes.<disabledText /></tooltip>

<content L_group="Pro SDK Samples" /></tool>

</controls>

Page 23: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• To add the editing tool to the Edit Tools gallery favorites- Set values for gallery2d and gallery3d attributes in content element

Editing Tool

<controls><tool id="InspectorTool_UseInspectorTool" caption="Select Inspector Tool"

loadOnClick="true" className=“UseInspectorTool"smallImage="Images\GenericButtonRed16.png"largeImage="Images\GenericButtonRed32.png"categoryRefID="esri_editing_CommandList"><tooltip heading="Inspector Tool">Select point features and explore/modify the attributes.<disabledText /></tooltip>

<content L_group="Pro SDK Samples" gallery2d="true" gallery3d="false"/></tool>

</controls>

Page 24: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• MapTool class has properties for specifying WPF User controls- ControlID – sets the DAML-ID for an Embedded control- EmbeddableControl – retrieves the ViewModel

Editing Tool – Embedding UI into Modify Features pane

Page 25: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Add an ArcGIS Pro Embeddable Control template in your add-in.- Updates the “esri_embeddableControls” category in Config.daml- DAML follows Pro MVVM pattern

• Set the ControlID property to the id.

Editing Tool – Embedding UI into Modify Features pane

<categories><updateCategory refID="esri_embeddableControls"><insertComponent id="InspectorTool_AttributeControl"

className="AttributeControlViewModel"><content className="AttributeControlView" />

</insertComponent></updateCategory>

</categories>

public UseInspectorTool() : base(){

IsSketchTool = true;SketchType = SketchGeometryType.Rectangle;SketchOutputMode = SketchOutputMode.Map;ControlID = "InspectorTool_AttributeControl";

}

Page 26: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Access the ViewModel and set or retrieve properties.

Editing Tool – Embedding UI into Modify Features pane

private void UpdateEmbeddableControl(string someText) {if (_vm == null) {

_vm = this.EmbeddableControl as SketchToolControlViewModel;}

vm.TheText = someText;}

Page 27: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Edit Operations – Relationships

• New at 2.5• Use EditOperation.Create(RelationshipDescription) to create a relationship between

an origin and destination row.- Previously would use Core.Data API RelationShipClass.CreateRelationship()

Page 28: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Editing tool

Demo

Page 29: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

• Create construction tool• Create construction tool with tool options• Create an editing tool

- Using the sketch- Placing in the modify features pane- Providing a UI for the tool

Session Summary

Page 30: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

ArcGIS Pro SDK for .NETBeginning Editing with Focus on EditOperation

• Questions?

- https://github.com/esri/arcgis-pro-sdk/wiki/tech-sessions#2020-palm-springs

Page 31: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Presenter Names

Presentation Title

Page 32: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction
Page 33: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Section SubheadSection Header

Page 34: ArcGIS Pro SDK for .NET: Advanced Editing with Focus on ......Advanced Editing with Focus on UI Customization Session Overview • Create construction tool • Create construction

Presenter(s)Demo Title