protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { if (arg.Button != System.Windows.Forms.MouseButtons.Left) { return; } try { //Get the active view from the ArcMap static class. IActiveView activeView = ArcMap.Document.FocusMap as IActiveView; var point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y) as IPoint; ISnappingResult snapResult = null; //Try to snap the current position snapResult = m_Snapper.Snap(point); m_SnappingFeedback.Update(null, 0); if (snapResult != null && snapResult.Location != null) { point = snapResult.Location; } Mediator.NotifyColleagues(Constants.NEW_MAP_POINT, point); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void OnMouseMove(int Button, int shift, int X, int Y) { //Snap the mouse location if (m_etoolPhase != ToolPhase.Intersection) { m_activePoint = m_editor.Display.DisplayTransformation.ToMapPoint(X, Y); ISnappingResult snapResult = m_snapper.Snap(m_activePoint); m_snappingFeedback.Update(snapResult, 0); if (snapResult != null) { m_activePoint = snapResult.Location; } } }
protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { if (arg.Button != System.Windows.Forms.MouseButtons.Left) { return; } try { var point = GetMapPoint(arg.X, arg.Y); if (point == null) { return; } ISnappingResult snapResult = null; //Try to snap the current position if (m_Snapper != null) { snapResult = m_Snapper.Snap(point); } if (m_SnappingFeedback != null) { m_SnappingFeedback.Update(null, 0); } if (snapResult != null && snapResult.Location != null) { point = snapResult.Location; } if (!SelectFeatureEnable) { Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.VALIDATE_MAP_POINT, point); } else { Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.SELECT_MAP_POINT, point); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg) { if (arg.Button != System.Windows.Forms.MouseButtons.Left) { return; } try { var point = GetMapPoint(arg.X, arg.Y); ISnappingResult snapResult = null; //Try to snap the current position snapResult = m_Snapper.Snap(point); m_SnappingFeedback.Update(null, 0); if (snapResult != null && snapResult.Location != null) { point = snapResult.Location; } Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.NEW_MAP_POINT, point); } catch { } }
public static IPoint getSnapPoint(IPoint ptIn) { IPoint SnapPt = ptIn; try { if (m_bStartSnap) { if (m_Snapper == null) { StartSnappingEnv(); } ISnappingResult snapResult = m_Snapper.Snap(ptIn); m_SnappingFeedback.Update(snapResult, 0); //更新当前点为捕捉到的点 if (snapResult != null) { SnapPt = snapResult.Location; } } return(SnapPt); } catch { return(SnapPt); } }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { // TODO: Add ToolNewDisplacement.OnMouseMove implementation IMapControl3 m_MapControl = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl3; m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC); m_snappingFeed.UnInitialize(); m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true); m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC); m_SnappingEnvironment.SnappingType = esriSnappingType.esriSnappingTypePoint; //起始点 if (bFlag == true) { IPoint point = TransformToMapPoint(X, Y); IPointSnapper ptSnapper = m_SnappingEnvironment.PointSnapper; ISnappingResult snapresult = ptSnapper.Snap(point); if (snapresult != null) { // IEngineEditProperties2 ep2 = env as IEngineEditProperties2; //if (ep2.SnapTips == true) { if (m_snappingFeed != null) { if (snapresult.Description == pIMULayer.Name + ": Point") { m_snappingFeed.Update(snapresult, m_MapControl.ActiveView.ScreenDisplay.hDC); } } } } else { m_snappingFeed.Update(null, m_MapControl.ActiveView.ScreenDisplay.hDC); } } // 结束点 if (bFlag == false) { IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { IPoint mapPoint = pMapCtr.ToMapPoint(X, Y); m_NewLineFeedback.MoveTo(mapPoint); IPoint point = TransformToMapPoint(X, Y); IPointSnapper ptSnapper = m_SnappingEnvironment.PointSnapper; ISnappingResult snapresult = ptSnapper.Snap(point); if (snapresult != null) { // IEngineEditProperties2 ep2 = env as IEngineEditProperties2; //if (ep2.SnapTips == true) { if (m_snappingFeed != null) { if (snapresult.Description == pCenterlinePointLayer.Name + ": Point") { m_snappingFeed.Update(snapresult, m_MapControl.ActiveView.ScreenDisplay.hDC); } } } } else { m_snappingFeed.Update(null, m_MapControl.ActiveView.ScreenDisplay.hDC); } } } }