Exemplo n.º 1
0
        private static void HitTest(IFeature ifeature_0, IPoint ipoint_0)
        {
            IGeometry shapeCopy = ifeature_0.ShapeCopy;
            IPoint    point     = new ESRI.ArcGIS.Geometry.Point();
            double    num       = 0.0;
            int       index     = 0;
            int       num2      = 0;
            bool      flag      = false;

            if (
                (!(shapeCopy as IHitTest).HitTest(ipoint_0, 0.0001, esriGeometryHitPartType.esriGeometryPartVertex,
                                                  point, ref num, ref index, ref num2, ref flag) || num >= 0.0001) &&
                (shapeCopy as IHitTest).HitTest(ipoint_0, 0.0001, esriGeometryHitPartType.esriGeometryPartBoundary,
                                                point, ref num, ref index, ref num2, ref flag) && num < 0.0001)
            {
                ISegmentCollection segmentCollection =
                    (shapeCopy as IGeometryCollection).get_Geometry(index) as ISegmentCollection;
                ISegment segment = segmentCollection.get_Segment(num2);
                if (segment is ILine)
                {
                    ILine line = new Line();
                    line.PutCoords((segment as ILine).FromPoint, point);
                    ILine line2 = new Line();
                    line2.PutCoords(point, (segment as ILine).ToPoint);
                    ISegmentCollection segmentCollection2 = new Polyline() as ISegmentCollection;
                    object             value  = System.Reflection.Missing.Value;
                    object             value2 = System.Reflection.Missing.Value;
                    segmentCollection2.AddSegment(line as ISegment, ref value, ref value2);
                    segmentCollection.ReplaceSegmentCollection(num2, 1, segmentCollection2);
                    segmentCollection2 = new Polyline() as ISegmentCollection;
                    object value3 = System.Reflection.Missing.Value;
                    object value4 = System.Reflection.Missing.Value;
                    segmentCollection2.AddSegment(line2 as ISegment, ref value3, ref value4);
                    segmentCollection.InsertSegmentCollection(num2 + 1, segmentCollection2);
                    segmentCollection.SegmentsChanged();
                    (shapeCopy as IGeometryCollection).GeometriesChanged();
                    ifeature_0.Shape = shapeCopy;
                    ifeature_0.Store();
                }
            }
        }
Exemplo n.º 2
0
        private static void HitTest(IFeature ifeature_0, IPoint ipoint_0)
        {
            IGeometry shapeCopy  = ifeature_0.ShapeCopy;
            IPoint    pointClass = new Point();
            double    num        = 0;
            int       num1       = 0;
            int       num2       = 0;
            bool      flag       = false;

            if (
                (!(shapeCopy as IHitTest).HitTest(ipoint_0, 0.0001, esriGeometryHitPartType.esriGeometryPartVertex,
                                                  pointClass, ref num, ref num1, ref num2, ref flag) || num >= 0.0001) &&
                (shapeCopy as IHitTest).HitTest(ipoint_0, 0.0001, esriGeometryHitPartType.esriGeometryPartBoundary,
                                                pointClass, ref num, ref num1, ref num2, ref flag) && num < 0.0001)
            {
                ISegmentCollection geometry = (shapeCopy as IGeometryCollection).Geometry[num1] as ISegmentCollection;
                ISegment           segment  = geometry.Segment[num2];
                if (segment is ILine)
                {
                    ILine lineClass = new Line();
                    lineClass.PutCoords((segment as ILine).FromPoint, pointClass);
                    ILine line = new Line();
                    line.PutCoords(pointClass, (segment as ILine).ToPoint);
                    ISegmentCollection polylineClass = new Polyline() as ISegmentCollection;
                    object             value         = Missing.Value;
                    object             obj           = Missing.Value;
                    polylineClass.AddSegment(lineClass as ISegment, ref value, ref obj);
                    geometry.ReplaceSegmentCollection(num2, 1, polylineClass);
                    polylineClass = new Polyline() as ISegmentCollection;
                    object value1 = Missing.Value;
                    object obj1   = Missing.Value;
                    polylineClass.AddSegment(line as ISegment, ref value1, ref obj1);
                    geometry.InsertSegmentCollection(num2 + 1, polylineClass);
                    geometry.SegmentsChanged();
                    (shapeCopy as IGeometryCollection).GeometriesChanged();
                    ifeature_0.Shape = shapeCopy;
                    ifeature_0.Store();
                }
            }
        }
        public ISegmentCollection Modify1Segment(IGeometryCollection polyline, Double searchRadius, Double offsetX, Double offsetY)
        {
            IPoint   queryPoint = m_activePoint;
            IPoint   hitPoint = new PointClass();
            double   hitDistance = 0; int hitPartIndex = 0;
            int      hitSegmentIndex = 0; bool rightSide = false;
            IHitTest hitTest       = (IHitTest)polyline;
            bool     foundGeometry = hitTest.HitTest(queryPoint, searchRadius, esriGeometryHitPartType.esriGeometryPartBoundary, hitPoint, ref hitDistance, ref hitPartIndex, ref hitSegmentIndex, ref rightSide);

            if (foundGeometry == true)
            {
                IGeometry          geometry          = polyline.get_Geometry(hitPartIndex);
                ISegmentCollection segmentCollection =
                    (ISegmentCollection)geometry;
                ISegment     segment     = segmentCollection.get_Segment(hitSegmentIndex);
                ITransform2D transform2D = (ITransform2D)segment;
                transform2D.Move(offsetX, offsetY);
                segmentCollection.SegmentsChanged();
                return(segmentCollection);
            }
            return(null);
        }