/// <summary>
        /// Returns true if the element intersect the rectangle from the parent class
        /// </summary>
        /// <param name="rect">The rectangle to test must be in the virtual modeling coordinant plane</param>
        /// <returns></returns>
        public override bool elementInRectangle(Rectangle rect)
        {
            Geometries.IGeometry rectanglePoly;
            if ((rect.Height == 0) && (rect.Width == 0))
            {
                rectanglePoly = new Geometries.Point(rect.X, rect.Y);
            }
            else if (rect.Width == 0)
            {
                Geometries.Point[] rectanglePoints = new Geometries.Point[2];
                rectanglePoints[0] = new Geometries.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Geometries.Point(rect.X, rect.Y + rect.Height);
                rectanglePoly = new MapWindow.Geometries.LineString(rectanglePoints);
            }
            else if (rect.Height == 0)
            {
                Geometries.Point[] rectanglePoints = new Geometries.Point[2];
                rectanglePoints[0] = new Geometries.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Geometries.Point(rect.X + rect.Width, rect.Y);
                rectanglePoly = new MapWindow.Geometries.LineString(rectanglePoints);
            }
            else
            {
                Geometries.Point[] rectanglePoints = new Geometries.Point[5];
                rectanglePoints[0] = new Geometries.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Geometries.Point(rect.X, rect.Y + rect.Height);
                rectanglePoints[2] = new Geometries.Point(rect.X + rect.Width, rect.Y + rect.Height);
                rectanglePoints[3] = new Geometries.Point(rect.X + rect.Width, rect.Y);
                rectanglePoints[4] = new Geometries.Point(rect.X, rect.Y);
                rectanglePoly = new Geometries.Polygon(new Geometries.LinearRing(rectanglePoints));
            }

            if (Shape == ModelShapes.Arrow)
            {
                Geometries.Point[] arrowPoints = new Geometries.Point[_arrowPath.PointCount];
                for(int i = 0; i < _arrowPath.PointCount; i++)
                {
                    arrowPoints[i] = new Geometries.Point(_arrowPath.PathPoints[i].X + this.Location.X,_arrowPath.PathPoints[i].Y + this.Location.Y);
                }
                Geometries.LineString arrowLine = new MapWindow.Geometries.LineString(arrowPoints);
                return (arrowLine.Intersects(rectanglePoly));
            }
            return false;
        }
        /// <summary>
        /// Returns true if the element intersect the rectangle from the parent class
        /// </summary>
        /// <param name="rect">The rectangle to test must be in the virtual modeling coordinant plane</param>
        /// <returns></returns>
        public virtual bool elementInRectangle(Rectangle rect)
        {
            Geometries.IGeometry rectanglePoly;
            if ((rect.Height == 0) && (rect.Width == 0))
            {
                rectanglePoly = new Geometries.Point(rect.X, rect.Y);
            }
            else if (rect.Width == 0)
            {
                Geometries.Point[] rectanglePoints = new Geometries.Point[2];
                rectanglePoints[0] = new Geometries.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Geometries.Point(rect.X, rect.Y + rect.Height);
                rectanglePoly = new MapWindow.Geometries.LineString(rectanglePoints);
            }
            else if (rect.Height == 0)
            {
                Geometries.Point[] rectanglePoints = new Geometries.Point[2];
                rectanglePoints[0] = new Geometries.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Geometries.Point(rect.X + rect.Width, rect.Y);
                rectanglePoly = new MapWindow.Geometries.LineString(rectanglePoints);
            }
            else
            {
                Geometries.Point[] rectanglePoints = new Geometries.Point[5];
                rectanglePoints[0] = new Geometries.Point(rect.X, rect.Y);
                rectanglePoints[1] = new Geometries.Point(rect.X, rect.Y + rect.Height);
                rectanglePoints[2] = new Geometries.Point(rect.X + rect.Width, rect.Y + rect.Height);
                rectanglePoints[3] = new Geometries.Point(rect.X + rect.Width, rect.Y);
                rectanglePoints[4] = new Geometries.Point(rect.X, rect.Y);
                rectanglePoly = new Geometries.Polygon(new Geometries.LinearRing(rectanglePoints));
            }

            switch (Shape)
            {
                case ModelShapes.Rectangle:
                    return (rect.IntersectsWith(this.Rectangle));

                case ModelShapes.Ellipse:
                    int b = Height / 2;
                    int a = Width / 2;
                    Geometries.Point[] ellipsePoints = new Geometries.Point[(4 * a) + 1];
                    for (int x = -a; x <= a; x++)
                    {
                        if (x == 0)
                        {
                            ellipsePoints[x + a] = new Geometries.Point(Location.X + x + a, Location.Y);
                            ellipsePoints[3 * a - x] = new Geometries.Point(Location.X + x + a, Location.Y + Height);
                        }
                        else
                        {
                            ellipsePoints[x + a] = new Geometries.Point(Location.X + x + a, Location.Y + b - System.Math.Sqrt(System.Math.Abs(((b * b * x * x) / (a * a)) - (b * b))));
                            ellipsePoints[3 * a - x] = new Geometries.Point(Location.X + x + a, Location.Y + b + System.Math.Sqrt(System.Math.Abs(((b * b * x * x) / (a * a)) - (b * b))));
                        }
                    }

                    Geometries.Polygon ellipsePoly = new Geometries.Polygon(new Geometries.LinearRing(ellipsePoints));
                    return (ellipsePoly.Intersects(rectanglePoly));

                case ModelShapes.Triangle:
                    Geometries.Point[] trianglePoints = new Geometries.Point[4];
                    trianglePoints[0] = new Geometries.Point(Location.X, Location.Y);
                    trianglePoints[1] = new Geometries.Point(Location.X, Location.Y + Height);
                    trianglePoints[2] = new Geometries.Point(Location.X + Width - 5, Location.Y + ((this.Height - 5) / 2));
                    trianglePoints[3] = new Geometries.Point(Location.X, Location.Y);
                    Geometries.Polygon trianglePoly = new Geometries.Polygon(new Geometries.LinearRing(trianglePoints));
                    return (trianglePoly.Intersects(rectanglePoly));

                default:
                    return false;
            }

        }