public void OnFinishSketch() { //get reference to featurelayer being edited IFeatureLayer featureLayer = m_editLayer.TargetLayer as IFeatureLayer; //get reference to the sketch geometry IGeometry reshapeGeom = m_editSketch.Geometry; if (reshapeGeom.IsEmpty == false) { //get the currently selected feature IFeatureSelection featureSelection = featureLayer as IFeatureSelection; ISelectionSet selectionSet = featureSelection.SelectionSet; ICursor cursor; selectionSet.Search(null, false, out cursor); IFeatureCursor featureCursor = cursor as IFeatureCursor; //the PerformSketchToolEnabledChecks property has already checked that only 1 feature is selected IFeature feature = featureCursor.NextFeature(); //Take a copy of geometry for the selected feature IGeometry editShape = feature.ShapeCopy; //create a path from the editsketch geometry IPointCollection reshapePath = new PathClass(); reshapePath.AddPointCollection(reshapeGeom as IPointCollection); //reshape the selected feature IPolyline polyline = editShape as IPolyline; polyline.Reshape(reshapePath as IPath); #region Perform an edit operation to store the new geometry for selected feature try { m_engineEditor.StartOperation(); feature.Shape = editShape; feature.Store(); m_engineEditor.StopOperation("Reshape Feature"); } catch (Exception ex) { m_engineEditor.AbortOperation(); System.Diagnostics.Trace.WriteLine(ex.Message, "Reshape Geometry Failed"); } #endregion } //refresh the display IActiveView activeView = m_engineEditor.Map as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, (object)featureLayer, activeView.Extent); }
internal static Dictionary <IPolygon, bool> GetVisibilityPolygons(IPoint observerPoint, Dictionary <IPointCollection, bool> pointCollections) { var visibilityPolygons = new Dictionary <IPolygon, bool>(); foreach (var points in pointCollections) { var polygonPoints = new PathClass(); polygonPoints.AddPoint(observerPoint); polygonPoints.AddPointCollection(points.Key); visibilityPolygons.Add(EsriTools.GetVisilityPolygon(polygonPoints), points.Value); } return(visibilityPolygons); }
public static IPolyline Create3DPolylineFromPoints(IPointCollection points) { object missing = Type.Missing; IGeometryCollection geometryCollection = new PolylineClass(); IPointCollection pointCollection = new PathClass(); pointCollection.AddPointCollection(points); geometryCollection.AddGeometry(pointCollection as IGeometry, ref missing, ref missing); var geometry = geometryCollection as IGeometry; IZAware zAware = geometry as IZAware; zAware.ZAware = true; return(geometryCollection as IPolyline); }
public void OnFinishSketch() { //get reference to featurelayer being edited IFeatureLayer featureLayer = m_editLayer.TargetLayer as IFeatureLayer; //get reference to the sketch geometry IGeometry reshapeGeom = m_editSketch.Geometry; if (reshapeGeom.IsEmpty == false) { //get the currently selected feature IFeatureSelection featureSelection = featureLayer as IFeatureSelection; ISelectionSet selectionSet = featureSelection.SelectionSet; ICursor cursor; selectionSet.Search(null, false, out cursor); IFeatureCursor featureCursor = cursor as IFeatureCursor; //the PerformSketchToolEnabledChecks property has already checked that only 1 feature is selected IFeature feature = featureCursor.NextFeature(); //Take a copy of geometry for the selected feature IGeometry editShape = feature.ShapeCopy; //create a path from the editsketch geometry IPointCollection reshapePath = new PathClass(); reshapePath.AddPointCollection(reshapeGeom as IPointCollection); //reshape the selected feature IPolyline polyline = editShape as IPolyline; polyline.Reshape(reshapePath as IPath); #region Perform an edit operation to store the new geometry for selected feature try { m_engineEditor.StartOperation(); feature.Shape = editShape; feature.Store(); m_engineEditor.StopOperation("Reshape Feature"); } catch (Exception ex) { m_engineEditor.AbortOperation(); System.Diagnostics.Trace.WriteLine(ex.Message, "Reshape Geometry Failed"); } #endregion } //refresh the display IActiveView activeView = m_engineEditor.Map as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, (object)featureLayer, activeView.Extent); }