public override void OnMouseDown(int int_0, int Shift, int int_2, int int_3) { if (int_0 == 1) { IActiveView focusMap = (IActiveView)_context.FocusMap; CreateFeatureTool.CreateFeature(this.pPoint, focusMap, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer); } base.OnMouseDown(int_0, Shift, int_2, int_3); }
public override void OnMouseDown(int int_0, int Shift, int int_2, int int_3) { if (int_0 == 1) { IActiveView activeView = _context.FocusMap as IActiveView; IPoint mapPoint = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_2, int_3); if (SketchToolAssist.Feedback != null) { try { ICircularArc circularArc = (SketchToolAssist.Feedback as INewCircleFeedback).Stop(); ISegmentCollection polylineClass = null; IFeatureLayer featureLayer = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer; if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { polylineClass = new Polyline() as ISegmentCollection; } else if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon) { return; } else { polylineClass = new Polygon() as ISegmentCollection; } object value = Missing.Value; polylineClass.AddSegment(circularArc as ISegment, ref value, ref value); CreateFeatureTool.CreateFeature(polylineClass as IGeometry, _context.FocusMap as IActiveView, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer); } catch (Exception exception) { //CErrorLog.writeErrorLog(this, exception, ""); } SketchShareEx.m_bInUse = false; SketchShareEx.LastPoint = null; SketchShareEx.PointCount = 0; SketchToolAssist.Feedback = null; SketchShareEx.m_LastPartGeometry = null; } else { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewCircleFeedback(); SketchToolAssist.Feedback.Display = activeView.ScreenDisplay; (SketchToolAssist.Feedback as INewCircleFeedback).Start(mapPoint); } } }
public override void OnDblClick() { IActiveView focusMap = (IActiveView)_context.FocusMap; if (SketchToolAssist.CurrentTask == null) { SketchToolAssist.EndSketch(false, focusMap, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer); } else { SketchToolAssist.EndSketch(false, focusMap, null); } if (SketchToolAssist.TempLine != null) { if (frmProperties == null) { frmProperties = new frmLinePointProperties(_context); } DialogResult result = frmProperties.ShowDialog(); if (result != DialogResult.OK) { return; } IPointCollection pntCol = SketchToolAssist.TempLine as IPointCollection; int createCount = 0; for (int i = 0; i < pntCol.PointCount; i++) { IPoint point = pntCol.Point[i]; if (i == 0 && !_context.Config.IsAddStartPoint) { continue; } if (i == pntCol.PointCount - 1 && !_context.Config.IsAddEndPoint) { continue; } if ((i > 0 && i < pntCol.PointCount - 1) && !_context.Config.IsAddVertexPoint) { continue; } bool isClear = createCount == 0 ? true : false; CreateFeatureTool.CreateFeature(point, focusMap, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer, isClear); createCount++; } } }
public override void OnDblClick() { IActiveView focusMap = (IActiveView)_context.FocusMap; if (SketchToolAssist.CurrentTask == null) { SketchToolAssist.EndSketch(false, focusMap, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer); } else { SketchToolAssist.EndSketch(false, focusMap, null); } if (SketchToolAssist.TempLine != null) { if (frmProperties == null) { frmProperties = new frmAlongLineProperties(_context); } frmProperties.SetPolyline((IPolyline)SketchToolAssist.TempLine); DialogResult result = frmProperties.ShowDialog(); if (result != DialogResult.OK) { return; } IPolyline polyline = SketchToolAssist.TempLine as IPolyline; double dbp = 0; if (frmProperties.IsNOP) { dbp = polyline.Length / (frmProperties.NOP + 1); } else { dbp = frmProperties.Distance; } int createCount = 0; bool isClear = true; //create points at distance between points up to total length for (double d = dbp; d < polyline.Length; d += dbp) { IConstructPoint contructionPoint = new Point() as IConstructPoint; contructionPoint.ConstructAlong(polyline, esriSegmentExtension.esriNoExtension, d, false); isClear = createCount == 0 ? true : false; CreateFeatureTool.CreateFeature((IGeometry)contructionPoint, focusMap, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer, isClear); createCount++; } if (frmProperties.IsEnds) { isClear = createCount == 0 ? true : false; CreateFeatureTool.CreateFeature(polyline.FromPoint, focusMap, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer, isClear); CreateFeatureTool.CreateFeature(polyline.ToPoint, focusMap, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer, false); } } }
public static void EndSketch(bool bool_0, IActiveView iactiveView_0, IFeatureLayer ifeatureLayer_0) { INewLineFeedback feedback; IPointCollection pointCollection; IGeometryCollection mLastPartGeometry; try { if (SketchToolAssist.m_pPointColn != null) { SketchToolAssist.m_pPointColn.RemovePoints(0, SketchToolAssist.m_pPointColn.PointCount); } IPoint mPAnchorPoint = null; if (SketchToolAssist.Feedback != null) { if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Line) { feedback = (INewLineFeedback)SketchToolAssist.Feedback; mPAnchorPoint = SketchShareEx.m_pAnchorPoint; if (bool_0) { feedback.AddPoint(mPAnchorPoint); } SketchToolAssist.TempLine = feedback.Stop(); SketchShareEx.m_bInUse = false; if (SketchToolAssist.CurrentTask != null) { SketchToolAssist.CurrentTask.Excute(); } SketchToolAssist.Feedback = null; return; } else if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Fill) { INewPolygonFeedbackEx newPolygonFeedbackEx = (INewPolygonFeedbackEx)SketchToolAssist.Feedback; mPAnchorPoint = SketchShareEx.m_pAnchorPoint; if (bool_0) { newPolygonFeedbackEx.AddPoint(mPAnchorPoint); } SketchToolAssist.TempLine = newPolygonFeedbackEx.Stop(); SketchShareEx.m_bInUse = false; if (SketchToolAssist.CurrentTask != null) { SketchToolAssist.CurrentTask.Excute(); } SketchToolAssist.Feedback = null; return; } else if (SketchToolAssist.IsDrawTempLine != DrawTempGeometry.Point) { mPAnchorPoint = SketchShareEx.m_pAnchorPoint; IGeometry mPPointCollection = null; if (SketchToolAssist.Feedback is INewMultiPointFeedback) { ((INewMultiPointFeedback)SketchToolAssist.Feedback).Stop(); mPPointCollection = (IGeometry)SketchShareEx.m_pPointCollection; } else if (SketchToolAssist.Feedback is INewLineFeedback) { feedback = (INewLineFeedback)SketchToolAssist.Feedback; if (bool_0) { feedback.AddPoint(mPAnchorPoint); } IPolyline polyline = feedback.Stop(); if (polyline != null) { pointCollection = (IPointCollection)polyline; if (pointCollection.PointCount >= 2) { mPPointCollection = (IGeometry)pointCollection; if (SketchShareEx.m_LastPartGeometry != null && SketchShareEx.m_LastPartGeometry is IPolyline) { mLastPartGeometry = SketchShareEx.m_LastPartGeometry as IGeometryCollection; mLastPartGeometry.AddGeometryCollection(polyline as IGeometryCollection); mPPointCollection = mLastPartGeometry as IGeometry; SketchShareEx.m_LastPartGeometry = null; } } SketchShareEx.m_pLastPoint1 = null; SketchShareEx.m_pEndPoint1 = null; SketchShareEx.m_totalLength = 0; if ((mPPointCollection == null ? false : SketchShareEx.IsCreateParrel)) { object value = Missing.Value; object constructOffset = SketchShareEx.ConstructOffset; IConstructCurve polylineClass = new Polyline() as IConstructCurve; polylineClass.ConstructOffset(mPPointCollection as IPolycurve, SketchShareEx.m_offset, ref constructOffset, ref value); IGeometryCollection geometryCollection = new Polyline() as IGeometryCollection; geometryCollection.AddGeometryCollection(polylineClass as IGeometryCollection); polylineClass = new Polyline() as IConstructCurve; polylineClass.ConstructOffset(mPPointCollection as IPolycurve, -SketchShareEx.m_offset, ref constructOffset, ref value); geometryCollection.AddGeometryCollection(polylineClass as IGeometryCollection); mPPointCollection = geometryCollection as IGeometry; } } } else if (SketchToolAssist.Feedback is INewPolygonFeedback) { INewPolygonFeedback newPolygonFeedback = (INewPolygonFeedback)SketchToolAssist.Feedback; if (bool_0) { newPolygonFeedback.AddPoint(mPAnchorPoint); } IPolygon polygon = newPolygonFeedback.Stop(); if (polygon != null) { pointCollection = (IPointCollection)polygon; if (pointCollection.PointCount >= 3) { mPPointCollection = (IGeometry)pointCollection; if (!(mPPointCollection as ITopologicalOperator).IsSimple) { (mPPointCollection as ITopologicalOperator).Simplify(); } if (SketchShareEx.m_LastPartGeometry != null && SketchShareEx.m_LastPartGeometry is IPolygon) { mLastPartGeometry = SketchShareEx.m_LastPartGeometry as IGeometryCollection; mLastPartGeometry.AddGeometryCollection(polygon as IGeometryCollection); mPPointCollection = mLastPartGeometry as IGeometry; SketchShareEx.m_LastPartGeometry = null; } } SketchToolAssist.m_pPointColn = null; } } CreateFeatureTool.CreateFeature(mPPointCollection, iactiveView_0, ifeatureLayer_0); } else { SketchToolAssist.TempLine = SketchShareEx.m_pAnchorPoint; SketchShareEx.m_bInUse = false; if (SketchToolAssist.CurrentTask != null) { SketchToolAssist.CurrentTask.Excute(); } SketchToolAssist.Feedback = null; return; } } } catch (COMException cOMException1) { COMException cOMException = cOMException1; if (cOMException.ErrorCode != -2147220936) { Logger.Current.Error("", cOMException, ""); } else { MessageBox.Show("坐标值或量测值超出范围!", "创建要素", MessageBoxButtons.OK, MessageBoxIcon.Hand); } iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGeography, ifeatureLayer_0, null); } catch (Exception exception1) { Exception exception = exception1; iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGeography, ifeatureLayer_0, null); Logger.Current.Error("", exception, ""); } SketchShareEx.m_bInUse = false; SketchShareEx.LastPoint = null; SketchToolAssist.Feedback = null; SketchShareEx.PointCount = 0; SketchShareEx.m_bSnapSuccessful = false; SketchToolAssist.m_pAP = null; }
public static string SketchMouseDown(IPoint ipoint_0, IActiveView iactiveView_0, IFeatureLayer ifeatureLayer_0) { INewPolylineFeedback feedback; string str; INewPolygonFeedbackEx newPolygonFeedbackEx; object value; INewPolylineFeedback newPolylineFeedback; double num; string[] strArrays; double num1; double length; if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Line) { if (SketchToolAssist.Feedback != null) { feedback = (INewPolylineFeedback)SketchToolAssist.Feedback; feedback.AddPoint(SketchShareEx.m_pAnchorPoint); object obj = Missing.Value; object value1 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchShareEx.m_pAnchorPoint, ref obj, ref value1); } else { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewPolylineFeedback(); feedback = (INewPolylineFeedback)SketchToolAssist.Feedback; SketchToolAssist.Feedback.Display = iactiveView_0.ScreenDisplay; feedback.ChangeLineType((enumLineType)SketchToolAssist.LineType); feedback.Start(SketchShareEx.m_pAnchorPoint); SketchToolAssist.m_pPointColn = new Polyline(); object obj1 = Missing.Value; object value2 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchShareEx.m_pAnchorPoint, ref obj1, ref value2); } str = ""; } else if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Fill) { if (SketchToolAssist.Feedback != null) { newPolygonFeedbackEx = (INewPolygonFeedbackEx)SketchToolAssist.Feedback; newPolygonFeedbackEx.AddPoint(SketchShareEx.m_pAnchorPoint); object obj2 = Missing.Value; object value3 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchShareEx.m_pAnchorPoint, ref obj2, ref value3); } else { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewPolygonFeedbackEx(); newPolygonFeedbackEx = (INewPolygonFeedbackEx)SketchToolAssist.Feedback; SketchToolAssist.Feedback.Display = iactiveView_0.ScreenDisplay; newPolygonFeedbackEx.ChangeLineType((enumLineType)SketchToolAssist.LineType); newPolygonFeedbackEx.Start(SketchShareEx.m_pAnchorPoint); SketchToolAssist.m_pPointColn = new Polygon(); object obj3 = Missing.Value; object value4 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchShareEx.m_pAnchorPoint, ref obj3, ref value4); } str = ""; } else if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Point) { SketchToolAssist.TempLine = SketchShareEx.m_pAnchorPoint; str = ""; } else if (ifeatureLayer_0 == null) { str = ""; } else if (ifeatureLayer_0.FeatureClass != null) { string str1 = ""; string unit = ""; SketchShareEx.IsFixDirection = false; SketchShareEx.IsFixLength = false; if (SketchToolAssist.Feedback == null) { if (ifeatureLayer_0.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation) { try { Editor.EditWorkspace.StartEditOperation(); IFeature feature = ifeatureLayer_0.FeatureClass.CreateFeature(); int num2 = 0; object fieldValue = Editor.CurrentEditTemplate.GetFieldValue("SymbolID"); if (fieldValue != null) { num2 = Convert.ToInt32(fieldValue); } ITextElement textElement = CreateFeatureTool.MakeTextElement("文本", 0, ipoint_0, num2); IAnnotationFeature2 annotationFeature2 = feature as IAnnotationFeature2; annotationFeature2.LinkedFeatureID = -1; annotationFeature2.AnnotationClassID = 0; annotationFeature2.Annotation = textElement as IElement; EditorEvent.NewRow(feature); feature.Store(); Editor.EditWorkspace.StopEditOperation(); EditorEvent.AfterNewRow(feature); iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); iactiveView_0.FocusMap.ClearSelection(); iactiveView_0.FocusMap.SelectFeature(ifeatureLayer_0, feature); iactiveView_0.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } catch (Exception exception) { Logger.Current.Error("", exception, ""); } } else if (ifeatureLayer_0.FeatureClass.FeatureType != esriFeatureType.esriFTDimension) { value = Missing.Value; switch (ifeatureLayer_0.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: { CreateFeatureTool.CreateFeature(ipoint_0, iactiveView_0, ifeatureLayer_0); break; } case esriGeometryType.esriGeometryMultipoint: { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewMultiPointFeedback(); INewMultiPointFeedback newMultiPointFeedback = (INewMultiPointFeedback)SketchToolAssist.Feedback; SketchToolAssist.Feedback.Display = iactiveView_0.ScreenDisplay; SketchShareEx.m_pPointCollection = new Multipoint(); newMultiPointFeedback.Start(SketchShareEx.m_pPointCollection, ipoint_0); break; } case esriGeometryType.esriGeometryPolyline: { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewPolylineFeedback(); newPolylineFeedback = (INewPolylineFeedback)SketchToolAssist.Feedback; SketchToolAssist.Feedback.Display = iactiveView_0.ScreenDisplay; newPolylineFeedback.Start(ipoint_0); SketchShareEx.PointCount = 1; SketchShareEx.StartPoint = ipoint_0; SketchToolAssist.m_pPointColn = new Polyline(); SketchToolAssist.m_pPointColn.AddPoint(ipoint_0, ref value, ref value); unit = CommonHelper.GetUnit(iactiveView_0.FocusMap.MapUnits); num = CommonHelper.measureLength(ipoint_0, 1, ref SketchShareEx.m_pLastPoint1, ref SketchShareEx.m_pEndPoint1, ref SketchShareEx.m_totalLength); strArrays = new string[] { "距离 = ", num.ToString("0.###"), unit, ", 总长度 = ", SketchShareEx.m_totalLength.ToString("0.###"), unit }; str1 = string.Concat(strArrays); break; } case esriGeometryType.esriGeometryPolygon: { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewPolygonFeedbackEx(); INewPolygonFeedbackEx feedback1 = (INewPolygonFeedbackEx)SketchToolAssist.Feedback; SketchToolAssist.Feedback.Display = iactiveView_0.ScreenDisplay; feedback1.Start(ipoint_0); SketchShareEx.PointCount = 0; SketchToolAssist.m_pPointColn = new Polygon(); SketchShareEx.StartPoint = ipoint_0; unit = CommonHelper.GetUnit(iactiveView_0.FocusMap.MapUnits); num1 = CommonHelper.measureArea(ipoint_0, 1, ref SketchToolAssist.m_pPointColn); length = (SketchToolAssist.m_pPointColn as IPolygon).Length; if (num1 <= 0) { break; } str1 = string.Format("周长 = {0:0.###} {1} ,总面积 = {2:0.###} 平方{1}", length, unit, num1); break; } } } else { SketchToolAssist.Feedback = new NewDimensionFeedback(); try { (SketchToolAssist.Feedback as INewDimensionFeedback).ReferenceScale = (iactiveView_0 as IMap).ReferenceScale; (SketchToolAssist.Feedback as INewDimensionFeedback).ReferenceScaleUnits = (iactiveView_0 as IMap).MapUnits; } catch { } SketchToolAssist.Feedback.Display = iactiveView_0.ScreenDisplay; (SketchToolAssist.Feedback as INewDimensionFeedback).Start(ipoint_0); SketchShareEx.PointCount = 1; } } else if (SketchToolAssist.Feedback is INewDimensionFeedback) { SketchShareEx.PointCount = SketchShareEx.PointCount + 1; (SketchToolAssist.Feedback as INewDimensionFeedback).AddPoint(ipoint_0); if (SketchShareEx.PointCount == 3) { IDimensionShape dimensionShape = (SketchToolAssist.Feedback as INewDimensionFeedback).Stop(); CreateFeatureTool.CreateDimensionFeature(dimensionShape, (SketchToolAssist.Feedback as INewDimensionFeedback).DimensionType, iactiveView_0, ifeatureLayer_0); } } else if (SketchToolAssist.Feedback is INewMultiPointFeedback) { value = Missing.Value; SketchShareEx.m_pPointCollection.AddPoint(ipoint_0, ref value, ref value); (SketchToolAssist.Feedback as INewMultiPointFeedback).Start(SketchShareEx.m_pPointCollection, ipoint_0); } else if (SketchToolAssist.Feedback is INewLineFeedback) { newPolylineFeedback = (INewPolylineFeedback)SketchToolAssist.Feedback; value = Missing.Value; newPolylineFeedback.AddPoint(ipoint_0); SketchToolAssist.m_pPointColn.AddPoint(ipoint_0, ref value, ref value); SketchShareEx.PointCount = SketchShareEx.PointCount + 1; unit = CommonHelper.GetUnit(iactiveView_0.FocusMap.MapUnits); num = CommonHelper.measureLength(ipoint_0, 1, ref SketchShareEx.m_pLastPoint1, ref SketchShareEx.m_pEndPoint1, ref SketchShareEx.m_totalLength); strArrays = new string[] { "距离 = ", num.ToString("0.###"), unit, ", 总长度 = ", SketchShareEx.m_totalLength.ToString("0.###"), unit }; str1 = string.Concat(strArrays); } else if (SketchToolAssist.Feedback is INewPolygonFeedback) { ((INewPolygonFeedbackEx)SketchToolAssist.Feedback).AddPoint(ipoint_0); SketchShareEx.PointCount = SketchShareEx.PointCount + 1; unit = CommonHelper.GetUnit(iactiveView_0.FocusMap.MapUnits); num1 = CommonHelper.measureArea(ipoint_0, 1, ref SketchToolAssist.m_pPointColn); length = (SketchToolAssist.m_pPointColn as IPolygon).Length; if (num1 > 0) { str1 = string.Format("周长 = {0:0.###} {1} ,总面积 = {2:0.###} 平方{1}", length, unit, num1); } } if (SketchShareEx.LastPoint == null) { SketchShareEx.LastPoint = new ESRI.ArcGIS.Geometry.Point(); } SketchShareEx.LastPoint.PutCoords(ipoint_0.X, ipoint_0.Y); str = str1; } else { str = ""; } return(str); }
public static void EndSketch(IGeometry igeometry_0, IActiveView iactiveView_0, IFeatureLayer ifeatureLayer_0) { IGeometryCollection mLastPartGeometry; try { if (igeometry_0.GeometryType == esriGeometryType.esriGeometryPolyline) { IPolyline igeometry0 = igeometry_0 as IPolyline; if (SketchShareEx.m_LastPartGeometry != null && SketchShareEx.m_LastPartGeometry is IPolyline) { mLastPartGeometry = SketchShareEx.m_LastPartGeometry as IGeometryCollection; mLastPartGeometry.AddGeometryCollection(igeometry0 as IGeometryCollection); igeometry_0 = mLastPartGeometry as IGeometry; SketchShareEx.m_LastPartGeometry = null; } SketchShareEx.m_pLastPoint1 = null; SketchShareEx.m_pEndPoint1 = null; SketchShareEx.m_totalLength = 0; if ((igeometry_0 == null ? false : SketchShareEx.IsCreateParrel)) { object value = Missing.Value; object constructOffset = SketchShareEx.ConstructOffset; IConstructCurve polylineClass = new Polyline() as IConstructCurve; polylineClass.ConstructOffset(igeometry_0 as IPolycurve, SketchShareEx.m_offset, ref constructOffset, ref value); IGeometryCollection geometryCollection = new Polyline() as IGeometryCollection; geometryCollection.AddGeometryCollection(polylineClass as IGeometryCollection); polylineClass = new Polyline() as IConstructCurve; polylineClass.ConstructOffset(igeometry_0 as IPolycurve, -SketchShareEx.m_offset, ref constructOffset, ref value); geometryCollection.AddGeometryCollection(polylineClass as IGeometryCollection); igeometry_0 = geometryCollection as IGeometry; } } else if (igeometry_0.GeometryType == esriGeometryType.esriGeometryPolygon) { IPolygon polygon = igeometry_0 as IPolygon; if (SketchShareEx.m_LastPartGeometry != null && SketchShareEx.m_LastPartGeometry is IPolygon) { mLastPartGeometry = SketchShareEx.m_LastPartGeometry as IGeometryCollection; mLastPartGeometry.AddGeometryCollection(polygon as IGeometryCollection); igeometry_0 = mLastPartGeometry as IGeometry; SketchShareEx.m_LastPartGeometry = null; } SketchToolAssist.m_pPointColn = null; } CreateFeatureTool.CreateFeature(igeometry_0, iactiveView_0, ifeatureLayer_0); } catch (COMException cOMException1) { COMException cOMException = cOMException1; if (cOMException.ErrorCode != -2147220936) { Logger.Current.Error("", cOMException, ""); } else { MessageBox.Show("坐标值或量测值超出范围!", "创建要素", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } catch (Exception exception) { Logger.Current.Error("", exception, ""); } iactiveView_0.Refresh(); SketchShareEx.m_bInUse = false; SketchShareEx.LastPoint = null; SketchToolAssist.Feedback = null; SketchShareEx.PointCount = 0; SketchShareEx.m_pAnchorPoint = null; }
public override void OnMouseDown(int int_0, int Shift, int int_2, int int_3) { if (int_0 != 1) { return; } IPoint mapPoint = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_2, int_3); ISnappingResult snappingResult = this.pointSnapper.Snap(mapPoint); if (anchorPoint == null) { anchorPoint = new AnchorPoint() { Symbol = simpleMarkerSymbol as ISymbol }; } if (snappingResult != null) { mapPoint = snappingResult.Location; } if (_order == 0) { ellipseFeedback = new NewEllipseFeedback() as INewEllipseFeedback; ellipseFeedback.Display = activeView.ScreenDisplay; // ellipseFeedback.Symbol = lineSymbol as ISymbol; ellipseFeedback.Start(mapPoint); _order = 1; return; } if (_order == 1) { ellipseFeedback.SetPoint(mapPoint); ellipseFeedback.Refresh(activeView.ScreenDisplay.hDC); _order = 2; return; } IGeometry circularArc = ellipseFeedback.Stop(mapPoint) as IGeometry; ISegmentCollection polylineClass = null; object value = Missing.Value; IFeatureLayer featureLayer = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer; if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { polylineClass = new Polyline() as ISegmentCollection; ISegmentCollection segmentCollection = circularArc as ISegmentCollection; polylineClass.AddSegment(segmentCollection.Segment[0], ref value, ref value); CreateFeatureTool.CreateFeature(polylineClass as IGeometry, _context.FocusMap as IActiveView, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer); } else if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon) { return; } else { CreateFeatureTool.CreateFeature(circularArc as IGeometry, _context.FocusMap as IActiveView, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer); } _order = 0; ellipseFeedback = null; }
public override void OnMouseDown(int int_0, int Shift, int int_2, int int_3) { double num; double num1; double num2; double num3; if (int_0 == 1) { IActiveView activeView = _context.FocusMap as IActiveView; IPoint mPAnchorPoint = SketchShareEx.m_pAnchorPoint; if (SketchToolAssist.Feedback != null) { try { IEnvelope envelope = (SketchToolAssist.Feedback as INewEnvelopeFeedback).Stop(); IPointCollection polylineClass = null; IFeatureLayer featureLayer = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer; if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { polylineClass = new Polyline(); } else if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon) { return; } else { polylineClass = new Polygon(); } envelope.QueryCoords(out num, out num1, out num2, out num3); object value = Missing.Value; IPoint pointClass = new Point(); pointClass.PutCoords(num, num1); polylineClass.AddPoint(pointClass, ref value, ref value); pointClass = new Point(); pointClass.PutCoords(num, num3); polylineClass.AddPoint(pointClass, ref value, ref value); pointClass = new Point(); pointClass.PutCoords(num2, num3); polylineClass.AddPoint(pointClass, ref value, ref value); pointClass = new Point(); pointClass.PutCoords(num2, num1); polylineClass.AddPoint(pointClass, ref value, ref value); pointClass = new Point(); pointClass.PutCoords(num, num1); polylineClass.AddPoint(pointClass, ref value, ref value); CreateFeatureTool.CreateFeature(polylineClass as IGeometry, _context.FocusMap as IActiveView, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer); } catch (Exception exception) { CErrorLog.writeErrorLog(this, exception, ""); } SketchShareEx.m_bInUse = false; SketchShareEx.LastPoint = null; SketchShareEx.PointCount = 0; SketchToolAssist.Feedback = null; SketchShareEx.m_LastPartGeometry = null; } else { SketchToolAssist.Feedback = new NewEnvelopeFeedback(); SketchToolAssist.Feedback.Display = activeView.ScreenDisplay; (SketchToolAssist.Feedback as INewEnvelopeFeedback2).Start(mPAnchorPoint); SketchShareEx.m_bInUse = true; } } }
public static string SketchMouseDown(IActiveView pActiveView, IFeatureLayer pFeatureLayer) { INewPolylineFeedback feedback; string str; INewPolygonFeedbackEx newPolygonFeedbackEx; object value; INewPolylineFeedback newPolylineFeedback; INewPolygonFeedbackEx feedback1; double num; double length; if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Line) { if (SketchToolAssist.Feedback != null) { feedback = (INewPolylineFeedback)SketchToolAssist.Feedback; feedback.AddPoint(SketchToolAssist.m_pAnchorPoint); object obj = Missing.Value; object value1 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchToolAssist.m_pAnchorPoint, ref obj, ref value1); } else { SketchToolAssist.m_bInUse = true; SketchToolAssist.Feedback = new NewPolylineFeedback() as IDisplayFeedback2; feedback = (INewPolylineFeedback)SketchToolAssist.Feedback; SketchToolAssist.Feedback.Display = pActiveView.ScreenDisplay; feedback.ChangeLineType(SketchToolAssist.LineType); feedback.Start(SketchToolAssist.m_pAnchorPoint); SketchToolAssist.m_pPointColn = new Polyline(); object obj1 = Missing.Value; object value2 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchToolAssist.m_pAnchorPoint, ref obj1, ref value2); } str = ""; } else if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Fill) { if (SketchToolAssist.Feedback != null) { newPolygonFeedbackEx = (INewPolygonFeedbackEx)SketchToolAssist.Feedback; newPolygonFeedbackEx.AddPoint(SketchToolAssist.m_pAnchorPoint); object obj2 = Missing.Value; object value3 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchToolAssist.m_pAnchorPoint, ref obj2, ref value3); } else { SketchToolAssist.m_bInUse = true; SketchToolAssist.Feedback = new NewPolygonFeedbackEx(); newPolygonFeedbackEx = (INewPolygonFeedbackEx)SketchToolAssist.Feedback; SketchToolAssist.Feedback.Display = pActiveView.ScreenDisplay; newPolygonFeedbackEx.ChangeLineType(SketchToolAssist.LineType); newPolygonFeedbackEx.Start(SketchToolAssist.m_pAnchorPoint); SketchToolAssist.m_pPointColn = new Polygon(); object obj3 = Missing.Value; object value4 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchToolAssist.m_pAnchorPoint, ref obj3, ref value4); } str = ""; } else if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.Point) { SketchToolAssist.TempLine = SketchToolAssist.m_pAnchorPoint; str = ""; } else if (pFeatureLayer == null) { str = ""; } else if (pFeatureLayer.FeatureClass != null) { string str1 = ""; string unit = ""; SketchToolAssist.IsFixDirection = false; SketchToolAssist.IsFixLength = false; if (SketchToolAssist.Feedback == null) { if (pFeatureLayer.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation) { try { Editor.EditWorkspace.StartEditOperation(); IFeature feature = pFeatureLayer.FeatureClass.CreateFeature(); ITextElement textElement = CreateFeatureTool.MakeTextElement("文本", 0, SketchToolAssist.m_pAnchorPoint); IAnnotationFeature2 annotationFeature2 = feature as IAnnotationFeature2; annotationFeature2.LinkedFeatureID = -1; annotationFeature2.AnnotationClassID = 0; annotationFeature2.Annotation = textElement as IElement; EditorEvent.NewRow(feature); feature.Store(); Editor.EditWorkspace.StopEditOperation(); EditorEvent.AfterNewRow(feature); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); pActiveView.FocusMap.ClearSelection(); pActiveView.FocusMap.SelectFeature(pFeatureLayer, feature); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } catch (Exception exception) { Logger.Current.Error("", exception, ""); } } else if (pFeatureLayer.FeatureClass.FeatureType != esriFeatureType.esriFTDimension) { value = Missing.Value; switch (pFeatureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: { CreateFeatureTool.CreateFeature(SketchToolAssist.m_pAnchorPoint, pActiveView, pFeatureLayer); break; } case esriGeometryType.esriGeometryMultipoint: { SketchToolAssist.m_bInUse = true; SketchToolAssist.Feedback = new NewMultiPointFeedback(); INewMultiPointFeedback newMultiPointFeedback = (INewMultiPointFeedback)SketchToolAssist.Feedback; SketchToolAssist.Feedback.Display = pActiveView.ScreenDisplay; SketchToolAssist.m_pPointCollection = new Multipoint(); newMultiPointFeedback.Start(SketchToolAssist.m_pPointCollection, SketchToolAssist.m_pAnchorPoint); break; } case esriGeometryType.esriGeometryPolyline: { SketchToolAssist.m_bInUse = true; SketchToolAssist.Feedback = new NewPolylineFeedback(); newPolylineFeedback = (INewPolylineFeedback)SketchToolAssist.Feedback; newPolylineFeedback.ChangeLineType(SketchToolAssist.LineType); SketchToolAssist.Feedback.Display = pActiveView.ScreenDisplay; newPolylineFeedback.Start(SketchToolAssist.m_pAnchorPoint); SketchToolAssist.m_PointCount = 1; SketchToolAssist.StartPoint = SketchToolAssist.m_pAnchorPoint; SketchToolAssist.m_pPointColn = new Polyline(); SketchToolAssist.m_pPointColn.AddPoint(SketchToolAssist.m_pAnchorPoint, ref value, ref value); unit = CommonHelper.GetUnit(pActiveView.FocusMap.MapUnits); break; } case esriGeometryType.esriGeometryPolygon: { SketchToolAssist.m_bInUse = true; SketchToolAssist.Feedback = new NewPolygonFeedbackEx(); feedback1 = (INewPolygonFeedbackEx)SketchToolAssist.Feedback; feedback1.ChangeLineType(SketchToolAssist.LineType); SketchToolAssist.Feedback.Display = pActiveView.ScreenDisplay; feedback1.Start(SketchToolAssist.m_pAnchorPoint); SketchToolAssist.m_PointCount = 0; SketchToolAssist.m_pPointColn = new Polygon(); SketchToolAssist.StartPoint = SketchToolAssist.m_pAnchorPoint; unit = CommonHelper.GetUnit(pActiveView.FocusMap.MapUnits); num = CommonHelper.measureArea(SketchToolAssist.m_pAnchorPoint, 1, ref SketchToolAssist.m_pPointColn); length = (SketchToolAssist.m_pPointColn as IPolygon).Length; if (num <= 0) { break; } str1 = string.Format("周长 = {0:0.###} {1} ,总面积 = {2:0.###} 平方{1}", length, unit, num); break; } } } else { SketchToolAssist.Feedback = new NewDimensionFeedback(); try { (SketchToolAssist.Feedback as INewDimensionFeedback).ReferenceScale = (pActiveView as IMap).ReferenceScale; (SketchToolAssist.Feedback as INewDimensionFeedback).ReferenceScaleUnits = (pActiveView as IMap).MapUnits; } catch { } SketchToolAssist.Feedback.Display = pActiveView.ScreenDisplay; (SketchToolAssist.Feedback as INewDimensionFeedback).Start(SketchToolAssist.m_pAnchorPoint); SketchToolAssist.m_PointCount = 1; } } else if (SketchToolAssist.Feedback is INewDimensionFeedback) { SketchToolAssist.m_PointCount = SketchToolAssist.m_PointCount + 1; (SketchToolAssist.Feedback as INewDimensionFeedback).AddPoint(SketchToolAssist.m_pAnchorPoint); if (SketchToolAssist.m_PointCount == 3) { IDimensionShape dimensionShape = (SketchToolAssist.Feedback as INewDimensionFeedback).Stop(); CreateFeatureTool.CreateDimensionFeature(dimensionShape, (SketchToolAssist.Feedback as INewDimensionFeedback).DimensionType, pActiveView, pFeatureLayer); } } else if (SketchToolAssist.Feedback is INewMultiPointFeedback) { value = Missing.Value; SketchToolAssist.m_pPointCollection.AddPoint(SketchToolAssist.m_pAnchorPoint, ref value, ref value); (SketchToolAssist.Feedback as INewMultiPointFeedback).Start(SketchToolAssist.m_pPointCollection, SketchToolAssist.m_pAnchorPoint); } else if (SketchToolAssist.Feedback is INewLineFeedback) { newPolylineFeedback = (INewPolylineFeedback)SketchToolAssist.Feedback; value = Missing.Value; newPolylineFeedback.AddPoint(SketchToolAssist.m_pAnchorPoint); SketchToolAssist.m_pPointColn.AddPoint(SketchToolAssist.m_pAnchorPoint, ref value, ref value); SketchToolAssist.m_PointCount = SketchToolAssist.m_PointCount + 1; unit = CommonHelper.GetUnit(pActiveView.FocusMap.MapUnits); } else if (SketchToolAssist.Feedback is INewPolygonFeedback) { feedback1 = (INewPolygonFeedbackEx)SketchToolAssist.Feedback; feedback1.AddPoint(SketchToolAssist.m_pAnchorPoint); SketchToolAssist.m_PointCount = SketchToolAssist.m_PointCount + 1; unit = CommonHelper.GetUnit(pActiveView.FocusMap.MapUnits); num = CommonHelper.measureArea(SketchToolAssist.m_pAnchorPoint, 1, ref SketchToolAssist.m_pPointColn); length = (SketchToolAssist.m_pPointColn as IPolygon).Length; if (num > 0) { str1 = string.Format("周长 = {0:0.###} {1} ,总面积 = {2:0.###} 平方{1}", length, unit, num); } object value5 = Missing.Value; object obj5 = Missing.Value; SketchToolAssist.m_pPointColn.AddPoint(SketchToolAssist.m_pAnchorPoint, ref value5, ref obj5); } if (SketchToolAssist.LastPoint == null) { SketchToolAssist.LastPoint = new ESRI.ArcGIS.Geometry.Point(); } SketchToolAssist.LastPoint.PutCoords(SketchToolAssist.m_pAnchorPoint.X, SketchToolAssist.m_pAnchorPoint.Y); str = str1; } else { str = ""; } return(str); }
private void method_2(IPoint ipoX) { string unit; double num; string[] str; string str1; double num1; string str2; SketchShareEx.IsFixDirection = false; SketchShareEx.IsFixLength = false; IActiveView focusMap = (IActiveView)_context.FocusMap; if (!SketchShareEx.m_bInUse) { if (Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer != null) { IFeatureLayer featureLayer = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer; if (featureLayer.FeatureClass == null) { return; } if (featureLayer.FeatureClass.FeatureType != esriFeatureType.esriFTAnnotation) { switch (featureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: { CreateFeatureTool.CreateFeature(ipoX, _context.FocusMap as IActiveView, Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer); break; } case esriGeometryType.esriGeometryMultipoint: { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewMultiPointFeedback(); INewMultiPointFeedback feedback = (INewMultiPointFeedback)SketchToolAssist.Feedback; SketchShareEx.m_pPointCollection = new Multipoint(); feedback.Start(SketchShareEx.m_pPointCollection, ipoX); break; } case esriGeometryType.esriGeometryPolyline: { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewLineFeedback(); ((INewLineFeedback)SketchToolAssist.Feedback).Start(ipoX); SketchShareEx.PointCount = SketchShareEx.PointCount + 1; if (!this.bool_0) { break; } unit = Common.GetUnit(_context.FocusMap.MapUnits); num = Common.measureLength(ipoX, 1, ref SketchShareEx.m_pLastPoint1, ref SketchShareEx.m_pEndPoint1, ref SketchShareEx.m_totalLength); str = new string[] { "距离 = ", num.ToString("0.###"), unit, ", 总长度 = ", SketchShareEx.m_totalLength.ToString("0.###"), unit }; str1 = string.Concat(str); _context.SetStatus(str1); break; } case esriGeometryType.esriGeometryPolygon: { SketchShareEx.m_bInUse = true; SketchToolAssist.Feedback = new NewPolygonFeedback(); ((INewPolygonFeedback)SketchToolAssist.Feedback).Start(ipoX); SketchShareEx.PointCount = SketchShareEx.PointCount + 1; if (!this.bool_0) { break; } unit = string.Concat(" 平方", Common.GetUnit(_context.FocusMap.MapUnits)); num1 = Common.measureArea(ipoX, 1, ref SketchToolAssist.m_pPointColn); if (num1 <= 0) { break; } str2 = string.Concat("总面积 = ", num1.ToString("0.###"), unit); _context.SetStatus(str2); break; } } } else { try { Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation(); IFeature feature = featureLayer.FeatureClass.CreateFeature(); ITextElement textElement = CreateFeatureTool.MakeTextElement("文本", 0, ipoX); IAnnotationFeature2 annotationFeature2 = feature as IAnnotationFeature2; annotationFeature2.LinkedFeatureID = -1; annotationFeature2.AnnotationClassID = 0; annotationFeature2.Annotation = textElement as IElement; EditorEvent.NewRow(feature); feature.Store(); Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation(); EditorEvent.AfterNewRow(feature); focusMap.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); _context.FocusMap.ClearSelection(); _context.FocusMap.SelectFeature(featureLayer, feature); focusMap.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } catch (Exception exception) { CErrorLog.writeErrorLog(this, exception, ""); } } if (SketchToolAssist.Feedback != null) { SketchToolAssist.Feedback.Display = focusMap.ScreenDisplay; } } else { return; } } else if (SketchToolAssist.Feedback is INewMultiPointFeedback) { object value = Missing.Value; SketchShareEx.m_pPointCollection.AddPoint(ipoX, ref value, ref value); } else if (SketchToolAssist.Feedback is INewLineFeedback) { ((INewLineFeedback)SketchToolAssist.Feedback).AddPoint(ipoX); SketchShareEx.PointCount = SketchShareEx.PointCount + 1; if (this.bool_0) { unit = Common.GetUnit(_context.FocusMap.MapUnits); num = Common.measureLength(ipoX, 1, ref SketchShareEx.m_pLastPoint1, ref SketchShareEx.m_pEndPoint1, ref SketchShareEx.m_totalLength); str = new string[] { "距离 = ", num.ToString("0.###"), unit, ", 总长度 = ", SketchShareEx.m_totalLength.ToString("0.###"), unit }; str1 = string.Concat(str); _context.SetStatus(str1); } } else if (SketchToolAssist.Feedback is INewPolygonFeedback) { ((INewPolygonFeedback)SketchToolAssist.Feedback).AddPoint(ipoX); SketchShareEx.PointCount = SketchShareEx.PointCount + 1; if (this.bool_0) { unit = string.Concat(" 平方", Common.GetUnit(_context.FocusMap.MapUnits)); num1 = Common.measureArea(ipoX, 1, ref SketchToolAssist.m_pPointColn); if (num1 > 0) { str2 = string.Concat("总面积 = ", num1.ToString("0.###"), unit); _context.SetStatus(str2); } } } SketchShareEx.LastPoint = new ESRI.ArcGIS.Geometry.Point(); SketchShareEx.LastPoint.PutCoords(ipoX.X, ipoX.Y); }