Exemplo n.º 1
0
        public static IPointCollection TriangleToPolygon(ITinTriangle itinTriangle_0)
        {
            IPointCollection pointCollection = new Ring();

            itinTriangle_0.QueryAsRing(pointCollection as IRing);
            IPointCollection pointCollection2 = new Polygon();

            pointCollection2.AddPointCollection(pointCollection);
            return(pointCollection2);
        }
Exemplo n.º 2
0
        public static IPolygon CreatePolygonByPoints(List <IPoint> points_list)
        {
            IPolygon         pPolygon;
            IPointCollection polygon_pt_cl = new Polygon();
            IPolyline        pPolyline     = new Polyline() as IPolyline;
            // create new pointcollection
            IPointCollection line_pt_cl = pPolyline as IPointCollection;
            object           o          = Type.Missing;

            foreach (IPoint point in points_list)
            {
                line_pt_cl.AddPoint(point, ref o, ref o);
            }
            //create polygon from pointcollection
            polygon_pt_cl.AddPointCollection(line_pt_cl);
            pPolygon = polygon_pt_cl as IPolygon;
            pPolygon.Close();
            return(pPolygon);
        }
Exemplo n.º 3
0
        private void CalculateArea(int x, int y, int pntnum)
        {
            double num;
            string str;
            string str1     = string.Concat(" 平方", this.GetUnitDesc(_context.FocusMap.MapUnits));
            object value    = Missing.Value;
            IPoint mapPoint = ((IActiveView)this._context.FocusMap).ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            if (!(pntnum != 1 ? true : this._polygonFeedback != null))
            {
                this._polygonFeedback = new NewPolygonFeedbackClass();
                this._polygonFeedback.Start(mapPoint);
                this._polygonFeedback.Display = ((IActiveView)this._context.FocusMap).ScreenDisplay;
                this._pointCollection         = new Polygon() as IPointCollection;
                this._pointCollection.AddPoint(mapPoint, ref value, ref value);
                graphicsContainer.DeleteAllElements();
                ((IActiveView)this._context.FocusMap).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            else if (this._polygonFeedback != null)
            {
                switch (pntnum)
                {
                case 1:
                {
                    this._polygonFeedback.AddPoint(mapPoint);
                    this._pointCollection.AddPoint(mapPoint, ref value, ref value);
                    if (this._pointCollection.PointCount > 2)
                    {
                        ITextElement     textElement  = new ParagraphTextElementClass();
                        IPointCollection polygonClass = new Polygon() as IPointCollection;
                        polygonClass.AddPointCollection(this._pointCollection);
                        polygonClass.AddPoint(_pointCollection.Point[0]);
                        num = Math.Abs(((IArea)polygonClass).Area);
                        str = string.Concat("总面积 = ", num.ToString("#.##"), str1);
                        textElement.Text   = str;
                        textElement.Symbol = pDistSymbol;
                        IElement element = textElement as IElement;
                        element.Geometry = polygonClass as IGeometry;
                        graphicsContainer.DeleteAllElements();
                        graphicsContainer.AddElement(element, 0);
                        ((IActiveView)this._context.FocusMap).PartialRefresh(esriViewDrawPhase.esriViewGraphics,
                                                                             null, null);
                    }
                    break;
                }

                case 2:
                {
                    this._polygonFeedback.MoveTo(mapPoint);
                    if (this._pointCollection.PointCount <= 1)
                    {
                        break;
                    }
                    IPointCollection polygonClass = new Polygon() as IPointCollection;
                    polygonClass.AddPointCollection(this._pointCollection);
                    polygonClass.AddPoint(mapPoint, ref value, ref value);
                    num = Math.Abs(((IArea)polygonClass).Area);
                    str = string.Concat("总面积 = ", num.ToString("#.##"), str1);
                    //ITextElement textElement = new ParagraphTextElementClass();
                    //textElement.Text = str;
                    //textElement.Symbol = pDistSymbol;
                    //IElement element = textElement as IElement;
                    //element.Geometry = polygonClass as IGeometry;
                    //graphicsContainer.DeleteAllElements();
                    //graphicsContainer.AddElement(element, 0);
                    //activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    break;
                }

                case 3:
                {
                    IPolygon polygon = this._polygonFeedback.Stop();
                    if (polygon.IsEmpty)
                    {
                        // this.m_HookHelper.SetStatus("");
                    }
                    else
                    {
                        num = Math.Abs(((IArea)polygon).Area);
                        str = string.Concat("总面积 = ", num.ToString("#.##"), str1);

                        ITextElement textElement = new ParagraphTextElementClass();
                        textElement.Text   = str;
                        textElement.Symbol = pDistSymbol;
                        IElement element = textElement as IElement;
                        element.Geometry = polygon as IGeometry;
                        graphicsContainer.DeleteAllElements();
                        graphicsContainer.AddElement(element, 0);
                        ((IActiveView)this._context.FocusMap).PartialRefresh(esriViewDrawPhase.esriViewGraphics,
                                                                             null, null);
                    }
                    this._polygonFeedback = null;
                    this._pointCollection = null;
                    ((IActiveView)this._context.FocusMap).Refresh();
                    break;
                }
                }
            }
        }