public void OnMouseUp(int button, int shift, int x, int y) { if (button == 1) { try { if (this.m_SelectedFeature == null) { this.m_SelectedFeature = new List <IFeature>(); } IPoint pPoint = this._hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IFeatureLayer targetLayer = Editor.UniqueInstance.TargetLayer; IFeatureSelection selection = targetLayer as IFeatureSelection; if (!this.m_IsSelecting) { selection.Clear(); this.m_SelectedFeature.Clear(); } this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, targetLayer, null); IEnvelope searchEnvelope = FeatureFuncs.GetSearchEnvelope(this._hookHelper.ActiveView, pPoint); if (searchEnvelope != null) { IFeature item = FeatureFuncs.SearchFeatures(targetLayer, searchEnvelope, esriSpatialRelEnum.esriSpatialRelIntersects).NextFeature(); if (item != null) { if (this.m_SelectedFeature.Contains(item)) { this.m_SelectedFeature.Remove(item); selection.Clear(); for (int i = 0; i < this.m_SelectedFeature.Count; i++) { selection.Add(this.m_SelectedFeature[i]); } } else { this.m_SelectedFeature.Add(item); selection.Add(item); } this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, targetLayer, null); if (!this.m_IsSelecting) { this.DeleteFeatures(); } } } } catch (Exception exception) { Editor.UniqueInstance.AbortEditOperation(); this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Delete", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } } }
public void OnMouseUp(int button, int shift, int x, int y) { if (button != 2) { IPoint pPoint = this.m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IEnvelope searchEnvelope = FeatureFuncs.GetSearchEnvelope(this.m_hookHelper.ActiveView, pPoint); IFeature feature = FeatureFuncs.SearchFeatures(Editor.UniqueInstance.TargetLayer, searchEnvelope, esriSpatialRelEnum.esriSpatialRelIntersects).NextFeature(); if (feature != null) { ITopologicalOperator2 shape = feature.Shape as ITopologicalOperator2; Editor.UniqueInstance.StartEditOperation(); shape.IsKnownSimple_2 = false; shape.Simplify(); Editor.UniqueInstance.StopEditOperation("simplify"); IActiveView activeView = this.m_hookHelper.ActiveView; IFeatureSelection targetLayer = Editor.UniqueInstance.TargetLayer as IFeatureSelection; targetLayer.Clear(); targetLayer.Add(feature); activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, null); } } }
public void OnDblClick() { Editor.UniqueInstance.CheckOverlap = false; try { IFeatureLayer targetLayer = Editor.UniqueInstance.TargetLayer; object missing = Type.Missing; if (!this.m_IsUsed || (this.m_LineFeedback == null)) { return; } if (this.m_Step > 1) { IPolyline polyline = this.m_LineFeedback.Stop(); if (polyline == null) { this.Init(); return; } IFeatureClass featureClass = targetLayer.FeatureClass; if (featureClass == null) { this.Init(); return; } IGeoDataset dataset = featureClass as IGeoDataset; if (polyline.SpatialReference != dataset.SpatialReference) { polyline.Project(dataset.SpatialReference); polyline.SpatialReference = dataset.SpatialReference; } IGeometry inGeometry = polyline; GeometryBagClass lineSrc = new GeometryBagClass(); lineSrc.AddGeometry(inGeometry, ref missing, ref missing); targetLayer.Selectable = true; IDataset dataset2 = featureClass as IDataset; IWorkspace selectionWorkspace = dataset2.Workspace; IEnvelope extent = dataset.Extent; IInvalidArea invalidArea = new InvalidAreaClass(); IFeatureConstruction construction = new FeatureConstructionClass(); IFeatureSelection selection = targetLayer as IFeatureSelection; ISelectionSet selectionSet = selection.SelectionSet; Editor.UniqueInstance.SetArea = false; Editor.UniqueInstance.StartEditOperation(); ISpatialReferenceTolerance spatialReference = (ISpatialReferenceTolerance)dataset.SpatialReference; construction.AutoCompleteFromGeometries(featureClass, extent, lineSrc, invalidArea, spatialReference.XYTolerance, selectionWorkspace, out selectionSet); if ((selectionSet == null) || (selectionSet.Count < 1)) { Editor.UniqueInstance.AbortEditOperation(); } else { List <IFeature> pFeatureList = new List <IFeature>(); IEnumIDs iDs = selectionSet.IDs; iDs.Reset(); for (int i = iDs.Next(); i >= 0; i = iDs.Next()) { IFeature pFeature = featureClass.GetFeature(i); FeatureFuncs.SetFeatureArea(pFeature); pFeatureList.Add(pFeature); } if (selectionSet.Count == 1) { IFeature feature = pFeatureList[0]; selection.Clear(); selection.Add(feature); AttributeManager.AttributeAddHandleClass.AttributeAdd(ref feature); } else { AttributeManager.AttributeSplitHandleClass.AttributeSplit(null, ref pFeatureList); } Editor.UniqueInstance.StopEditOperation("AutoComplete"); } Editor.UniqueInstance.SetArea = true; this.m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, this.m_hookHelper.ActiveView.Extent); } } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.AutoComplete", "OnDblClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } this.Init(); Editor.UniqueInstance.CheckOverlap = true; }
public void OnMouseUp(int button, int shift, int x, int y) { if (button != 2) { IPoint pPoint = this.m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IEnvelope searchEnvelope = FeatureFuncs.GetSearchEnvelope(this.m_hookHelper.ActiveView, pPoint); IFeature feature = FeatureFuncs.SearchFeatures(Editor.UniqueInstance.TargetLayer, searchEnvelope, esriSpatialRelEnum.esriSpatialRelIntersects).NextFeature(); if (feature != null) { bool flag = false; Editor.UniqueInstance.StartEditOperation(); IGeometryCollection shape = feature.Shape as IGeometryCollection; int geometryCount = shape.GeometryCount; List <string> list = new List <string>(); for (int i = 0; i < geometryCount; i++) { flag = false; list.Clear(); IGeometry geometry = shape.get_Geometry(i); int num3 = 0; if ((geometry.GeometryType == esriGeometryType.esriGeometryPolygon) || (geometry.GeometryType == esriGeometryType.esriGeometryRing)) { IRing ring = geometry as IRing; if (ring.IsClosed) { num3 = 1; } } IPointCollection points = geometry as IPointCollection; int pointCount = points.PointCount; for (int j = num3; j < pointCount; j++) { IPoint point2 = points.get_Point(j); string item = string.Format("{0:F3},{1:F3}", point2.X, point2.Y); if (list.Contains(item)) { points.RemovePoints(j, 1); j--; pointCount--; flag = true; } else { list.Add(item); } } if (flag) { object missing = Type.Missing; object before = new object(); before = i; shape.RemoveGeometries(i, 1); shape.AddGeometry(points as IGeometry, ref before, ref missing); } } feature.Shape = shape as IGeometry; feature.Store(); Editor.UniqueInstance.StopEditOperation("delete repeat point"); this.m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, this.m_hookHelper.ActiveView.Extent); } } }