Exemple #1
0
        private IGeometry method_1(IPolyline ipolyline_0, int int_0, int int_1, int int_2, int int_3)
        {
            IPointCollection geometry;
            int i;
            IGeometryCollection ipolyline0    = ipolyline_0 as IGeometryCollection;
            IGeometryCollection polylineClass = null;
            object value = Missing.Value;

            if (int_2 != int_0)
            {
                if (int_0 != ipolyline0.GeometryCount - 1)
                {
                    ipolyline0.RemoveGeometries(int_0 + 1, ipolyline0.GeometryCount - int_0 - 1);
                }
                if (int_2 != 0)
                {
                    ipolyline0.RemoveGeometries(0, int_2);
                }
                geometry = ipolyline0.Geometry[0] as IPointCollection;
                if (int_3 != 0)
                {
                    geometry.RemovePoints(0, int_3);
                }
                ipolyline0.GeometriesChanged();
                geometry = ipolyline0.Geometry[int_0 - int_2] as IPointCollection;
                if (int_1 != geometry.PointCount - 1)
                {
                    geometry.RemovePoints(int_1 + 1, geometry.PointCount - int_1 - 1);
                }
                ipolyline0.GeometriesChanged();
            }
            else
            {
                geometry = ipolyline0.Geometry[int_0] as IPointCollection;
                if (int_3 - int_1 + 1 != geometry.PointCount)
                {
                    polylineClass = new Polyline() as IGeometryCollection;
                    for (i = 0; i < int_0 - 1; i++)
                    {
                        polylineClass.AddGeometry((ipolyline0.Geometry[i] as IClone).Clone() as IGeometry, ref value,
                                                  ref value);
                    }
                    IPointCollection pathClass = new ESRI.ArcGIS.Geometry.Path();
                    for (i = int_1; i < int_3 + 1; i++)
                    {
                        pathClass.AddPoint(geometry.Point[i], ref value, ref value);
                    }
                    if (pathClass is IRing)
                    {
                        (pathClass as IRing).Close();
                    }
                    polylineClass.AddGeometry(pathClass as IGeometry, ref value, ref value);
                    for (i = int_0 + 1; i < ipolyline0.GeometryCount; i++)
                    {
                        polylineClass.AddGeometry((ipolyline0.Geometry[i] as IClone).Clone() as IGeometry, ref value,
                                                  ref value);
                    }
                }
                else
                {
                    ipolyline0.RemoveGeometries(int_0, 1);
                    polylineClass = ipolyline0;
                }
            }
            return(polylineClass as IGeometry);
        }