Ejemplo n.º 1
0
        /// <summary>
        /// Value clone
        /// </summary>
        /// <returns>new polyline shape</returns>
        public PolylineShape ValueClone()
        {
            PolylineShape aPLS = new PolylineShape();

            aPLS.value       = value;
            aPLS.Visible     = Visible;
            aPLS.Selected    = Selected;
            aPLS.LegendIndex = LegendIndex;

            return(aPLS);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Clone polylineshape
        /// </summary>
        /// <returns>PolylineShape</returns>
        public override object Clone()
        {
            PolylineShape aPLS = new PolylineShape();

            aPLS.value       = value;
            aPLS.Extent      = Extent;
            aPLS._numParts   = _numParts;
            aPLS.parts       = (int[])parts.Clone();
            aPLS.Points      = new List <PointD>(Points);
            aPLS.Visible     = Visible;
            aPLS.Selected    = Selected;
            aPLS.LegendIndex = LegendIndex;

            return(aPLS);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Select graphics by an extent
        /// </summary>
        /// <param name="aExtent">extent</param>
        /// <param name="selectedGraphics">ref selected graphics</param>
        /// <returns>if selected</returns>
        public bool SelectGraphics(Extent aExtent, ref GraphicCollection selectedGraphics)
        {
            selectedGraphics.GraphicList.Clear();
            int    i, j;
            PointD aPoint = new PointD();

            aPoint.X = (aExtent.minX + aExtent.maxX) / 2;
            aPoint.Y = (aExtent.minY + aExtent.maxY) / 2;

            foreach (Graphic aGraphic in _graphicList)
            {
                switch (aGraphic.Shape.ShapeType)
                {
                case ShapeTypes.Point:
                    for (i = 0; i < Count; i++)
                    {
                        PointShape aPS = (PointShape)_graphicList[i].Shape;
                        if (MIMath.PointInExtent(aPS.Point, aExtent))
                        {
                            selectedGraphics.Add(aGraphic);
                        }
                    }
                    break;

                case ShapeTypes.Polyline:
                case ShapeTypes.PolylineZ:
                    for (i = 0; i < Count; i++)
                    {
                        PolylineShape aPLS = (PolylineShape)_graphicList[i].Shape;
                        if (MIMath.IsExtentCross(aExtent, aPLS.Extent))
                        {
                            for (j = 0; j < aPLS.Points.Count; j++)
                            {
                                aPoint = aPLS.Points[j];
                                if (MIMath.PointInExtent(aPoint, aExtent))
                                {
                                    selectedGraphics.Add(aGraphic);
                                    break;
                                }
                            }
                        }
                    }
                    break;

                case ShapeTypes.Polygon:
                case ShapeTypes.Rectangle:
                    for (i = Count - 1; i >= 0; i--)
                    {
                        PolygonShape aPGS = (PolygonShape)_graphicList[i].Shape;
                        if (!(aPGS.PartNum > 1))
                        {
                            if (MIMath.PointInPolygon(aPGS.Points, aPoint))
                            {
                                selectedGraphics.Add(aGraphic);
                            }
                        }
                        else
                        {
                            for (int p = 0; p < aPGS.PartNum; p++)
                            {
                                ArrayList pList = new ArrayList();
                                if (p == aPGS.PartNum - 1)
                                {
                                    for (int pp = aPGS.parts[p]; pp < aPGS.PointNum; pp++)
                                    {
                                        pList.Add(aPGS.Points[pp]);
                                    }
                                }
                                else
                                {
                                    for (int pp = aPGS.parts[p]; pp < aPGS.parts[p + 1]; pp++)
                                    {
                                        pList.Add(aPGS.Points[pp]);
                                    }
                                }
                                if (MIMath.PointInPolygon(pList, aPoint))
                                {
                                    selectedGraphics.Add(aGraphic);
                                    break;
                                }
                            }
                        }
                    }
                    break;
                }
            }

            if (selectedGraphics.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        private Shape LoadShape(XmlNode shapeNode)
        {
            Shape aShape = new Shape();

            try
            {
                ShapeTypes shapeType = (ShapeTypes)Enum.Parse(typeof(ShapeTypes), shapeNode.Attributes["ShapeType"].InnerText, true);
                switch (shapeType)
                {
                case ShapeTypes.Point:
                    aShape = new PointShape();
                    break;

                case ShapeTypes.WindArraw:
                    aShape = new WindArraw();
                    break;

                case ShapeTypes.Polyline:
                    aShape = new PolylineShape();
                    break;

                case ShapeTypes.CurveLine:
                    aShape = new CurveLineShape();
                    break;

                case ShapeTypes.Circle:
                    aShape = new CircleShape();
                    break;

                case ShapeTypes.Polygon:
                case ShapeTypes.Rectangle:
                    aShape = new PolygonShape();
                    break;

                case ShapeTypes.CurvePolygon:
                    aShape = new CurvePolygonShape();
                    break;

                case ShapeTypes.Ellipse:
                    aShape = new EllipseShape();
                    break;
                }

                aShape.Visible  = bool.Parse(shapeNode.Attributes["Visible"].InnerText);
                aShape.Selected = bool.Parse(shapeNode.Attributes["Selected"].InnerText);

                List <PointD> pointList  = new List <PointD>();
                XmlNode       pointsNode = shapeNode.ChildNodes[0];
                foreach (XmlNode pNode in pointsNode.ChildNodes)
                {
                    PointD aPoint = new PointD(double.Parse(pNode.Attributes["X"].InnerText),
                                               double.Parse(pNode.Attributes["Y"].InnerText));
                    pointList.Add(aPoint);
                }
                aShape.SetPoints(pointList);
            }
            catch
            {
            }

            return(aShape);
        }