private void ExplodeFeature(IFeature pFeature) { IFeatureLayer targetLayer = Editor.UniqueInstance.TargetLayer; if (targetLayer != null) { IFeatureClass featureClass = targetLayer.FeatureClass; if (featureClass != null) { IGeometry shapeCopy = pFeature.ShapeCopy; IList <IGeometry> geometrys = this.GetGeometrys(shapeCopy); if (geometrys == null) { MessageBox.Show("选中要素获取多部件,无法打散!", "打散"); } else { int count = geometrys.Count; if (count < 2) { MessageBox.Show("选中要素没有多个部件,无法打散!", "打散"); } else { Editor.UniqueInstance.CheckOverlap = false; Editor.UniqueInstance.AddAttribute = false; IAttributeSplit attributeSplitHandleClass = AttributeManager.AttributeSplitHandleClass; if (attributeSplitHandleClass != null) { Editor.UniqueInstance.StartEditOperation(); try { int num2 = 0; List <IFeature> pFeatureList = new List <IFeature>(); for (int i = 0; i < count; i++) { IGeometry geometry2 = geometrys[i]; IFeature item = null; if (num2 == 0) { item = pFeature; } else { item = featureClass.CreateFeature(); } item.Shape = geometry2; item.Store(); pFeatureList.Add(item); num2++; } attributeSplitHandleClass.AttributeSplit(pFeature, ref pFeatureList); Editor.UniqueInstance.StopEditOperation("Explode"); } catch (Exception exception) { Editor.UniqueInstance.AbortEditOperation(); this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Explode", "ExplodeFeature", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } Editor.UniqueInstance.CheckOverlap = true; } } } } } }
public void OnDblClick() { if (this._isLineStarted) { this._snapPoint = null; try { this._isLineStarted = false; this._linePoints.RemoveAll(); IPolyline other = this._feedback.Stop(); IFeatureSelection targetLayer = Editor.UniqueInstance.TargetLayer as IFeatureSelection; IEnumIDs iDs = targetLayer.SelectionSet.IDs; iDs.Reset(); IFeature srcFeature = Editor.UniqueInstance.TargetLayer.FeatureClass.GetFeature(iDs.Next()); if (other.SpatialReference != srcFeature.Shape.SpatialReference) { other.Project(srcFeature.Shape.SpatialReference); other.SpatialReference = srcFeature.Shape.SpatialReference; } ITopologicalOperator2 shape = srcFeature.Shape as ITopologicalOperator2; if (shape != null) { shape.IsKnownSimple_2 = false; shape.Simplify(); ITopologicalOperator2 operator2 = other as ITopologicalOperator2; operator2.IsKnownSimple_2 = false; operator2.Simplify(); IGeometry geometry = null; if (srcFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { geometry = shape.Intersect(other, esriGeometryDimension.esriGeometry0Dimension); } else { geometry = shape.Intersect(other, esriGeometryDimension.esriGeometry1Dimension); } if (!geometry.IsEmpty) { IGeometry geometry2; IGeometry geometry3; shape.Cut(other, out geometry3, out geometry2); if ((geometry3 != null) && (geometry2 != null)) { (geometry3 as ITopologicalOperator).Simplify(); (geometry2 as ITopologicalOperator).Simplify(); IFeatureClass featureClass = Editor.UniqueInstance.TargetLayer.FeatureClass; IFeature feature = featureClass.CreateFeature(); IFeature feature3 = featureClass.CreateFeature(); feature.Shape = geometry3; feature3.Shape = geometry2; IAttributeSplit attributeSplitHandleClass = AttributeManager.AttributeSplitHandleClass; if (attributeSplitHandleClass != null) { try { Editor.UniqueInstance.StartEditOperation(); Editor.UniqueInstance.AddAttribute = false; List <IFeature> pFeatureList = null; pFeatureList = new List <IFeature> { feature, feature3 }; attributeSplitHandleClass.AttributeSplit(srcFeature, ref pFeatureList); feature = pFeatureList[0]; feature3 = pFeatureList[1]; feature.Store(); feature3.Store(); srcFeature.Delete(); Editor.UniqueInstance.StopEditOperation("split"); targetLayer.Clear(); targetLayer.Add(feature); this._hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewGeography, null, null); } catch (Exception exception) { Editor.UniqueInstance.AbortEditOperation(); this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Split", "OnDblClick", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } } } } } } catch (Exception exception2) { this._mErrOpt.ErrorOperate(this._mSubSysName, "ShapeEdit.Split", "OnDblClick", exception2.GetHashCode().ToString(), exception2.Source, exception2.Message, "", "", ""); } } }