Reshape Polyline edit task


Purpose This sample demonstrates how to create a custom ArcGIS Engine edit task that can be used in conjunction with the out-of-the-box editing commands. The Reshape Polyline edit task allows you to reshape the selected feature within an edit session. The edit task is created by implementing the IEngineEditTask interface.
 
The position of the task in the ControlsEditingTaskToolControl list is controlled using the IEngineEditTask.GroupName property, and the display name is controlled using the IEngineEditTask.Name property. The IEngineEditTask.Activate method is called when the end user selects the edit task in the ControlsEditingTaskToolControl. The Activate method is used to set up listeners to the following IEngineEditEvents:

OnTargetLayerChanged fires when the target layer changes
OnSelectionChanged fires when the feature selection changes
OnCurrentTaskChanged fires when selected task changes

These event listeners set the IEngineEditSketch.GeometryType to null if the following conditions are met, thereby disabling the Sketch tool:

The target layer does not have a polyline geometry type
More than one feature is selected in the target layer

The IEngineEditLayers.TargetLayer property on the EngineEditor singleton is used to return to the target layer selected in the ControlsEditingTargetToolControl.
 
The IEngineEditTask.OnFinishSketch method is used to reshape the geometry of the selected feature using the IPolyline.Reshape method, passing in a path created from the digitized sketch as an argument. The task calls the IFeature.Store method within an edit operation to commit the changes.

How to use

See How to use ArcGIS samples for help running the sample.

  1. Start the sample application. The ushigh.shp shapefile from the sample data is loaded into the Map control.
  2. Use the Editor menu on the toolbar to start an edit session. The editing controls on the toolbar are enabled.
  3. Click the Add ReshapePolyline Task command on the toolbar. The command is disabled, and the Reshape Polyline Edit task is added to the Edit Tasks tool control and is set as the active task.
  4. Zoom in on an area on the map where you want to reshape a highway feature.
  5. Use the Edit tool to select a feature by clicking the feature. The Sketch tool is enabled, and the feature is highlighted in blue.
  6. Use the Sketch tool to digitize a polyline that intersects the selected highway feature in at least two places. You can right-click the map to access the Sketch context menu.
  7. Double-click to finish the sketch. The selected feature is reshaped.
  8. Stop the edit session using the Editor menu.





Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView
ArcEditor
ArcInfo