Hi - I've added a button to a dockpane that opens a polygon select tool using GetPlugInWrapper . I'd like to be able to be able to access the constructor of the polygon select tool and the sketchcomplete event of the select tool so that I can specify a specific layer in the map to select, and then export the selected features
to a new layer. Would I specify these events in the ViewModel.cs? Do I need to create a new class
for the select tool? I'm just not sure how to hook up with these events. Below is the code I'm using
to fire the select tool when the button is clicked in the dock pane.
Thanks
Pete
Dockpane .xaml
<Button Command="{Binding CmdCreateSelectTool}" Content="Select Area" HorizontalAlignment="Left" Margin="10,10,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" RenderTransformOrigin="-1.017,-0.75"/>
ViewModel.cs
public ICommand CmdCreateSelectTool =>
FrameworkApplication.GetPlugInWrapper("esri_mapping_selectByPolygonTool") as ICommand;
Solved! Go to Solution.
Hi,
I suggest you to use sample code. You don't need to use esri_mapping_selectByPolygonTool tool. You can make it yourself. In sample you can find class SeqNumTool. It could be your tool analog. One thing you need is to make selection on your layer in OnSketchCompleteAsync method. Something like this:
SpatialQueryFilter filter = new SpatialQueryFilter();
filter.FilterGeometry = geometry;
filter.SpatialRelationship = SpatialRelationship.Intersects;
yourLayer.Select(filter, SelectionCombinationMethod.New);
And remember about MCT
Hi,
I would recommend you to use MapTool with Embeddable control template of ArcGIS Pro. One of Esri community samples to demonstrate functioning is SequentialNumberTool sample. Embeddable control works as Dockpane only one difference that it will be shown if your MapTool is active. MapTool has connection to dialog.
Thanks, I'll give that a try
I got the map tool to fire from clicking button on dockpane by doing this:
Dockpane .xaml
<Button Command="{Binding CmdCreateSelectTool}" Content="Select Area" HorizontalAlignment="Left" Margin="10,10,0,0" Grid.Row="1" VerticalAlignment="Top" Width="75" RenderTransformOrigin="-1.017,-0.75"/>
viewmodel.cs
protected Dockpane1ViewModel()
{
CmdCreateSelectTool = FrameworkApplication.GetPlugInWrapper("esri_mapping_selectByPolygonTool")
as ICommand;
}
public ICommand CmdCreateSelectTool { get; set; }
Now I need to hook into the OnToolActivateAsync and OnSketchCompleteAsync events.
In all the examples I see the maptool is added as a new item and the code is stubbed out in a separate class like this:
public MapTool1()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Polygon;
SketchOutputMode = SketchOutputMode.Map;
}
protected override Task OnToolActivateAsync(bool active)
{
return base.OnToolActivateAsync(active);
}
Any idea how I can hook into these events?
Thanks
Pete
Hi,
I suggest you to use sample code. You don't need to use esri_mapping_selectByPolygonTool tool. You can make it yourself. In sample you can find class SeqNumTool. It could be your tool analog. One thing you need is to make selection on your layer in OnSketchCompleteAsync method. Something like this:
SpatialQueryFilter filter = new SpatialQueryFilter();
filter.FilterGeometry = geometry;
filter.SpatialRelationship = SpatialRelationship.Intersects;
yourLayer.Select(filter, SelectionCombinationMethod.New);
And remember about MCT
I was hoping to have the button on the form because I thought it was more user friendly, but you're right, no samples have this work flow, so I should go with the sample.
Thanks
Pete