A synchronous (blocking) call which executes the specified delegate and returns a new Polyline at the location of a series of mouse clicks on the display, using the specified line color and width while tracking.

Namespace:  ESRI.ArcGISExplorer.Mapping

Assembly:  ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)

Syntax

C#
public Polyline TrackPolyline(
	Color color,
	double width,
	TrackDelegate trackDelegate
)
Visual Basic (Declaration)
Public Function TrackPolyline ( _
	color As Color, _
	width As Double, _
	trackDelegate As TrackDelegate _
) As Polyline

Parameters

color
Type: System.Drawing..::.Color

The color of the partially completed line shown during the tracking operation.
width
Type: System..::.Double

The width in pixels of the partially completed line shown during the tracking operation. Default is 1, maximum is 10.
trackDelegate
Type: ESRI.ArcGISExplorer.Mapping..::.TrackDelegate

A tracking delegate that contains a method to be called when the user interacts with the display.

Return Value

A new Polyline defined by a series of mouse clicks on the display.

Remarks

This method returns a user-clicked Polyline on the map, using the specified line color and width while tracking. The TrackDelegate allows mouse moves and tracking cancellation to be identified. This overload allows the same TrackDelegate method to be called from both this synchronous method and also the asynchronous MapDisplay.BeginTrackPolyline(TrackDelegate) method.

This method will block the user interface (UI) thread until the user has completed tracking the Polyline. The method can be cancelled if the ESC key is pressed after the method has been called or the CancelTracking()()() method is called; in this case the method will return nullNothingnullptra null reference (Nothing in Visual Basic).

Alternatively you may wish to use an asynchronous equivalent, see the BeginTrackPolyline methods.

Examples

Although the following code example relates to the TrackPolygon method, it serves to illustrate how to also use the TrackPolyline method which has a delegate argument.
CopyC#
using System;
using System.IO;
using System.Drawing;
using ESRI.ArcGISExplorer;
using ESRI.ArcGISExplorer.Application;
using ESRI.ArcGISExplorer.Mapping;
using ESRI.ArcGISExplorer.Geometry;
using ESRI.ArcGISExplorer.Data;
using ESRI.ArcGISExplorer.Threading;

namespace TrackPolygonUsingDelegate
{
  public class SyncTrackPoly : ESRI.ArcGISExplorer.Application.Button
  {
    Table _districtsTable;

    public override void OnClick()
    {
      //Open the district shapefile
      _districtsTable = Table.OpenShapefile(@"C:\Data\district.shp");

      //get the MapDisplay
      ESRI.ArcGISExplorer.Mapping.MapDisplay disp = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay;

      //Start tracking synchronously
      disp.TrackPolygon(Color.Red, 6, TrackDelegate);

      //The following code WILL NOT be executed until tracking has finished
      //e.g list all files in a folder on disk
      DirectoryInfo di = new DirectoryInfo(@"C:\Data");
      FileInfo[] files = di.GetFiles("*.*");
      foreach (FileInfo fi in files)
      {
        System.Diagnostics.Debug.Print(fi.Name);
      }
    }

    /// <summary>
    /// The delegate used by the TrackPolygon method
    /// </summary>
    public void TrackDelegate(TrackingInfo info)
    {
      switch (info.Status)
      {
        case TrackStatus.Cancelled:
          System.Diagnostics.Debug.Print("cancelled");
          break;
        case TrackStatus.Completed:
          System.Diagnostics.Debug.Print("completed");
          break;
        case TrackStatus.MouseMoved:
          break;
        case TrackStatus.PointAdded:
          //Perform a spatial query
          ReportDistrictsIntersectingTheTrackPolygon(info.Geometry);
          break;
        case TrackStatus.PointRemoved:
          //Perform a spatial query
          ReportDistrictsIntersectingTheTrackPolygon(info.Geometry);
          break;
        default:
          break;
      }
    }

    /// <summary>
    /// Reports the districts which intersect the tracked polygon.
    /// </summary>
    private void ReportDistrictsIntersectingTheTrackPolygon(Geometry geom)
    {
      Polygon poly = geom as Polygon;

      if ((poly != null) && (poly.IsEmpty == false))
      {
        RowCollection resultRows = _districtsTable.Search(new Filter(poly, FilterSearchOptions.Intersects));

        System.Diagnostics.Debug.Print("*******");

        foreach (Row resultRow in resultRows)
        {
          System.Diagnostics.Debug.Print(resultRow.Values["District"].ToString());
        }
      }
    }
  }
}
CopyVB.NET
Imports System
Imports System.IO
Imports System.Drawing
Imports ESRI.ArcGISExplorer
Imports ESRI.ArcGISExplorer.Application
Imports ESRI.ArcGISExplorer.Mapping
Imports ESRI.ArcGISExplorer.Geometry
Imports ESRI.ArcGISExplorer.Data
Imports ESRI.ArcGISExplorer.Threading

Public Class SyncTrackPolygon
  Inherits ESRI.ArcGISExplorer.Application.Button
  Private _districtsTable As Table

  Public Overloads Overrides Sub OnClick()
    'Open the district shapefile 
    _districtsTable = Table.OpenShapefile("C:\Data\district.shp")

    'get the MapDisplay 
    Dim disp As ESRI.ArcGISExplorer.Mapping.MapDisplay = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay

    'Start tracking synchronously 
    disp.TrackPolygon(Color.Red, 6, AddressOf TrackDelegate)

    'The following code WILL NOT be executed until tracking has finished 
    'e.g list all files in a folder on disk 
    Dim di As New DirectoryInfo("C:\Data")
    Dim files As FileInfo() = di.GetFiles("*.*")
    For Each fi As FileInfo In files
      System.Diagnostics.Debug.Print(fi.Name)
    Next
  End Sub

  ''' <summary> 
  ''' The delegate used by the TrackPolygon method 
  ''' </summary> 
  Public Sub TrackDelegate(ByVal info As TrackingInfo)
    Select Case info.Status
      Case TrackStatus.Cancelled
        System.Diagnostics.Debug.Print("cancelled")
        Exit Select
      Case TrackStatus.Completed
        System.Diagnostics.Debug.Print("completed")
        Exit Select
      Case TrackStatus.MouseMoved
        Exit Select
      Case TrackStatus.PointAdded
        'Perform a spatial query 
        ReportDistrictsIntersectingTheTrackPolygon(info.Geometry)
        Exit Select
      Case TrackStatus.PointRemoved
        'Perform a spatial query 
        ReportDistrictsIntersectingTheTrackPolygon(info.Geometry)
        Exit Select
      Case Else
        Exit Select
    End Select
  End Sub

  ''' <summary> 
  ''' Reports the districts which intersect the tracked polygon. 
  ''' </summary> 
  Private Sub ReportDistrictsIntersectingTheTrackPolygon(ByVal geom As Geometry)
    Dim poly As Polygon = TryCast(geom, Polygon)

    If (poly IsNot Nothing) AndAlso (poly.IsEmpty = False) Then
      Dim resultRows As RowCollection = _districtsTable.Search(New Filter(poly, FilterSearchOptions.Intersects))

      System.Diagnostics.Debug.Print("*******")

      For Each resultRow As Row In resultRows
        System.Diagnostics.Debug.Print(resultRow.Values("District").ToString())
      Next
    End If
  End Sub
End Class

See Also