예제 #1
0
        public override void OnMouseDown(int button, int shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }

            IActiveView     activeView     = _context.ActiveView;
            IPoint          point          = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            ISnappingResult snappingResult = _pointSnapper.Snap(point);

            if (snappingResult != null)
            {
                point = snappingResult.Location;
            }

            if (_lineFeedback == null)
            {
                _lineFeedback = new NewLineFeedbackClass()
                {
                    Display = activeView.ScreenDisplay
                };
                _lineFeedback.Start(point);
            }
            else
            {
                _lineFeedback.AddPoint(point);
            }
        }
예제 #2
0
        public override void OnDblClick()
        {
            try
            {
                if (_lineFeedback == null)
                {
                    return;
                }
                IPolyline polyline = _lineFeedback.Stop();
                _context.ActiveView.Refresh();
                _lineFeedback = null;
                if (polyline == null)
                {
                    return;
                }

                ISnappingResult snappingResult = _pointSnapper.Snap(polyline.ToPoint);
                if (snappingResult != null)
                {
                    IPointCollection pointCollection = polyline as IPointCollection;
                    pointCollection.UpdatePoint(pointCollection.PointCount - 1, snappingResult.Location);
                }
                CommonHelper.MovePointWithLine(_pointFeature, _lineFeatures, polyline.ToPoint, _tolerance);

                _lineFeedback = null;
                _pointFeature = null;
                _lineFeatures = null;
                _context.ActiveView.Refresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
        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); }
        }
예제 #6
0
        protected override void OnMouseMove(MouseEventArgs arg)
        {
            try
            {
                var point = GetMapPoint(arg.X, arg.Y);
                if (point == null)
                {
                    return;
                }

                ISnappingResult snapResult = null;
                //Try to snap the current position
                snapResult = m_Snapper.Snap(point);
                m_SnappingFeedback.Update(snapResult, 0);
                if (snapResult != null && snapResult.Location != null)
                {
                    point = snapResult.Location;
                }

                Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.MOUSE_MOVE_POINT, point);
                if (!ListHasItems)
                {
                    Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.RequestOutputUpdate, null);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
예제 #7
0
        public override void OnDblClick()
        {
            try
            {
                if (_lineFeedback == null)
                {
                    return;
                }
                IPolyline polyline = _lineFeedback.Stop();
                _context.ActiveView.Refresh();
                _lineFeedback = null;
                if (polyline == null)
                {
                    return;
                }

                ISnappingResult snappingResult = _pointSnapper.Snap(polyline.ToPoint);
                if (snappingResult != null)
                {
                    IPointCollection pointCollection = polyline as IPointCollection;
                    pointCollection.UpdatePoint(pointCollection.PointCount - 1, snappingResult.Location);
                }
                CommonHelper.MovePointWithLine(_pointFeature, _lineFeatures, polyline.ToPoint, _tolerance);
                //IPoint linkPoint = _pointFeature.Shape as IPoint;
                //linkPoint.PutCoords(polyline.ToPoint.X, polyline.ToPoint.Y);
                //_pointFeature.Shape = linkPoint;
                //_pointFeature.Store();

                //foreach (IFeature lineFeature in _lineFeatures)
                //{
                //    IPolyline linkPolyline = lineFeature.Shape as IPolyline;
                //    if (linkPolyline == null)
                //        continue;
                //    IPointCollection pointCollection = linkPolyline as IPointCollection;
                //    if (CommonHelper.GetDistance(linkPolyline.FromPoint, polyline.FromPoint) < _tolerance)
                //    {
                //        IPoint fromPoint = pointCollection.Point[0];
                //        fromPoint.PutCoords(polyline.ToPoint.X, polyline.ToPoint.Y);
                //        pointCollection.UpdatePoint(0, fromPoint);
                //    }
                //    else if (CommonHelper.GetDistance(linkPolyline.ToPoint, polyline.FromPoint) < _tolerance)
                //    {
                //        IPoint toPoint = pointCollection.Point[pointCollection.PointCount - 1];
                //        toPoint.PutCoords(polyline.ToPoint.X, polyline.ToPoint.Y);
                //        pointCollection.UpdatePoint(pointCollection.PointCount - 1, toPoint);
                //    }
                //    lineFeature.Shape = pointCollection as IPolyline;
                //    lineFeature.Store();
                //}
                _lineFeedback = null;
                _pointFeature = null;
                _lineFeatures = null;
                _context.ActiveView.Refresh();
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
예제 #8
0
        public override void OnMouseMove(int int_0, int int_1, int int_2, int int_3)
        {
            IPoint          mapPoint       = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_2, int_3);
            ISnappingResult snappingResult = this.pointSnapper.Snap(mapPoint);

            if (snappingResult != null)
            {
                mapPoint = snappingResult.Location;
            }
            ellipseFeedback.MoveTo(mapPoint);
        }
예제 #9
0
        public override void OnMouseMove(int Button, int Shift, int x, int y)
        {
            IActiveView     activeView     = _context.ActiveView;
            IPoint          point          = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
            ISnappingResult snappingResult = _pointSnapper.Snap(point);

            if (snappingResult != null)
            {
                point = snappingResult.Location;
            }
            _lineFeedback?.MoveTo(point);
        }
예제 #10
0
        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 OnMouseMove(MouseEventArgs arg)
        {
            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(snapResult, 0);
            if (snapResult != null && snapResult.Location != null)
            {
                point = snapResult.Location;
            }

            Mediator.NotifyColleagues(Constants.MOUSE_MOVE_POINT, point);
        }
예제 #12
0
        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 OnMouseMove(MouseEventArgs arg)
        {
            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(snapResult, 0);
                if (snapResult != null && snapResult.Location != null)
                {
                    point = snapResult.Location;
                }

                Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.MOUSE_MOVE_POINT, point);
                Mediator.NotifyColleagues(CoordinateConversionLibrary.Constants.RequestOutputUpdate, null);
            }
            catch { }
        }
        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 { }
        }
예제 #15
0
        private ISnappingResult method_0(IPoint ipoint_1)
        {
            IActiveView focusMap   = this._appContext.MapControl.Map as IActiveView;
            IPoint      pointClass = new ESRI.ArcGIS.Geometry.Point();

            pointClass.PutCoords(ipoint_1.X, ipoint_1.Y);
            IEngineSnapEnvironment engineSnapEnvironment = ApplicationRef.AppContext.Config.EngineSnapEnvironment;
            ISnappingResult        snappingResult        = null;

            if (engineSnapEnvironment is ISnapEnvironment)
            {
                ISnapEnvironment snapEnvironment = engineSnapEnvironment as ISnapEnvironment;
                if ((snapEnvironment == null || !ApplicationRef.AppContext.Config.UseSnap
                    ? false
                    : snapEnvironment.SnapPoint(pointClass, ipoint_1)))
                {
                    SnappingResult snappingResult1 = new SnappingResult()
                    {
                        X = ipoint_1.X,
                        Y = ipoint_1.Y
                    };
                    snappingResult = snappingResult1;
                }
            }
            else if ((engineSnapEnvironment == null || !ApplicationRef.AppContext.Config.UseSnap
                ? false
                : engineSnapEnvironment.SnapPoint(ipoint_1)))
            {
                SnappingResult snappingResult2 = new SnappingResult()
                {
                    X = ipoint_1.X,
                    Y = ipoint_1.Y
                };
                snappingResult = snappingResult2;
            }
            return(snappingResult);
        }
예제 #16
0
        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); }
        }
예제 #17
0
        public override void OnMouseDown(int button, int shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }

            IActiveView activeView = _context.ActiveView;

            if (_lineFeedback == null)
            {
                if (_context.Config.EngineSnapEnvironment.SnapToleranceUnits ==
                    esriEngineSnapToleranceUnits.esriEngineSnapTolerancePixels)
                {
                    _tolerance = ArcGIS.Common.Helpers.CommonHelper.ConvertPixelsToMapUnits(_context.ActiveView,
                                                                                            _tolerance);
                }
                this.SelectByClick(x, y);
                IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;
                _pointFeature = enumFeature.Next();
                IPoint linkPoint = _pointFeature?.Shape as IPoint;
                if (linkPoint == null)
                {
                    return;
                }
                _lineFeatures = new List <IFeature>();
                this.SelectByShape(linkPoint);
                enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;
                if (enumFeature == null)
                {
                    return;
                }
                enumFeature.Reset();
                IFeature lineFeature;
                while ((lineFeature = enumFeature.Next()) != null)
                {
                    IPolyline polyline = lineFeature.Shape as IPolyline;
                    if (polyline == null)
                    {
                        continue;
                    }
                    _lineFeatures.Add(lineFeature);
                }
                if (_lineFeatures.Count <= 0)
                {
                    return;
                }

                _lineFeedback = new NewLineFeedbackClass()
                {
                    Display = activeView.ScreenDisplay
                };
                _lineFeedback.Start(linkPoint);
            }
            else
            {
                IPoint          point          = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                ISnappingResult snappingResult = _pointSnapper.Snap(point);
                if (snappingResult != null)
                {
                    point = snappingResult.Location;
                }
                _lineFeedback.AddPoint(point);
            }
        }
예제 #18
0
        public override void OnMouseDown(int button, int shift, int x, int y)
        {
            if (button != 1)
            {
                return;
            }

            if (_lineFeedback == null)
            {
                this.SelectByClick(x, y);

                if (_context.FocusMap.SelectionCount != 1)
                {
                    return;
                }
                IEnumFeature enumFeature = _context.FocusMap.FeatureSelection as IEnumFeature;
                _annoFeature = enumFeature.Next();
                IAnnotationFeature annotationFeature = _annoFeature as IAnnotationFeature;
                if (annotationFeature == null)
                {
                    _annoFeature = null;
                    return;
                }
                this.SelectByShape(_annoFeature.Shape);
                IFeatureSelection featureSelection = _cheQiConfig.FlagLineLayer as IFeatureSelection;
                if (featureSelection?.SelectionSet == null || featureSelection.SelectionSet.Count != 1)
                {
                    return;
                }
                ICursor cursor;
                featureSelection.SelectionSet.Search(null, false, out cursor);
                if (cursor == null)
                {
                    return;
                }
                _lineFeature = cursor.NextRow() as IFeature;
                IPolyline polyline = _lineFeature?.Shape as IPolyline;
                if (polyline == null)
                {
                    return;
                }
                _lineFeedback = new NewLineFeedbackClass()
                {
                    Display = _context.ActiveView.ScreenDisplay
                };
                _lineFeedback.Start(polyline.FromPoint);
            }
            else
            {
                IActiveView activeView = _context.ActiveView;
                if (_context.Config.EngineSnapEnvironment.SnapToleranceUnits ==
                    esriEngineSnapToleranceUnits.esriEngineSnapTolerancePixels)
                {
                    _tolerance = ArcGIS.Common.Helpers.CommonHelper.ConvertPixelsToMapUnits(activeView, _tolerance);
                }
                IPoint          point          = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
                ISnappingResult snappingResult = _pointSnapper.Snap(point);
                if (snappingResult != null)
                {
                    point = snappingResult.Location;
                }

                _lineFeedback.AddPoint(point);
            }
        }
예제 #19
0
 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);
 }
예제 #20
0
        public static void Snap2Point(IPoint ipoint_0, IPoint ipoint_1, esriSimpleMarkerStyle esriSimpleMarkerStyle_0,
                                      IActiveView iactiveView_0, IEngineSnapEnvironment iengineSnapEnvironment_0)
        {
            IHitTest mPPointColn;
            double   num;
            int      num1;
            int      num2;
            bool     flag;
            double   mapUnits;
            IPoint   pointClass;

            if (!Editor.UseOldSnap)
            {
                ISnappingResult snappingResult = SketchToolAssist.m_psnaper.Snap(ipoint_0);
                if (snappingResult == null)
                {
                    if (SketchToolAssist.m_pAP == null)
                    {
                        SketchToolAssist.m_pAP = new AnchorPoint()
                        {
                            Symbol = SketchShareEx.m_pSym as ISymbol
                        };
                    }
                    SketchToolAssist.m_pAP.MoveTo(SketchShareEx.m_pAnchorPoint, iactiveView_0.ScreenDisplay);
                }
                else
                {
                    SketchShareEx.m_pAnchorPoint = snappingResult.Location;
                    if (SketchToolAssist.m_pAP != null)
                    {
                        SketchToolAssist.m_pAP.MoveTo(snappingResult.Location, iactiveView_0.ScreenDisplay);
                    }
                    else
                    {
                        SketchToolAssist.AddNewAnchorPt(snappingResult.Location, esriSimpleMarkerStyle_0, iactiveView_0);
                    }
                }
            }
            else
            {
                SketchShareEx.m_pSym.Style = esriSimpleMarkerStyle_0;
                if (iengineSnapEnvironment_0 is ISnapEnvironment)
                {
                    ISnapEnvironment iengineSnapEnvironment0 = iengineSnapEnvironment_0 as ISnapEnvironment;
                    if ((iengineSnapEnvironment0 == null || !ApplicationRef.AppContext.Config.UseSnap
                        ? true
                        : !iengineSnapEnvironment0.SnapPoint(SketchShareEx.LastPoint, ipoint_0)))
                    {
                        if (ApplicationRef.AppContext.Config.IsSnapSketch)
                        {
                            mPPointColn = SketchToolAssist.m_pPointColn as IHitTest;
                            if (mPPointColn != null)
                            {
                                num      = 0;
                                num1     = 0;
                                num2     = 0;
                                flag     = false;
                                mapUnits = CommonHelper.ConvertPixelsToMapUnits(iactiveView_0,
                                                                                iengineSnapEnvironment0.SnapTolerance);
                                if (mapUnits == 0)
                                {
                                    mapUnits = 3;
                                }
                                pointClass = new ESRI.ArcGIS.Geometry.Point();
                                if (
                                    !mPPointColn.HitTest(ipoint_0, mapUnits,
                                                         esriGeometryHitPartType.esriGeometryPartVertex, pointClass, ref num, ref num1,
                                                         ref num2, ref flag))
                                {
                                    SketchShareEx.m_bSnapSuccessful = false;
                                    if (SketchToolAssist.m_pAP != null)
                                    {
                                        SketchToolAssist.m_pAP.MoveTo(ipoint_0, iactiveView_0.ScreenDisplay);
                                    }
                                    else
                                    {
                                        SketchToolAssist.AddNewAnchorPt(ipoint_0, esriSimpleMarkerStyle_0, iactiveView_0);
                                    }
                                    return;
                                }
                                ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                SketchShareEx.m_bSnapSuccessful = true;
                                if (SketchToolAssist.m_pAP != null)
                                {
                                    SketchToolAssist.m_pAP.MoveTo(ipoint_0, iactiveView_0.ScreenDisplay);
                                    return;
                                }
                                else
                                {
                                    SketchToolAssist.AddNewAnchorPt(ipoint_0, esriSimpleMarkerStyle_0, iactiveView_0);
                                    return;
                                }
                            }
                        }
                    }
                    else
                    {
                        SketchShareEx.m_bSnapSuccessful = true;
                        if (SketchToolAssist.m_pAP != null)
                        {
                            SketchToolAssist.m_pAP.MoveTo(ipoint_0, iactiveView_0.ScreenDisplay);
                        }
                        else
                        {
                            SketchToolAssist.AddNewAnchorPt(ipoint_0, esriSimpleMarkerStyle_0, iactiveView_0);
                        }
                    }
                }
                else if ((iengineSnapEnvironment_0 == null || !ApplicationRef.AppContext.Config.UseSnap
                    ? true
                    : !iengineSnapEnvironment_0.SnapPoint(ipoint_0)))
                {
                    if (ApplicationRef.AppContext.Config.IsSnapSketch)
                    {
                        mPPointColn = SketchToolAssist.m_pPointColn as IHitTest;
                        if (mPPointColn != null)
                        {
                            num      = 0;
                            num1     = 0;
                            num2     = 0;
                            flag     = false;
                            mapUnits = iengineSnapEnvironment_0.SnapTolerance;
                            if (iengineSnapEnvironment_0.SnapToleranceUnits ==
                                esriEngineSnapToleranceUnits.esriEngineSnapTolerancePixels)
                            {
                                mapUnits = CommonHelper.ConvertPixelsToMapUnits(iactiveView_0,
                                                                                iengineSnapEnvironment_0.SnapTolerance);
                            }
                            if (mapUnits == 0)
                            {
                                mapUnits = 3;
                            }
                            pointClass = new ESRI.ArcGIS.Geometry.Point();
                            if (
                                !mPPointColn.HitTest(ipoint_0, mapUnits, esriGeometryHitPartType.esriGeometryPartVertex,
                                                     pointClass, ref num, ref num1, ref num2, ref flag))
                            {
                                SketchShareEx.m_bSnapSuccessful = false;
                                if (SketchToolAssist.m_pAP != null)
                                {
                                    SketchToolAssist.m_pAP.MoveTo(ipoint_0, iactiveView_0.ScreenDisplay);
                                }
                                else
                                {
                                    SketchToolAssist.AddNewAnchorPt(ipoint_0, esriSimpleMarkerStyle_0, iactiveView_0);
                                }
                                return;
                            }
                            ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                            SketchShareEx.m_bSnapSuccessful = true;
                            if (SketchToolAssist.m_pAP != null)
                            {
                                SketchToolAssist.m_pAP.MoveTo(ipoint_0, iactiveView_0.ScreenDisplay);
                                return;
                            }
                            else
                            {
                                SketchToolAssist.AddNewAnchorPt(ipoint_0, esriSimpleMarkerStyle_0, iactiveView_0);
                                return;
                            }
                        }
                    }
                }
                else
                {
                    SketchShareEx.m_bSnapSuccessful = true;
                    if (SketchToolAssist.m_pAP != null)
                    {
                        SketchToolAssist.m_pAP.MoveTo(ipoint_0, iactiveView_0.ScreenDisplay);
                    }
                    else
                    {
                        SketchToolAssist.AddNewAnchorPt(ipoint_0, esriSimpleMarkerStyle_0, iactiveView_0);
                    }
                }
            }
        }
예제 #21
0
파일: SnapEx.cs 프로젝트: 605258778/GISData
 private void DrawLinefeedback(IPoint pPoint)
 {
     try
     {
         int hDC = this._hookHelper.ActiveView.ScreenDisplay.hDC;
         IEngineSnapEnvironment engineEditor = Editor.UniqueInstance.EngineEditor as IEngineSnapEnvironment;
         if (this._snappingEnv != null)
         {
             ISnappingResult snappingResult = this._snappingEnv.PointSnapper.Snap(pPoint);
             this._snapFeedback.Update(snappingResult, hDC);
             if ((this._lineFeedback != null) && this._bStarted)
             {
                 IPoint location = null;
                 if (snappingResult == null)
                 {
                     location = pPoint;
                 }
                 else
                 {
                     location = snappingResult.Location;
                 }
                 try
                 {
                     this._lineFeedback.AddPoint(location);
                 }
                 catch
                 {
                 }
                 IPolyline polyline = this._lineFeedback.Stop();
                 if (polyline == null)
                 {
                     if (snappingResult != null)
                     {
                         this._lineFeedback.Start(location);
                     }
                 }
                 else
                 {
                     IPointCollection points = (IPointCollection)polyline;
                     if (points.PointCount > 2)
                     {
                         points.RemovePoints(points.PointCount - 1, 1);
                     }
                     double    snapTolerance   = engineEditor.SnapTolerance;
                     double    hitDistance     = -1.0;
                     int       hitSegmentIndex = -1;
                     int       hitPartIndex    = -1;
                     bool      bRightSide      = false;
                     IGeometry geometry        = (IGeometry)points;
                     IHitTest  test            = geometry as IHitTest;
                     if (!test.HitTest(location, snapTolerance, esriGeometryHitPartType.esriGeometryPartVertex, null, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref bRightSide))
                     {
                         hitSegmentIndex = -1;
                     }
                     this._lineFeedback.Start(points.get_Point(0));
                     if (hitSegmentIndex != 0)
                     {
                         for (int i = 1; i < points.PointCount; i++)
                         {
                             IPoint point = points.get_Point(i);
                             this._lineFeedback.AddPoint(point);
                             if (i == hitSegmentIndex)
                             {
                                 break;
                             }
                         }
                     }
                     if (snappingResult != null)
                     {
                         this._lineFeedback.AddPoint(location);
                     }
                 }
             }
         }
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.SnapEx", "DrawLinefeedback", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
     }
 }
예제 #22
0
파일: SnapEx.cs 프로젝트: 605258778/GISData
        public void OnMouseDown(int button, int shift, int x, int y)
        {
            this._bMouse = true;
            IPoint point = this._hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            this._tool.OnMouseDown(1, shift, x, y);
            if (this._bFinished)
            {
                this._bFinished = false;
            }
            else
            {
                try
                {
                    if (this._snappingEnv == null)
                    {
                        return;
                    }
                    IPointSnapper     pointSnapper = this._snappingEnv.PointSnapper;
                    ISnappingResult   result       = pointSnapper.Snap(point);
                    IEngineEditSketch engineEditor = Editor.UniqueInstance.EngineEditor as IEngineEditSketch;
                    IPointCollection  points       = engineEditor.Geometry as IPointCollection;
                    if (!this._bStarted)
                    {
                        this.CreateFeed();
                        if (result != null)
                        {
                            this._lineFeedback.Start(result.Location);
                        }
                        this._bStarted = true;
                        return;
                    }
                    IGeometry geometry = engineEditor.Geometry;
                    if (geometry == null)
                    {
                        return;
                    }
                    IPointCollection points2  = geometry as IPointCollection;
                    IPolyline        polyline = this._lineFeedback.Stop();
                    int index = 0;
                    if (engineEditor.GeometryType == esriGeometryType.esriGeometryPolygon)
                    {
                        index = points.PointCount - 2;
                    }
                    else
                    {
                        index = points.PointCount - 1;
                    }
                    if (polyline != null)
                    {
                        IPointCollection points3 = (IPointCollection)polyline;
                        for (int i = 1; i < (points3.PointCount - 1); i++)
                        {
                            IPoint point2    = points3.get_Point(i);
                            IPoint newPoints = (point2 as IClone).Clone() as IPoint;
                            if (pointSnapper.Snap(point2).Type == esriSnappingType.esriSnappingTypeVertex)
                            {
                                points2.InsertPoints(index, 1, ref newPoints);
                                index++;
                            }
                        }
                    }
                    int hDC = this._hookHelper.ActiveView.ScreenDisplay.hDC;
                    this._lineFeedback.Stop();
                    this._lineFeedback.Refresh(hDC);
                    if (result != null)
                    {
                        this._lineFeedback.Start(result.Location);
                    }
                    if (button == 2)
                    {
                        this.OnDblClick();
                    }
                    engineEditor.RefreshSketch();
                }
                catch (Exception exception)
                {
                    this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.SnapEx", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
                }
                this._bMouse = false;
            }
        }
예제 #23
0
        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);
                    }
                }
            }
        }
예제 #24
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolNewDisplacement.OnMouseDown implementation
            if (!DataReady())
            {
                MessageBox.Show("内检测、中线图层设置不正确");
                return;
            }

            object       Miss         = Type.Missing;
            IMapControl2 pMapCtr      = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;
            IMapControl3 m_MapControl = pMapCtr as IMapControl3;

            if (pMapCtr != null)
            {
                //IGeoReference pGR = pRasterLayer as IGeoReference;
                IPoint mapPoint = pMapCtr.ToMapPoint(X, Y);
                m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
                if (bFlag == true)//起始点
                {
                    IPoint          point      = TransformToMapPoint(X, Y);
                    IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                    ISnappingResult snapresult = ptSnapper.Snap(point);
                    if (snapresult != null)
                    {
                        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;
                        ISpatialFilter pSF    = new SpatialFilterClass();
                        IPoint         ProjPt = snapresult.Location;
                        ProjPt.Project(((IGeoDataset)(pIMULayer.FeatureClass)).SpatialReference);
                        pSF.Geometry      = ProjPt;
                        pSF.GeometryField = pIMULayer.FeatureClass.ShapeFieldName;
                        pSF.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                        IFeatureCursor pCursor  = pIMULayer.FeatureClass.Search(pSF, false);
                        IFeature       pFeature = pCursor.NextFeature();
                        if (pFeature != null)
                        {
                            IMUFeature = pFeature;
                            m_NewLineFeedback.Start(mapPoint);

                            bFlag = false;
                        }
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(pSF);
                    }
                }
                else//目标点
                {
                    IPoint          point      = TransformToMapPoint(X, Y);
                    IPointSnapper   ptSnapper  = m_SnappingEnvironment.PointSnapper;
                    ISnappingResult snapresult = ptSnapper.Snap(point);
                    if (snapresult != null)
                    {
                        //m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                        //m_snappingFeed.UnInitialize();
                        //m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                        //m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);

                        m_SnappingEnvironment.SnappingType = esriSnappingType.esriSnappingTypePoint;
                        ISpatialFilter pSF    = new SpatialFilterClass();
                        IPoint         ProjPt = snapresult.Location;
                        ProjPt.Project(((IGeoDataset)(pCenterlinePointLayer.FeatureClass)).SpatialReference);
                        pSF.Geometry      = ProjPt;
                        pSF.GeometryField = pCenterlinePointLayer.FeatureClass.ShapeFieldName;
                        pSF.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                        IFeatureCursor pCursor  = pCenterlinePointLayer.FeatureClass.Search(pSF, false);
                        IFeature       pFeature = pCursor.NextFeature();
                        if (pFeature != null)
                        {
                            CenterlinePointFeature = pFeature;



                            if (m_CenterlinePointFeatureList.Count > 0)
                            {
                                double newIMUM        = Convert.ToDouble(IMUFeature.Value[m_IMUFeatureList[0].Fields.FindField("记录距离")]);
                                double newCenterlineM = Convert.ToDouble(CenterlinePointFeature.Value[m_CenterlinePointFeatureList[0].Fields.FindField("里程")]);
                                for (int i = 0; i < m_CenterlinePointFeatureList.Count; i++)
                                {
                                    double previewIMUM      = Convert.ToDouble(m_IMUFeatureList[i].Value[m_IMUFeatureList[0].Fields.FindField("记录距离")]);
                                    double previewCentlineM = Convert.ToDouble(m_CenterlinePointFeatureList[i].Value[m_CenterlinePointFeatureList[0].Fields.FindField("里程")]);

                                    if ((newIMUM - previewIMUM) * (newCenterlineM - previewCentlineM) <= 0)
                                    {
                                        MessageBox.Show("特征点不能交叉匹配.");
                                        return;
                                    }
                                }
                            }

                            m_IMUFeatureList.Add(IMUFeature);
                            m_CenterlinePointFeatureList.Add(CenterlinePointFeature);
                            bFlag = true;
                            IPolyline pPline = m_NewLineFeedback.Stop();
                            m_FrmVectorLinkTable.RefreshDataTable();
                        }
                    }
                    m_MapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null);
                    //m_snappingFeed.UnInitialize();

                    //m_snappingFeed.Initialize(m_MapControl.Object, m_SnappingEnvironment, true);
                    // m_snappingFeed.Refresh(m_MapControl.ActiveView.ScreenDisplay.hDC);
                }
            }
        }
예제 #25
0
        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;
        }
예제 #26
0
        private static ISnappingResult OldSnap(IPoint ipoint_0, IActiveView pActiveView,
                                               IEngineSnapEnvironment iengineSnapEnvironment_0)
        {
            IHitTest        mPPointColn;
            double          num;
            int             num1;
            int             num2;
            bool            flag;
            double          mapUnits;
            IPoint          pointClass;
            ISnappingResult snappingResult = null;

            if (iengineSnapEnvironment_0 is ISnapEnvironment)
            {
                ISnapEnvironment iengineSnapEnvironment0 = iengineSnapEnvironment_0 as ISnapEnvironment;
                if (
                    !(iengineSnapEnvironment0 == null || !ApplicationRef.AppContext.Config.UseSnap
                        ? true
                        : !iengineSnapEnvironment0.SnapPoint(SketchToolAssist.LastPoint, ipoint_0)))
                {
                    SnappingResult snappingResult1 = new SnappingResult()
                    {
                        X = ipoint_0.X,
                        Y = ipoint_0.Y
                    };
                    snappingResult = snappingResult1;
                }
                else if (ApplicationRef.AppContext.Config.IsSnapSketch)
                {
                    mPPointColn = SketchToolAssist.m_pPointColn as IHitTest;
                    if (mPPointColn != null)
                    {
                        num      = 0;
                        num1     = 0;
                        num2     = 0;
                        flag     = false;
                        mapUnits = CommonHelper.ConvertPixelsToMapUnits(pActiveView,
                                                                        iengineSnapEnvironment0.SnapTolerance);
                        if (mapUnits == 0)
                        {
                            mapUnits = 3;
                        }
                        pointClass = new ESRI.ArcGIS.Geometry.Point();
                        if (mPPointColn.HitTest(ipoint_0, mapUnits, esriGeometryHitPartType.esriGeometryPartVertex,
                                                pointClass, ref num, ref num1, ref num2, ref flag))
                        {
                            SnappingResult snappingResult2 = new SnappingResult()
                            {
                                X = pointClass.X,
                                Y = pointClass.Y
                            };
                            snappingResult = snappingResult2;
                        }
                    }
                }
            }
            else if (
                !(iengineSnapEnvironment_0 == null || !ApplicationRef.AppContext.Config.UseSnap
                    ? true
                    : !iengineSnapEnvironment_0.SnapPoint(ipoint_0)))
            {
                SnappingResult snappingResult3 = new SnappingResult()
                {
                    X = ipoint_0.X,
                    Y = ipoint_0.Y
                };
                snappingResult = snappingResult3;
            }
            else if (ApplicationRef.AppContext.Config.IsSnapSketch)
            {
                mPPointColn = SketchToolAssist.m_pPointColn as IHitTest;
                if (mPPointColn != null)
                {
                    num      = 0;
                    num1     = 0;
                    num2     = 0;
                    flag     = false;
                    mapUnits = iengineSnapEnvironment_0.SnapTolerance;
                    if (iengineSnapEnvironment_0.SnapToleranceUnits ==
                        esriEngineSnapToleranceUnits.esriEngineSnapTolerancePixels)
                    {
                        mapUnits = CommonHelper.ConvertPixelsToMapUnits(pActiveView,
                                                                        iengineSnapEnvironment_0.SnapTolerance);
                    }
                    if (mapUnits == 0)
                    {
                        mapUnits = 3;
                    }
                    pointClass = new ESRI.ArcGIS.Geometry.Point();
                    if (mPPointColn.HitTest(ipoint_0, mapUnits, esriGeometryHitPartType.esriGeometryPartVertex,
                                            pointClass, ref num, ref num1, ref num2, ref flag))
                    {
                        SnappingResult snappingResult4 = new SnappingResult()
                        {
                            X = pointClass.X,
                            Y = pointClass.Y
                        };
                        snappingResult = snappingResult4;
                    }
                }
            }
            return(snappingResult);
        }