VertexGeometry.vb
' Copyright 2011 ESRI ' ' All rights reserved under the copyright laws of the United States ' and applicable international laws, treaties, and conventions. ' ' You may freely redistribute and use this sample code, with or ' without modification, provided you include the original copyright ' notice and use restrictions. ' ' See the use restrictions. ' Imports System.Collections.Generic Imports System.Linq Imports System.Text Imports ESRI.ArcGISExplorer.Geometry ' This class can be used to edit the vertices of single-part polygons and polylines, and also of multipoints. ' If used to edit multipart polygons or polylines, only the first part is edited; the class can be extended to ' edit multiparts. Class VertexGeometry Private _pgon As Polygon = Nothing Private _pline As Polyline = Nothing Private _mpt As Multipoint = Nothing Public Sub New(geom As Geometry) Select Case geom.GeometryType Case GeometryType.Polygon _pgon = TryCast(geom, Polygon) Exit Select Case GeometryType.Polyline _pline = TryCast(geom, Polyline) Exit Select Case GeometryType.Multipoint _mpt = TryCast(geom, Multipoint) Exit Select Case Else Throw New NotSupportedException() End Select End Sub Public Function GetPoint(vertexIndex As Integer) As Point Dim retVal As Point = Nothing If _pgon IsNot Nothing Then retVal = _pgon.GetPoint(vertexIndex) ElseIf _pline IsNot Nothing Then retVal = _pline.GetPoint(vertexIndex) ElseIf _mpt IsNot Nothing Then retVal = _mpt.GetPoint(vertexIndex) End If Return retVal End Function Public Sub SetPoint(vertexIndex As Integer, newPoint As Point) If _pgon IsNot Nothing Then _pgon.SetPoint(vertexIndex, newPoint) ElseIf _pline IsNot Nothing Then _pline.SetPoint(vertexIndex, newPoint) ElseIf _mpt IsNot Nothing Then _mpt.SetPoint(vertexIndex, newPoint) End If End Sub Public Function PointCount() As Integer Dim retVal As Integer = -1 If _pgon IsNot Nothing Then retVal = _pgon.PointCount(0) ElseIf _pline IsNot Nothing Then retVal = _pline.PointCount(0) ElseIf _mpt IsNot Nothing Then retVal = _mpt.PointCount End If Return retVal End Function End Class