Custom reshape polyline edit task


PurposeThis sample illustrates 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 the user to perform a reshape on the selected feature within an edit session.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and running the sample.

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/USAMajorHighways/usa_major_highways.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Build and run the sample.
  2. Start editing.
  3. Zoom in on a polyline feature that you want to reshape.
  4. Select this feature with the Edit tool.
  5. Select the Reshape Polyline edit task from the Edit Task Tool control.
  6. Using the Sketch tool, digitize a new line that intersects the selected feature in at least two places.
  7. Finish the sketch to perform the reshape.
  8. Stop editing and save edits to persist changes. See the following illustration:


  9. Illustration of performing a reshape on the selected feature.

Additional information

The edit task is created by implementing the IEngineEditTask interface. Compiling this sample registers the edit task in the ESRI Engine Edit Tasks component category, which is used to populate the ControlsEditingTaskToolControl at runtime. The position of the task within the ControlsEditingTaskToolControl list is controlled using the IEngineEditTask.GroupName property and the display name 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 the 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.


EngineEditTask/ReshapePolylineEditTask.cs Class file.
Application/EditingForm.cs Form file.
Download the C# files
EngineEditTask/ReshapePolylineEditTask.vb Class file.
Application/EditingForm.vb Form file.
Download the VB.NET files

Download the files for all languages

See Also:

EngineEditorClass




Additional Requirements
  • An edit session.

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