arcgis pro sdk for .net: advanced editing with focus on ......advanced editing with focus on ui...
TRANSCRIPT
Sean JonesNarelle Chedzey
ArcGIS Pro SDK for .NETAdvanced Editing with Focus on UI Customization
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
• 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
Construction Tool – Implementation• Implement using the Pro SDK “Construction Tool” Item Template:
• 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>
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();
}}
• 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>
• 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>
• 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>
• 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>
• 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>
• 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>
Construction Tool
Demo
• 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
• 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
• 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>
• 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
}
• 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);
}}
}
• 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();
}
Construction Tool – Tool Options
Demo
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
• 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>
• 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>
• 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
• 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";
}
• 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;}
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()
Editing tool
Demo
• 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
ArcGIS Pro SDK for .NETBeginning Editing with Focus on EditOperation
• Questions?
- https://github.com/esri/arcgis-pro-sdk/wiki/tech-sessions#2020-palm-springs
Presenter Names
Presentation Title
Section SubheadSection Header
Presenter(s)Demo Title