Esempio n. 1
0
 protected override Drawing.PDFPoint[] GetPoints(Drawing.PDFRect bounds, Style style)
 {
     if (this.HasPoints)
     {
         return(this.Points.ToArray());
     }
     else
     {
         return(base.GetPoints(bounds, style));
     }
 }
        /// <summary>
        /// Gets all the points in this polygon based on the required bounds.
        /// Inheritors can override this method.
        /// </summary>
        /// <param name="bounds">The bounds this polygo should fit into.</param>
        /// <param name="style">The style of the polygon</param>
        /// <returns>An array of points</returns>
        protected virtual Drawing.PDFPoint[] GetPoints(Drawing.PDFRect bounds, Style style)
        {
            int    vCount   = style.GetValue(StyleKeys.ShapeVertexCountKey, this.DefaultShapeVetexCount);
            double rotation = style.GetValue(StyleKeys.ShapeRotationKey, 0.0);

            if (vCount > 2)
            {
                PDFUnit  radiusX = (bounds.Width / 2.0);
                PDFUnit  radiusY = (bounds.Height / 2.0);
                PDFPoint centre  = new PDFPoint(radiusX, radiusY);

                return(this.GetRegularPolygonPoints(centre, radiusX, radiusY, vCount, rotation));
            }
            else if (vCount != 0) //between 1 and 2 sides is invalid.
            {
                throw new PDFException(Errors.CannotCreatePolygonWithLessThan3Sides, null);
            }
            else
            {
                return new PDFPoint[] { }
            };
        }