ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapTool Class / OnSketchCompleteAsync Method
The geometry of the sketch.
Example

In This Topic
    OnSketchCompleteAsync Method (MapTool)
    In This Topic
    Occurs when a sketch is finished.
    Syntax
    protected virtual Task<bool> OnSketchCompleteAsync( 
       Geometry geometry
    )
    Protected Overridable Function OnSketchCompleteAsync( _
       ByVal geometry As Geometry _
    ) As Task(Of Boolean)

    Parameters

    geometry
    The geometry of the sketch.

    Return Value

    True if the sketch complete event was handled.
    Example
    Annotation Construction Tool
    //In your config.daml...set the categoryRefID
    //<tool id="..." categoryRefID="esri_editing_construction_annotation" caption="Create Anno" ...>
    
    //Sketch type Point or Line or BezierLine in the constructor...
    //internal class AnnoConstructionTool : MapTool  {
    //  public AnnoConstructionTool()  {
    //    IsSketchTool = true;
    //    UseSnapping = true;
    //    SketchType = SketchGeometryType.Point;
    //
    
    protected async override Task<bool> OnSketchCompleteAsync(Geometry geometry)
    {
      if (CurrentTemplate == null || geometry == null)
        return false;
    
      // Create an edit operation
      var createOperation = new EditOperation();
      createOperation.Name = string.Format("Create {0}", CurrentTemplate.Layer.Name);
      createOperation.SelectNewFeatures = true;
    
      var insp = CurrentTemplate.Inspector;
      var result = await QueuedTask.Run(() =>
      {
        // get the annotation properties class
        AnnotationProperties annoProperties = insp.GetAnnotationProperties();
        // set custom annotation properties
        annoProperties.TextString = "my custom text";
        annoProperties.Color = ColorFactory.Instance.RedRGB;
        annoProperties.FontSize = 24;
        annoProperties.FontName = "Arial";
        annoProperties.HorizontalAlignment = ArcGIS.Core.CIM.HorizontalAlignment.Right;
        annoProperties.Shape = geometry;
        // assign annotation properties back to the inspector
        insp.SetAnnotationProperties(annoProperties);
    
        // Queue feature creation
        createOperation.Create(CurrentTemplate.Layer, insp);
    
        // Execute the operation
        return createOperation.Execute();
      });
      return result;
    }
    
    Spatial selection of elements in all Graphics Layers
    //Map Tool is used to perform Spatial selection.
    //Graphic selection uses the selection geometry 
    //to intersect the geometries of those elements (graphic or group) 
    //that will be selected and then highlights them. 
    protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry)
    {
      var selPoly = geometry as Polygon;
      return await QueuedTask.Run(() =>
      {     
        //note: the selected elements may belong to more than one layer...
        var elems = MapView.Active.SelectElements(selPoly, SelectionCombinationMethod.New);
        return true;
      });
    }
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also