private void method_5() { this.bool_6 = true; this.bool_1 = false; IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature; IGeometryCollection geometryCollection = new GeometryBag() as IGeometryCollection; enumFeature.Reset(); IFeature feature = enumFeature.Next(); object value = Missing.Value; while (feature != null) { esriGeometryType geometryType = feature.Shape.GeometryType; if (geometryType == esriGeometryType.esriGeometryPolygon || geometryType == esriGeometryType.esriGeometryPolyline) { IClone clone = feature.Shape as IClone; geometryCollection.AddGeometry(clone.Clone() as IGeometry, ref value, ref value); this.bool_4 = true; } feature = enumFeature.Next(); } if (this.bool_2) { this.isegmentGraph_0.SetEmpty(); this.isegmentGraphCursor_0 = null; } this.isegmentGraph_0.Load(geometryCollection as IEnumGeometry, false, true); this.bool_2 = false; }
private void Reset() { if (m_pCursor != null) { m_pCursor = null; } if (m_pGraph != null) { if (m_pGraph != null) { m_pGraph.SetEmpty(); } } bBegineMove = false; m_bIsSelect = false; bBegineMove = false; button1 = 1; m_pFeedbackEnve = null; m_OriginFeatureArray.RemoveAll(); m_pActiveView.GraphicsContainer.DeleteAllElements(); m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_pEnvelope); //视图刷新 m_pEnvelope = null; m_pStatusBarService.SetStateMessage("就绪"); }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { // TODO: 添加 DrawTraceLine.OnMouseDown 实现 base.OnMouseDown(button, shift, x, y, mapX, mapY); m_pStatusBarService.SetStateMessage("1.选择要素;2.右键/ENTER/SPACEBAR,结束选择;3.左键,确定跟踪的起点;4.左键,结束跟踪。(ESC: 取消/DEL:删除)"); m_CurrentLayer = ((IDFApplication)this.Hook).CurrentEditLayer; m_bIsSelect = true; if (button != 2 && bBegineMove && button1 == 2) //结束跟踪,复位 { object a = esriConstructOffsetEnum.esriConstructOffsetSimple; object b = System.Reflection.Missing.Value; m_pTraceLine = m_pCursor.CurrentTrace; m_pOffsetTraceLine.ConstructOffset(m_pTraceLine, m_dOffsetDistance, ref a, ref b); IGeometry pGeometry = (IGeometry)m_pOffsetTraceLine; if (((IFeatureLayer)m_App.CurrentEditLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { pGeometry = (IGeometry)CommonFunction.GetPolygonBoundary((IPolygon)pGeometry); } CommonFunction.CreateFeature(m_App.Workbench, pGeometry, m_FocusMap, m_CurrentLayer); Reset(); //复位 return; } if (button != 2 && bBegineMove && button1 == 1) //开始跟踪 { //'Start a trace if one doesn't exist m_pCursor = m_pGraph.GetCursor(m_pPoint); m_pTraceLine = m_pCursor.CurrentTrace; object a = esriConstructOffsetEnum.esriConstructOffsetSimple; object b = System.Reflection.Missing.Value; m_pOffsetTraceLine.ConstructOffset(m_pTraceLine, m_dOffsetDistance, ref a, ref b); RefreshTraceline(); m_lMoveCounter = 0; button1 = 2; return; } if (button == 2 && !bBegineMove) //右键单击,停止选择 { if (m_OriginFeatureArray.Count == 0) { return; } CreateGraph(); bBegineMove = true; return; } }
public override void OnMouseDown(int int_2, int int_3, int int_4, int int_5) { if (int_2 == 1) { if (!this.bool_6) { this.method_5(); } if (this.bool_4) { object value = Missing.Value; object obj = this.int_1; if (!this.bool_2) { this.ipoint_1 = _context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_4, int_5); this.isegmentGraphCursor_0 = this.isegmentGraph_0.GetCursor(this.ipoint_0); this.ipolyline_0 = this.isegmentGraphCursor_0.CurrentTrace; this.iconstructCurve_0.ConstructOffset(this.ipolyline_0, this.double_0, ref obj, ref value); if (SketchShareEx.LastPoint != null && (this.iconstructCurve_0 as IPointCollection).PointCount > 0) { this.iline_0 = new Line(); this.iline_0.PutCoords(SketchShareEx.LastPoint, (this.iconstructCurve_0 as IPointCollection).get_Point(0)); } this.method_4(); this.int_0 = 0; this.bool_2 = true; } else { if (this.bool_5) { this.iline_0 = null; this.ipolyline_0 = this.isegmentGraphCursor_0.CurrentTrace; this.iconstructCurve_0.ConstructOffset(this.ipolyline_0, this.double_0, ref obj, ref value); } else { if (!this.isegmentGraphCursor_0.MoveTo(this.snapHelper_0.AnchorPoint)) { this.isegmentGraphCursor_0.FinishMoveTo(this.snapHelper_0.AnchorPoint); } this.iline_0 = null; this.ipolyline_0 = this.isegmentGraphCursor_0.CurrentTrace; this.iconstructCurve_0.ConstructOffset(this.ipolyline_0, this.double_0, ref obj, ref value); } this.method_1(); this.method_2(this.iconstructCurve_0 as IPolyline); } } } }
private void method_1() { if (this.isegmentGraphCursor_0 != null) { this.isegmentGraphCursor_0 = null; } if (this.isegmentGraph_0 != null) { this.isegmentGraph_0.SetEmpty(); } this.bool_2 = false; this.bool_6 = false; }
private void CreateGraph() { IClone pClone; IFeature pFeature; IGeometryCollection pGeometryBag; esriGeometryType GeoType; pGeometryBag = new GeometryBagClass(); for (int i = 0; i < m_OriginFeatureArray.Count; i++) { pFeature = (IFeature)m_OriginFeatureArray.get_Element(i); GeoType = pFeature.Shape.GeometryType; if (GeoType == esriGeometryType.esriGeometryPolygon || GeoType == esriGeometryType.esriGeometryPolyline) { object a = System.Reflection.Missing.Value; object b = System.Reflection.Missing.Value; pClone = (IClone)pFeature.Shape; pGeometryBag.AddGeometry((IGeometry)pClone.Clone(), ref a, ref b); } } if (bBegineMove) { if (m_pGraph != null) { m_pGraph.SetEmpty(); } m_pCursor = null; } IEnumGeometry pEnumGeometry = (IEnumGeometry)pGeometryBag; m_pGraph.Load(pEnumGeometry, false, true); bBegineMove = false; }