Ejemplo n.º 1
0
        public override IGeometry VerticalMirror(IPoint ipoint_0)
        {
            object value = Missing.Value;
            IGeometryCollection mPGeometry    = this.m_pGeometry as IGeometryCollection;
            IGeometryCollection polylineClass = new Polyline() as IGeometryCollection;

            for (int i = 0; i < mPGeometry.GeometryCount; i++)
            {
                ISegmentCollection geometry  = mPGeometry.Geometry[i] as ISegmentCollection;
                ISegmentCollection pathClass = new ESRI.ArcGIS.Geometry.Path() as ISegmentCollection;
                int num = 0;
                while (num < geometry.SegmentCount)
                {
                    ISegment segment = this.method_4(geometry.Segment[num], ipoint_0);
                    pathClass.AddSegment(segment, ref value, ref value);
                    i++;
                }
                polylineClass.AddGeometry(geometry as IGeometry, ref value, ref value);
            }
            return(polylineClass as IGeometry);
        }
Ejemplo n.º 2
0
        public IPolyline CreatePolyline(IntPtr intptr_0)
        {
            IPolyline polylineClass = new Polyline() as IPolyline;
            int       num           = TabRead._mitab_c_get_parts(intptr_0);
            object    value         = Missing.Value;

            for (int i = 0; i < num; i++)
            {
                int   num1      = TabRead._mitab_c_get_vertex_count(intptr_0, i);
                IPath pathClass = new ESRI.ArcGIS.Geometry.Path() as IPath;
                for (int j = 0; j < num1; j++)
                {
                    IPoint pointClass = new Point()
                    {
                        X = TabRead._mitab_c_get_vertex_x(intptr_0, i, j),
                        Y = TabRead._mitab_c_get_vertex_y(intptr_0, i, j)
                    };
                    (pathClass as IPointCollection).AddPoint(pointClass, ref value, ref value);
                }
                (polylineClass as IGeometryCollection).AddGeometry(pathClass, ref value, ref value);
            }
            return(polylineClass);
        }
Ejemplo n.º 3
0
        private Image SymbolToBitmap(IGradientFillSymbol iSymbol, int iStyle, int iWidth, int iHeight)
        {
            IntPtr    iHDC      = new IntPtr();
            Bitmap    iBitmap   = new Bitmap(iWidth, iHeight);
            Graphics  iGraphics = System.Drawing.Graphics.FromImage(iBitmap);
            tagRECT   itagRECT;
            IEnvelope iEnvelope = new EnvelopeClass() as IEnvelope;
            IDisplayTransformation iDisplayTransformation;
            IPoint iPoint;
            IGeometryCollection iPolyline;
            IGeometryCollection iPolygon;
            IRing iRing;
            ISegmentCollection iSegmentCollection;
            IGeometry          iGeometry = null;
            object             Missing   = Type.Missing;

            iEnvelope.PutCoords(0, 0, iWidth, iHeight);
            itagRECT.left          = 0;
            itagRECT.right         = iWidth;
            itagRECT.top           = 0;
            itagRECT.bottom        = iHeight;
            iDisplayTransformation = new DisplayTransformationClass();
            iDisplayTransformation.VisibleBounds = iEnvelope;
            iDisplayTransformation.Bounds        = iEnvelope;
            iDisplayTransformation.set_DeviceFrame(ref itagRECT);
            iDisplayTransformation.Resolution = iGraphics.DpiX / 100000;
            iHDC = iGraphics.GetHdc();
            //获取Geometry;

            if (iSymbol is ESRI.ArcGIS.Display.IMarkerSymbol)
            {
                switch (iStyle)
                {
                case 0:
                    iPoint = new ESRI.ArcGIS.Geometry.Point();
                    iPoint.PutCoords(iWidth / 2, iHeight / 2);
                    iGeometry = iPoint;
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (iSymbol is ESRI.ArcGIS.Display.ILineSymbol)
                {
                    iSegmentCollection = new ESRI.ArcGIS.Geometry.Path() as ISegmentCollection;
                    iPolyline          = new ESRI.ArcGIS.Geometry.Polyline() as IGeometryCollection;
                    switch (iStyle)
                    {
                    case 0:
                        iSegmentCollection.AddSegment(CreateLine(0, iHeight / 2, iWidth, iHeight / 2) as ISegment, ref Missing, ref Missing);

                        iPolyline.AddGeometry(iSegmentCollection as IGeometry, ref Missing, ref Missing);
                        iGeometry = iPolyline as IGeometry;
                        break;

                    case 1:
                        iSegmentCollection.AddSegment(CreateLine(0, iHeight / 4, iWidth / 4, 3 * iHeight / 4) as ISegment, ref Missing, ref Missing);
                        iSegmentCollection.AddSegment(CreateLine(iWidth / 4, 3 * iHeight / 4, 3 * iWidth / 4, iHeight / 4) as ISegment, ref Missing, ref Missing);
                        iSegmentCollection.AddSegment(CreateLine(3 * iWidth / 4, iHeight / 4, iWidth, 3 * iHeight / 4) as ISegment, ref Missing, ref Missing);
                        iPolyline.AddGeometry(iSegmentCollection as IGeometry, ref Missing, ref Missing);
                        iGeometry = iPolyline as IGeometry;
                        break;

                    default:
                        break;
                    }
                }
                else
                if (iSymbol is ESRI.ArcGIS.Display.IFillSymbol)
                {
                    iSegmentCollection = new ESRI.ArcGIS.Geometry.Ring() as ISegmentCollection;
                    iPolygon           = new ESRI.ArcGIS.Geometry.Polygon() as IGeometryCollection;
                    switch (iStyle)
                    {
                    case 0:
                        iSegmentCollection.AddSegment(CreateLine(5, iHeight - 5, iWidth - 6, iHeight - 5) as ISegment, ref Missing, ref Missing);
                        iSegmentCollection.AddSegment(CreateLine(iWidth - 6, iHeight - 5, iWidth - 6, 6) as ISegment, ref Missing, ref Missing);
                        iSegmentCollection.AddSegment(CreateLine(iWidth - 6, 6, 5, 6) as ISegment, ref Missing, ref Missing);
                        iRing = iSegmentCollection as IRing;
                        iRing.Close();
                        iPolygon.AddGeometry(iSegmentCollection as IGeometry, ref Missing, ref Missing);
                        iGeometry = iPolygon as IGeometry;
                        break;

                    default:
                        break;
                    }
                }
                else
                if (iSymbol is ESRI.ArcGIS.Display.ISimpleTextSymbol)
                {
                    switch (iStyle)
                    {
                    case 0:
                        iPoint = new ESRI.ArcGIS.Geometry.Point();
                        iPoint.PutCoords(iWidth / 2, iHeight / 2);
                        iGeometry = iPoint;
                        break;

                    default:
                        break;
                    }
                }
            }////////////////////////
            if (iGeometry == null)
            {
                MessageBox.Show("几何对象不符合!", "错误");
                return(null);
            }
            ISymbol pOutputSymbol = iSymbol as ISymbol;

            pOutputSymbol.SetupDC(iHDC.ToInt32(), iDisplayTransformation);
            pOutputSymbol.Draw(iGeometry);
            pOutputSymbol.ResetDC();
            iGraphics.ReleaseHdc(iHDC);
            iGraphics.Dispose();
            return(iBitmap);
        }
Ejemplo n.º 4
0
        private void method_2(IPolyline ipolyline_1)
        {
            esriGeometryType shapeType =
                Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer.FeatureClass.ShapeType;

            if (SketchToolAssist.Feedback == null)
            {
                if (shapeType == esriGeometryType.esriGeometryPolyline)
                {
                    SketchToolAssist.Feedback         = new NewPolylineFeedback();
                    SketchToolAssist.Feedback.Display = (_context.FocusMap as IActiveView).ScreenDisplay;
                    SketchShareEx.m_bInUse            = true;
                }
                else if (shapeType == esriGeometryType.esriGeometryPolygon)
                {
                    SketchToolAssist.Feedback         = new NewPolygonFeedbackEx();
                    SketchToolAssist.Feedback.Display = (_context.FocusMap as IActiveView).ScreenDisplay;
                    SketchShareEx.m_bInUse            = true;
                }
            }
            if (SketchToolAssist.Feedback is INewPolygonFeedbackEx)
            {
                (SketchToolAssist.Feedback as INewPolygonFeedbackEx).AddPart(ipolyline_1);
                SketchShareEx.PointCount += (ipolyline_1 as IPointCollection).PointCount;
            }
            else if (SketchToolAssist.Feedback is INewPolylineFeedback)
            {
                (SketchToolAssist.Feedback as INewPolylineFeedback).AddPart(ipolyline_1);
                SketchShareEx.PointCount += (ipolyline_1 as IPointCollection).PointCount;
            }
            ISegmentCollection segmentCollection = null;

            this.bool_3 = true;
            if (this.isegmentCollection_0 == null)
            {
                if (shapeType == esriGeometryType.esriGeometryPolyline)
                {
                    this.isegmentCollection_0 = new Polyline() as ISegmentCollection;
                }
                else if (shapeType == esriGeometryType.esriGeometryPolygon)
                {
                    this.isegmentCollection_0 = new Polygon() as ISegmentCollection;
                }
            }
            if (shapeType == esriGeometryType.esriGeometryPolyline)
            {
                segmentCollection = new Path() as ISegmentCollection;
            }
            else if (shapeType == esriGeometryType.esriGeometryPolygon)
            {
                segmentCollection = new Ring() as ISegmentCollection;
            }
            IGeometryCollection geometryCollection = this.isegmentCollection_0 as IGeometryCollection;
            IGeometry           geometry           = segmentCollection as IGeometry;

            geometryCollection.InsertGeometries(-1, 1, ref geometry);
            if (shapeType == esriGeometryType.esriGeometryPolygon)
            {
                IPolygon polygon = this.isegmentCollection_0 as IPolygon;
                polygon.Close();
            }
            this.bool_3 = false;
        }
Ejemplo n.º 5
0
        public bool Snap(IGeometry igeometry_0, IPoint ipoint_0, double double_0)
        {
            ILine  lineClass;
            double length     = 0;
            int    num        = 0;
            int    num1       = 0;
            bool   flag       = true;
            IPoint pointClass = new ESRI.ArcGIS.Geometry.Point();
            double num2       = 1000;
            bool   flag1      = false;
            object value      = Missing.Value;
            IPoint ipoint0    = ipoint_0;
            IPoint point      = null;

            point = (!(igeometry_0 is IPoint) ? ((IPointCollection)igeometry_0).Point[0] : (IPoint)igeometry_0);
            for (int i = 0; i < this.ifeatureCache_0.Count; i++)
            {
                IHitTest shape = (IHitTest)this.ifeatureCache_0.Feature[i].Shape;
                if (shape.HitTest(ipoint0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, pointClass,
                                  ref length, ref num, ref num1, ref flag))
                {
                    IGeometryCollection geometryCollection = shape as IGeometryCollection;
                    if (geometryCollection != null)
                    {
                        ISegmentCollection geometry = geometryCollection.Geometry[num] as ISegmentCollection;
                        if (geometry != null)
                        {
                            ISegment segment = geometry.Segment[num1];
                            if (segment is ICircularArc)
                            {
                                IPoint centerPoint = ((ICircularArc)segment).CenterPoint;
                                ILine  line        = new Line();
                                line.PutCoords(point, centerPoint);
                                double length1 = line.Length;
                                IConstructCircularArc circularArcClass = new CircularArc() as IConstructCircularArc;
                                circularArcClass.ConstructCircle(point, length1, true);
                                IGeometryCollection polylineClass = new Polyline() as IGeometryCollection;
                                ISegmentCollection  pathClass     = new ESRI.ArcGIS.Geometry.Path() as ISegmentCollection;
                                pathClass.AddSegment((ISegment)circularArcClass, ref value, ref value);
                                polylineClass.AddGeometry((IGeometry)pathClass, ref value, ref value);
                                ((ITopologicalOperator)polylineClass).Simplify();
                                IGeometryCollection polylineClass1    = new Polyline() as IGeometryCollection;
                                ISegmentCollection  segmentCollection = new Path() as ISegmentCollection;
                                segmentCollection.AddSegment(segment, ref value, ref value);
                                polylineClass1.AddGeometry((IGeometry)segmentCollection, ref value, ref value);
                                ((ITopologicalOperator)polylineClass1).Simplify();
                                IGeometry geometry1 =
                                    ((ITopologicalOperator)polylineClass).Intersect((IGeometry)polylineClass1,
                                                                                    esriGeometryDimension.esriGeometry0Dimension);
                                if (geometry1 != null)
                                {
                                    if (!(geometry1 is IPointCollection))
                                    {
                                        lineClass = new Line();
                                        lineClass.PutCoords((IPoint)geometry1, ipoint0);
                                        if (num2 > length)
                                        {
                                            num2       = length;
                                            pointClass = ((IPointCollection)geometry1).Point[0];
                                            ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                            flag1 = true;
                                        }
                                    }
                                    else
                                    {
                                        lineClass = new Line();
                                        ILine lineClass1 = new Line();
                                        lineClass.PutCoords(((IPointCollection)geometry1).Point[0], ipoint0);
                                        lineClass1.PutCoords(((IPointCollection)geometry1).Point[1], ipoint0);
                                        if (lineClass.Length <= lineClass1.Length)
                                        {
                                            length     = lineClass.Length;
                                            pointClass = ((IPointCollection)geometry1).Point[0];
                                        }
                                        else
                                        {
                                            length     = lineClass1.Length;
                                            pointClass = ((IPointCollection)geometry1).Point[1];
                                        }
                                        if (num2 > length)
                                        {
                                            num2       = length;
                                            pointClass = ((IPointCollection)geometry1).Point[0];
                                            ipoint_0.PutCoords(pointClass.X, pointClass.Y);
                                            flag1 = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(flag1);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public override void OnMouseDown(int int_0, int int_1, int int_2, int int_3)
        {
            IFeature feature;
            int      i;
            IPoint   point;

            if (int_0 == 1)
            {
                IActiveView focusMap    = (IActiveView)_context.FocusMap;
                IPoint      anchorPoint = SketchToolAssist.AnchorPoint;
                double      mapUnits    = Common.ConvertPixelsToMapUnits(_context.FocusMap as IActiveView,
                                                                         _context.Config.EngineSnapEnvironment.SnapTolerance);
                Yutai.ArcGIS.Common.Editor.Editor.GetClosesFeature(_context.FocusMap, anchorPoint, mapUnits,
                                                                   esriGeometryType.esriGeometryPolyline, out feature);
                if (feature == null)
                {
                    MessageService.Current.Warn("没有点击的要素上,请设置较大的捕捉范围!");
                }
                else
                {
                    IPolycurve2 shape      = feature.Shape as IPolycurve2;
                    IEnvelope   envelope   = shape.Envelope;
                    object      value      = Missing.Value;
                    IHitTest    hitTest    = shape as IHitTest;
                    IPoint      pointClass = new Point();
                    double      num        = 0;
                    int         num1       = -1;
                    int         num2       = -1;
                    bool        flag       = false;
                    if (hitTest.HitTest(anchorPoint, mapUnits, esriGeometryHitPartType.esriGeometryPartBoundary,
                                        pointClass, ref num, ref num1, ref num2, ref flag))
                    {
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StartEditOperation();
                        IGeometryCollection polylineClass = new Polyline() as IGeometryCollection;
                        for (i = 0; i < num1; i++)
                        {
                            polylineClass.AddGeometry((shape as IGeometryCollection).Geometry[i], ref value, ref value);
                        }
                        IPointCollection geometry  = (shape as IGeometryCollection).Geometry[num1] as IPointCollection;
                        IPointCollection pathClass = new ESRI.ArcGIS.Geometry.Path();
                        for (i = 0; i < num2 + 1; i++)
                        {
                            point = (geometry.Point[i] as IClone).Clone() as IPoint;
                            pathClass.AddPoint(point, ref value, ref value);
                        }
                        pathClass.AddPoint((pointClass as IClone).Clone() as IPoint, ref value, ref value);
                        polylineClass.AddGeometry(pathClass as IGeometry, ref value, ref value);
                        if ((polylineClass as IPointCollection).PointCount > 1)
                        {
                            Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(polylineClass as IGeometry, shape);
                            feature.Shape = polylineClass as IGeometry;
                            feature.Store();
                        }
                        pathClass = new ESRI.ArcGIS.Geometry.Path();
                        pathClass.AddPoint((pointClass as IClone).Clone() as IPoint, ref value, ref value);
                        for (i = num2 + 1; i < geometry.PointCount; i++)
                        {
                            point = (geometry.Point[i] as IClone).Clone() as IPoint;
                            pathClass.AddPoint(point, ref value, ref value);
                        }
                        polylineClass = new Polyline() as IGeometryCollection;
                        polylineClass.AddGeometry(pathClass as IGeometry, ref value, ref value);
                        for (i = num1 + 1; i < (shape as IGeometryCollection).GeometryCount; i++)
                        {
                            polylineClass.AddGeometry((shape as IGeometryCollection).Geometry[i], ref value, ref value);
                        }
                        if ((polylineClass as IPointCollection).PointCount > 1)
                        {
                            IFeature feature1 = RowOperator.CreatRowByRow(feature as Row) as IFeature;
                            Yutai.ArcGIS.Common.Editor.Editor.SetGeometryZM(polylineClass as IGeometry, shape);
                            feature1.Shape = polylineClass as IGeometry;
                            feature1.Store();
                        }
                        Yutai.ArcGIS.Common.Editor.Editor.EditWorkspace.StopEditOperation();
                        (_context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, null,
                                                                          envelope);
                        (_context.FocusMap as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null,
                                                                          null);
                    }
                }
            }
        }