ArcGIS Pro二次开发-选择工具
多边形选择 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ArcGIS.Core.CIM; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Catalog; using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Editing; using ArcGIS.Desktop.Extensions; using ArcGIS.Desktop.Framework; using ArcGIS.Desktop.Framework.Contracts; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; namespace ProAppModule1 { internal class MapTool2 : MapTool { public MapTool2() { IsSketchTool = true; SketchType = SketchGeometryType.Polygon; SketchOutputMode = SketchOutputMode.Map; } protected override Task OnToolActivateAsync(bool active) { return base.OnToolActivateAsync(active); } protected override Task<bool> OnSketchCompleteAsync(Geometry geometry) { return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { // Using the active map view to select // the features that intersect the sketch geometry ActiveMapView.SelectFeatures(geometry); return true; }); } } }
==================
矩形选择 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using ArcGIS.Core.CIM; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Catalog; using ArcGIS.Desktop.Core; using ArcGIS.Desktop.Editing; using ArcGIS.Desktop.Extensions; using ArcGIS.Desktop.Framework; using ArcGIS.Desktop.Framework.Contracts; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; namespace ProAppModule1 { internal class MapToolSelect : MapTool { public MapToolSelect() { IsSketchTool = true; SketchType = SketchGeometryType.Rectangle; SketchOutputMode = SketchOutputMode.Screen; } protected override Task OnToolActivateAsync(bool active) { return base.OnToolActivateAsync(active); } protected override Task<bool> OnSketchCompleteAsync(Geometry geometry) { return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { // Using the active map view to select // the features that intersect the sketch geometry ActiveMapView.SelectFeatures(geometry); return true; }); } } }