Can I get access to the Select one or more features control (with different shapes-rectangle,polygon,...) in ArcGIS Pro SDK C#?

1345
2
09-10-2019 07:41 AM
AnandhaSudhan
New Contributor II

I would like to use the "Select one or more features" tool in a custom dock pane I created. 

Is there a way I can access this functionality using the ArcGIS Pro SDK for C#?

The closest tool I could find from this link: DAML ID Reference Editing.daml · Esri/arcgis-pro-sdk Wiki · GitHub 

esri_editing_EditVerticesNormal - It brings up a dock pane with a select tool but I don't want 
to edit the vertices

My Use case:

I have a connect and disconnect button (similar to existing Move, Rotate). When I click either of them, I need to open a new dock pane with the select one or more features active which selects only a particular feature and has buttons on the dock pane which Activates once the selection is valid.

I found a sample project close to it: arcgis-pro-sdk-community-samples/Map-Exploration/FeatureSelection at master · Esri/arcgis-pro-sdk-co... 

But it has only one select (by rectangle). I would like to replace that select tool with Esri's default feature selection tool as shown in the above image. 

In short, I would like to create a feature similar to Move, Rotate that performs a different operation using a similar dock pane as Esri's. 

Is there a way I can get access to this functionality. Instead of Move/Rotate/Scale, I would like to have my own functionality like Connect, Disconnect.

2 Replies
RichardReinicke
Occasional Contributor II

Hello Anandha,

if you are just looking for the ArcGIS Pro select tools:

then you should be able to get the controls by the following DAML IDs:

Name: Circle 
ID: esri_mapping_selectByCircleTool 
Condition: esri_mapping_mapPane  

Name: Lasso 
ID: esri_mapping_selectByLassoTool 
Condition: esri_mapping_mapPane  

Name: Line 
ID: esri_mapping_selectByLineTool 
Condition: esri_mapping_mapPane  

Name: Polygon 
ID: esri_mapping_selectByPolygonTool 
Condition: esri_mapping_mapPane  

Name: Rectangle 
ID: esri_mapping_selectByRectangleTool 
Condition: esri_mapping_mapPane  

Name: Trace 
ID: esri_mapping_selectByTraceTool 
Condition: esri_mapping_mapViewingMode2DState

Taken from: DAML ID Reference ADMapping.daml · Esri/arcgis-pro-sdk Wiki · GitHub 

Then you should follow this link to use an existing controls logic from your code:
ProGuide Reusing Pro Commands · Esri/arcgis-pro-sdk Wiki · GitHub 

Hope that helps a little bit.

VidmasKondratas
Esri Contributor

Maybe what you are looking for is "esri_mapping_selectToolPalette", "esri_editing_ShowAttributes", and "esri_mapping_clearSelectionButton"? I'm not sure, but this may help someone else at any rate because I came across your post while struggling with this on my project.

In your Config.daml add the tools and toolPalette:

 

<modules>
	<insertModule id="SIPAS_Module" className="SipasModule" autoLoad="false" caption="SIPAS Module">
	  <groups>
		<group id="SIPAS_Selection_Group" caption="Selection" keytip="Z0">
		  <toolPalette refID="esri_mapping_selectToolPalette"/>
		  <tool refID="esri_editing_ShowAttributes" size="middle" />
		  <tool refID="esri_mapping_clearSelectionButton" size="middle" />
		</group>
	  </groups>
	  <tabs>
		<tab id="SIPAS_Tab1" caption="SIPAS" keytip="Z0">
		  <group refID="SIPAS_Selection_Group"></group>
		</tab>
	  </tabs>
	</insertModule>
</modules>

 

In your View Model subscribe to the "OnMapSelectionChanged" event:

 

MapSelectionChangedEvent.Subscribe(OnMapSelectionChanged);

private async void OnMapSelectionChanged(MapSelectionChangedEventArgs args)
{
  await QueuedTask.Run(() =>
  {
    try
    {
      //Eggs is an ObservableCollection of a custom class
      Eggs.Clear();
      _selectedEggCount = 0;
      ShowCanvas = false;
      FeatureLayer layer = _layerHelper.GetIcePolygonLayer();
      var selection = layer.GetSelection();
      IReadOnlyList<long> selectedOIDs = selection.GetObjectIDs();
      if (selectedOIDs.Count == 0)
        return;

      ArcGIS.Core.Data.QueryFilter queryFilter = new ArcGIS.Core.Data.QueryFilter { ObjectIDs = selectedOIDs };
      queryFilter.WhereClause = "POLY_TYPE = 'I' Or POLY_TYPE = 'W'";
      using (RowCursor rowCursor = layer.Search(queryFilter))
      {
        while (rowCursor.MoveNext())
        {
          using (Row row = rowCursor.Current)
          {
            EggModel egg = new EggModel(row);
            Eggs.Add(egg);
          }
        }
      }
    }
    catch (Exception ex)
    {
      _logger.Error("Failed to get egg list: " + ex.Message + ex.StackTrace);
    }
  });
}

 

 

0 Kudos