public override void OnMouseMove(int Button, int Shift, int x, int y) { IActiveView focusMap = (IActiveView)_context.ActiveView; pPoint = focusMap.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); ISnappingResult snappingResult = this.pointSnapper.Snap(this.pPoint); if (snappingResult == null) { if (anchorPoint == null) { anchorPoint = new AnchorPoint() { Symbol = simpleMarkerSymbol as ISymbol }; } anchorPoint.MoveTo(this.pPoint, focusMap.ScreenDisplay); } else { pPoint = snappingResult.Location; if (this.anchorPoint == null) { anchorPoint = new AnchorPoint() { Symbol = simpleMarkerSymbol as ISymbol }; } anchorPoint.MoveTo(this.pPoint, focusMap.ScreenDisplay); } //base.OnMouseMove(Button, Shift, x, y); }
public override void OnMouseMove(int int_0, int int_1, int int_2, int int_3) { if (_order == 0) { 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; } anchorPoint.MoveTo(mapPoint, activeView.ScreenDisplay); rectangleFeedback.MoveTo(mapPoint); }
private void method_1(IPoint ipoint_1, esriSimpleMarkerStyle esriSimpleMarkerStyle_0) { this.ianchorPoint_0 = new AnchorPoint() { Symbol = this.isimpleMarkerSymbol_0 as ISymbol }; this.ianchorPoint_0.MoveTo(ipoint_1, this.iactiveView_0.ScreenDisplay); }
internal static void AddNewAnchorPt(IPoint ipoint_0, esriSimpleMarkerStyle esriSimpleMarkerStyle_0, IActiveView pActiveView) { SketchToolAssist.m_pAP = new AnchorPoint() { Symbol = SketchToolAssist.m_pSym as ISymbol }; SketchToolAssist.m_pAP.MoveTo(ipoint_0, pActiveView.ScreenDisplay); }
private static void old_acctor_mc() { SketchToolAssist.m_LastPartGeometry = null; SketchToolAssist.IsCreateParrel = false; SketchToolAssist.m_offset = 1; SketchToolAssist.ConstructOffset = 5; SketchToolAssist.m_Feedback = null; SketchToolAssist.m_pUnDoPoint = null; SketchToolAssist.m_pLastPoint1 = null; SketchToolAssist.m_pEndPoint1 = null; SketchToolAssist.m_bShowVlaue = true; SketchToolAssist.m_totalLength = 0; SketchToolAssist.m_pPointColn = null; SketchToolAssist.m_pAP = null; SketchToolAssist.m_pPointCollection = null; SketchToolAssist.m_PointCount = 0; SketchToolAssist.m_bInUse = false; SketchToolAssist.m_pSym = new SimpleMarkerSymbol(); SketchToolAssist.m_psnaper = new PointSnapper(); SketchToolAssist.Init(); }
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 void Snap2Point(IPoint ipoint_1, IPoint ipoint_2, esriSimpleMarkerStyle esriSimpleMarkerStyle_0) { ISnappingResult snappingResult; this.AnchorPoint = ipoint_1; if (!Editor.UseOldSnap) { snappingResult = SketchToolAssist.m_psnaper.Snap(this.AnchorPoint); if (snappingResult == null) { if (this.ianchorPoint_0 == null) { this.ianchorPoint_0 = new AnchorPoint() { Symbol = this.isimpleMarkerSymbol_0 as ISymbol }; } this.ianchorPoint_0.MoveTo(this.AnchorPoint, (this._appContext.MapControl.Map as IActiveView).ScreenDisplay); } else { this.AnchorPoint = snappingResult.Location; if (this.ianchorPoint_0 == null) { this.ianchorPoint_0 = new AnchorPoint() { Symbol = this.isimpleMarkerSymbol_0 as ISymbol }; } this.ianchorPoint_0.MoveTo(this.AnchorPoint, (this._appContext.MapControl.Map as IActiveView).ScreenDisplay); } } else { IAppContext application = ApplicationRef.AppContext; snappingResult = this.method_0(this.AnchorPoint); if (snappingResult == null) { if (this.ianchorPoint_0 == null) { this.ianchorPoint_0 = new AnchorPoint() { Symbol = this.isimpleMarkerSymbol_0 as ISymbol }; } this.ianchorPoint_0.MoveTo(this.AnchorPoint, (this._appContext.MapControl.Map as IActiveView).ScreenDisplay); } else { this.AnchorPoint = snappingResult.Location; if (this.ianchorPoint_0 == null) { this.ianchorPoint_0 = new AnchorPoint() { Symbol = this.isimpleMarkerSymbol_0 as ISymbol }; } this.ianchorPoint_0.MoveTo(this.AnchorPoint, (this._appContext.MapControl.Map as IActiveView).ScreenDisplay); } } }
public bool Snap2Point2(IPoint ipoint_1, IPoint ipoint_2, esriSimpleMarkerStyle esriSimpleMarkerStyle_0) { if (!Editor.UseOldSnap) { ISnappingResult snappingResult = SketchToolAssist.m_psnaper.Snap(ipoint_1); if (snappingResult == null) { if (this.ianchorPoint_0 == null) { this.ianchorPoint_0 = new AnchorPoint() { Symbol = this.isimpleMarkerSymbol_0 as ISymbol }; } this.ianchorPoint_0.MoveTo(ipoint_1, this.iactiveView_0.ScreenDisplay); this.bool_0 = false; } else { ipoint_2 = snappingResult.Location; this.bool_0 = true; if (this.ianchorPoint_0 != null) { this.ianchorPoint_0.MoveTo(snappingResult.Location, this.iactiveView_0.ScreenDisplay); } else { this.method_1(snappingResult.Location, esriSimpleMarkerStyle_0); } } } else { ISimpleMarkerSymbol isimpleMarkerSymbol0 = this.isimpleMarkerSymbol_0; isimpleMarkerSymbol0.Style = esriSimpleMarkerStyle_0; if (ipoint_2 == null) { ipoint_2 = new ESRI.ArcGIS.Geometry.Point(); } ipoint_2.PutCoords(ipoint_1.X, ipoint_1.Y); if (this.iengineSnapEnvironment_0 is SnapEnvironment) { if ((!ApplicationRef.AppContext.Config.UseSnap ? true : !(this.iengineSnapEnvironment_0 as SnapEnvironment).SnapPoint(ipoint_1, ipoint_2))) { this.bool_0 = false; if (this.ianchorPoint_0 != null) { this.ianchorPoint_0.Symbol = (ISymbol)isimpleMarkerSymbol0; this.ianchorPoint_0.MoveTo(ipoint_1, this.iactiveView_0.ScreenDisplay); } else { this.method_1(ipoint_1, esriSimpleMarkerStyle_0); } } else { this.bool_0 = true; if (this.ianchorPoint_0 != null) { this.ianchorPoint_0.Symbol = (ISymbol)isimpleMarkerSymbol0; this.ianchorPoint_0.MoveTo(ipoint_2, this.iactiveView_0.ScreenDisplay); } else { this.method_1(ipoint_2, esriSimpleMarkerStyle_0); } } } else if ((this.iengineSnapEnvironment_0 == null || !ApplicationRef.AppContext.Config.UseSnap ? true : !this.iengineSnapEnvironment_0.SnapPoint(ipoint_2))) { this.bool_0 = false; if (this.ianchorPoint_0 != null) { this.ianchorPoint_0.Symbol = (ISymbol)isimpleMarkerSymbol0; this.ianchorPoint_0.MoveTo(ipoint_1, this.iactiveView_0.ScreenDisplay); } else { this.method_1(ipoint_1, esriSimpleMarkerStyle_0); } } else { this.bool_0 = true; if (this.ianchorPoint_0 != null) { this.ianchorPoint_0.Symbol = (ISymbol)isimpleMarkerSymbol0; this.ianchorPoint_0.MoveTo(ipoint_2, this.iactiveView_0.ScreenDisplay); } else { this.method_1(ipoint_2, esriSimpleMarkerStyle_0); } } } return(this.bool_0); }
public static string SketchMouseMove(IPoint ipoint_0) { string str; double x; double y; double num; ISnappingResult snappingResult; string unit; if (SketchToolAssist.Map != null) { IMap map = SketchToolAssist.Map; string str1 = ""; bool flag = true; if (SketchToolAssist.LastPoint != null) { if (SketchToolAssist.IsFixDirection) { x = ipoint_0.X - SketchToolAssist.LastPoint.X; y = ipoint_0.Y - SketchToolAssist.LastPoint.Y; num = CommonHelper.azimuth(SketchToolAssist.LastPoint, ipoint_0); double num1 = Math.Sqrt(x * x + y * y); double num2 = num1 * Math.Cos(SketchToolAssist.FixDirection * 3.14159265358979 / 180); double num3 = num1 * Math.Sin(SketchToolAssist.FixDirection * 3.14159265358979 / 180); if (!(SketchToolAssist.FixDirection < 0 ? true : SketchToolAssist.FixDirection >= 90)) { if ((num < 90 + SketchToolAssist.FixDirection ? false : num < 270 + SketchToolAssist.FixDirection)) { num2 = -num2; num3 = -num3; } } else if (!(SketchToolAssist.FixDirection < 90 ? true : SketchToolAssist.FixDirection >= 270)) { if ((num < SketchToolAssist.FixDirection - 90 ? true : num >= SketchToolAssist.FixDirection + 90)) { num2 = -num2; num3 = -num3; } } else if ((num < SketchToolAssist.FixDirection - 270 ? false : num < SketchToolAssist.FixDirection - 90)) { num2 = -num2; num3 = -num3; } flag = false; x = SketchToolAssist.LastPoint.X + num2; y = SketchToolAssist.LastPoint.Y + num3; ipoint_0.PutCoords(x, y); } else if (SketchToolAssist.IsFixLength) { num = CommonHelper.azimuth(SketchToolAssist.LastPoint, ipoint_0); x = SketchToolAssist.FixLength * Math.Cos(num * 3.14159265358979 / 180); y = SketchToolAssist.FixLength * Math.Sin(num * 3.14159265358979 / 180); x = SketchToolAssist.LastPoint.X + x; y = SketchToolAssist.LastPoint.Y + y; flag = false; ipoint_0.PutCoords(x, y); } } SketchToolAssist.m_pAnchorPoint = ipoint_0; if (flag) { if (!Editor.UseOldSnap) { snappingResult = SketchToolAssist.m_psnaper.Snap(SketchToolAssist.m_pAnchorPoint); if (snappingResult == null) { if (SketchToolAssist.m_pAP == null) { SketchToolAssist.m_pAP = new AnchorPoint() { Symbol = SketchToolAssist.m_pSym as ISymbol }; } SketchToolAssist.m_pAP.MoveTo(SketchToolAssist.m_pAnchorPoint, (map as IActiveView).ScreenDisplay); } else { SketchToolAssist.m_pAnchorPoint = snappingResult.Location; if (SketchToolAssist.m_pAP == null) { SketchToolAssist.m_pAP = new AnchorPoint() { Symbol = SketchToolAssist.m_pSym as ISymbol }; } SketchToolAssist.m_pAP.MoveTo(SketchToolAssist.m_pAnchorPoint, (map as IActiveView).ScreenDisplay); } } else { IAppContext application = ApplicationRef.AppContext; snappingResult = SketchToolAssist.OldSnap(SketchToolAssist.m_pAnchorPoint, map as IActiveView, application.Config.EngineSnapEnvironment); if (snappingResult == null) { if (SketchToolAssist.m_pAP == null) { SketchToolAssist.m_pAP = new AnchorPoint() { Symbol = SketchToolAssist.m_pSym as ISymbol }; } SketchToolAssist.m_pAP.MoveTo(SketchToolAssist.m_pAnchorPoint, (map as IActiveView).ScreenDisplay); } else { SketchToolAssist.m_pAnchorPoint = snappingResult.Location; if (SketchToolAssist.m_pAP == null) { SketchToolAssist.m_pAP = new AnchorPoint() { Symbol = SketchToolAssist.m_pSym as ISymbol }; } SketchToolAssist.m_pAP.MoveTo(SketchToolAssist.m_pAnchorPoint, (map as IActiveView).ScreenDisplay); } } } if (SketchToolAssist.Feedback != null) { SketchToolAssist.Feedback.MoveTo(SketchToolAssist.m_pAnchorPoint); } if (SketchToolAssist.IsDrawTempLine == DrawTempGeometry.None) { if (SketchToolAssist.m_bShowVlaue) { if (SketchToolAssist.Feedback is INewLineFeedback) { unit = CommonHelper.GetUnit(map.MapUnits); double num4 = CommonHelper.measureLength(ipoint_0, 2, ref SketchToolAssist.m_pLastPoint1, ref SketchToolAssist.m_pEndPoint1, ref SketchToolAssist.m_totalLength); string[] strArrays = new string[] { "距离 = ", num4.ToString("0.###"), unit, ", 总长度 = ", SketchToolAssist.m_totalLength.ToString("0.###"), unit }; str1 = string.Concat(strArrays); } else if (SketchToolAssist.Feedback is INewPolygonFeedback) { unit = CommonHelper.GetUnit(map.MapUnits); double num5 = CommonHelper.measureArea(ipoint_0, 2, ref SketchToolAssist.m_pPointColn); double length = (SketchToolAssist.m_pPointColn as IPolygon).Length; if (num5 > 0) { str1 = string.Format("周长 = {0:0.###} {1} ,总面积 = {2:0.###} 平方{1}", length, unit, num5); } } } str = str1; } else { str = ""; } } else { str = ""; } return(str); }
public static void EndSketch(bool bool_0, IActiveView pActiveView, IFeatureLayer pFeatureLayer) { 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 = SketchToolAssist.m_pAnchorPoint; if (bool_0) { feedback.AddPoint(mPAnchorPoint); } SketchToolAssist.TempLine = feedback.Stop(); SketchToolAssist.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 = SketchToolAssist.m_pAnchorPoint; if (bool_0) { newPolygonFeedbackEx.AddPoint(mPAnchorPoint); } SketchToolAssist.TempLine = newPolygonFeedbackEx.Stop(); SketchToolAssist.m_bInUse = false; if (SketchToolAssist.CurrentTask != null) { SketchToolAssist.CurrentTask.Excute(); } SketchToolAssist.Feedback = null; return; } else if (SketchToolAssist.IsDrawTempLine != DrawTempGeometry.Point) { mPAnchorPoint = SketchToolAssist.m_pAnchorPoint; IGeometry mPPointCollection = null; if (SketchToolAssist.Feedback is INewMultiPointFeedback) { ((INewMultiPointFeedback)SketchToolAssist.Feedback).Stop(); mPPointCollection = (IGeometry)SketchToolAssist.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 (SketchToolAssist.m_LastPartGeometry != null && SketchToolAssist.m_LastPartGeometry is IPolyline) { mLastPartGeometry = SketchToolAssist.m_LastPartGeometry as IGeometryCollection; mLastPartGeometry.AddGeometryCollection(polyline as IGeometryCollection); mPPointCollection = mLastPartGeometry as IGeometry; SketchToolAssist.m_LastPartGeometry = null; } } SketchToolAssist.m_pLastPoint1 = null; SketchToolAssist.m_pEndPoint1 = null; SketchToolAssist.m_totalLength = 0; if ((mPPointCollection == null ? false : SketchToolAssist.IsCreateParrel)) { object value = Missing.Value; object constructOffset = SketchToolAssist.ConstructOffset; IConstructCurve polylineClass = new Polyline() as IConstructCurve; polylineClass.ConstructOffset(mPPointCollection as IPolycurve, SketchToolAssist.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, -SketchToolAssist.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 (SketchToolAssist.m_LastPartGeometry != null && SketchToolAssist.m_LastPartGeometry is IPolygon) { mLastPartGeometry = SketchToolAssist.m_LastPartGeometry as IGeometryCollection; mLastPartGeometry.AddGeometryCollection(polygon as IGeometryCollection); mPPointCollection = mLastPartGeometry as IGeometry; SketchToolAssist.m_LastPartGeometry = null; } } SketchToolAssist.m_pPointColn = null; } } CreateFeatureTool.CreateFeature(mPPointCollection, pActiveView, pFeatureLayer); } else { SketchToolAssist.TempLine = SketchToolAssist.m_pAnchorPoint; SketchToolAssist.m_bInUse = false; if (SketchToolAssist.CurrentTask != null) { SketchToolAssist.CurrentTask.Excute(); } SketchToolAssist.Feedback = null; return; } } } catch (COMException cOMException1) { COMException cOMException = cOMException1; if (cOMException.ErrorCode == -2147220936) { MessageBox.Show("坐标值或量测值超出范围!", "创建要素", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else if (cOMException.ErrorCode != -2147220943) { Logger.Current.Error("", cOMException, ""); } else { MessageBox.Show("面剪切操作无法将面的所有部分划分到剪切线的左侧或右侧!", "编辑", MessageBoxButtons.OK, MessageBoxIcon.Hand); } pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pFeatureLayer, null); } catch (Exception exception1) { Exception exception = exception1; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, pFeatureLayer, null); Logger.Current.Error("", exception, ""); } SketchToolAssist.m_bInUse = false; SketchToolAssist.LastPoint = null; SketchToolAssist.Feedback = null; SketchToolAssist.m_PointCount = 0; SketchToolAssist.m_pAP = null; }