I need to create a custom polygon select tool in Pro that has the same behavior as the default rectangle select tool in ArcGIS Pro. The default behavior is the if you click once, the polygon will be selected (multiple polygons with Shift key pressed down); if you click and drag, you select by rectangle. (Similar to the old IRubberBand in Arc Objects). I cannot figure out how to emulate this behavior using the Pro SDK. I’ve developed a custom point select tool with the Shift multi select behavior using
SketchType = SketchGeometryType.Point;
public bool IsShiftKey()
{
return (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift));
}
protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
{
Key keyboardKey = Key.None;
if(IsShiftKey())
{
keyboardKey = Key.LeftShift;
}
SIPAS.Events.SketchGeometryUpdatedEvent.Publish(new SIPAS.Events.SketchGeometryUpdatedEventArgs(this, geometry, keyboardKey));
return base.OnSketchCompleteAsync(geometry);
}
But this does not let you select by rectangle by dragging. If I use
SketchType = SketchGeometryType.Rectangle;
I cannot multiselect by click or Shift click. I have to click twice to create a rectangle to select a single polygon (which my customer is highly annoyed by).
How can I create a custom select tool that has the same behavior as the default Pro select tool on the Edit tab/ribbon?
Solved! Go to Solution.
This is a complicated answer. We ran into the same issue when developing our configuration. It took a lot of effort to figure out the right combination of flags and event handlers to make it work.
Here is a basic summary of what we did.
In the constructor
In the OnSketchCompleteAsync method:
I hope that helps.
Kris
You can define a launcher button for your group in the daml that replicates the launcher on the selection group.
This is a complicated answer. We ran into the same issue when developing our configuration. It took a lot of effort to figure out the right combination of flags and event handlers to make it work.
Here is a basic summary of what we did.
In the constructor
In the OnSketchCompleteAsync method:
I hope that helps.
Kris
I marked this as the solution because it answered my question and it works. Thanks, it was very helpful. However, the implementation is complicated. To keep it more standard, the customer agreed to a combination of the Pro SDK Tool select behavior in combination with the standard Pro Select tool as Wolf mentioned (with programmatically turning off selectable layers in conjunction with the OnMapSelectionChanged(MapSelectionChangedEventArgs args) event). This also satisfies my customers requirements. Thanks again.
You can also reuse the existing ArcGIS Pro tools (and commands) in your add-in without having to re-create the code. You can find information on reusing Pro commands here:
ProGuide Reusing Pro Commands Esri/arcgis-pro-sdk Wiki (github.com)
And the following video from the last dev summit demonstrates how to re-use Pro commands in your dockpane. (446) ArcGIS Pro SDK for .NET: Practical Dockpane Design and Implementation - YouTube You have to advance the video to 35:30 for the relevant information.
I reuse tools that I can but I need a customized implementation of select to meet my customers requirements.
So I have a tab group with my custom selection tools and an "Advanced Selection" group with the default Esri selection tools (which are actually working with a highly customized Pro Window). This combination is acceptable to the customer. One question however with the "Selection Options" button. Is there a way in the DAML where I can get the graphic used in the out-of-the-box button instead of the "Select Options" text on my button?
<group id="Esri_Selection_Group" caption="Advanced Selection" keytip="Z0">
<toolPalette refID="esri_mapping_selectToolPalette"/>
<tool refID="esri_editing_ShowAttributes" size="middle" />
<tool refID="esri_mapping_clearSelectionButton" size="middle" />
<button refID="esri_mapping_openSelectionOptionsButton" size="middle" />
</group>
<button refID="esri_mapping_openSelectionOptionsButton" size="middle" />
My "Selection Options" button:
Out-of-the-Box "Selection Options" button:
I don't want to use this group because I don't need "Select By Location" or "Select By Attribute" and cannot change the name of the group (to my knowledge):
<group refID="esri_mapping_selectionGroup"></group>
You can define a launcher button for your group in the daml that replicates the launcher on the selection group.
Thanks!
<group id="Esri_Selection_Group" caption="Advanced Selection" keytip="Z0" launcherButtonID="esri_mapping_openSelectionOptionsButton">
<toolPalette refID="esri_mapping_selectToolPalette"/>
<tool refID="esri_editing_ShowAttributes" size="middle" />
<tool refID="esri_mapping_clearSelectionButton" size="middle" />
</group>