public static void AllowToolID( CIMEditingTemplate templateDef, string damlID )
Public Shared Sub AllowToolID( _ ByVal templateDef As CIMEditingTemplate, _ ByVal damlID As String _ )
Parameters
- templateDef
- damlID
- DAML ID of the tool.
public static void AllowToolID( CIMEditingTemplate templateDef, string damlID )
Public Shared Sub AllowToolID( _ ByVal templateDef As CIMEditingTemplate, _ ByVal damlID As String _ )
Exception | Description |
---|---|
System.ArgumentException | The tool corresponding to the specified damlID cannot be found. |
QueuedTask.Run(() => { //hide all tools except line tool on layer var featLayer = MapView.Active.Map.FindLayers("Roads").First(); var editTemplates = featLayer.GetTemplates(); var newCIMEditingTemplates = new List<CIMEditingTemplate>(); foreach (var et in editTemplates) { //initialize template by activating default tool et.ActivateDefaultToolAsync(); var cimEditTemplate = et.GetDefinition(); //get the visible tools on this template var allTools = et.ToolIDs.ToList(); //add the hidden tools on this template allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList()); //hide all the tools then allow the line tool //At 2.x - //allTools.AddRange(cimEditTemplate.GetExcludedToolDamlIds().ToList()); allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList()); //At 2.x - //cimEditTemplate.SetExcludedToolDamlIds(allTools.ToArray()); //cimEditTemplate.AllowToolDamlID("esri_editing_SketchLineTool"); cimEditTemplate.SetExcludedToolIDs(allTools.ToArray()); cimEditTemplate.AllowToolID("esri_editing_SketchLineTool"); newCIMEditingTemplates.Add(cimEditTemplate); } //update the layer templates var layerDef = featLayer.GetDefinition() as CIMFeatureLayer; // Set AutoGenerateFeatureTemplates to false for template changes to stick layerDef.AutoGenerateFeatureTemplates = false; layerDef.FeatureTemplates = newCIMEditingTemplates.ToArray(); featLayer.SetDefinition(layerDef); });
Target Platforms: Windows 11, Windows 10