ClosePathStroke() public method

public ClosePathStroke ( ) : void
return void
        // ---------------------------------------------------------------------------    
        /**
         * Draws the time table for a day at the film festival.
         * @param directcontent a canvas to which the time table has to be drawn.
         */
        protected void DrawTimeTable(PdfContentByte directcontent)
        {
            directcontent.SaveState();
            directcontent.SetLineWidth(1.2f);
            float llx, lly, urx, ury;

            llx = OFFSET_LEFT;
            lly = OFFSET_BOTTOM;
            urx = OFFSET_LEFT + WIDTH;
            ury = OFFSET_BOTTOM + HEIGHT;
            directcontent.MoveTo(llx, lly);
            directcontent.LineTo(urx, lly);
            directcontent.LineTo(urx, ury);
            directcontent.LineTo(llx, ury);
            directcontent.ClosePath();
            directcontent.Stroke();

            llx = OFFSET_LOCATION;
            lly = OFFSET_BOTTOM;
            urx = OFFSET_LOCATION + WIDTH_LOCATION;
            ury = OFFSET_BOTTOM + HEIGHT;
            directcontent.MoveTo(llx, lly);
            directcontent.LineTo(urx, lly);
            directcontent.LineTo(urx, ury);
            directcontent.LineTo(llx, ury);
            directcontent.ClosePathStroke();

            directcontent.SetLineWidth(1);
            directcontent.MoveTo(
              OFFSET_LOCATION + WIDTH_LOCATION / 2, OFFSET_BOTTOM
            );
            directcontent.LineTo(
              OFFSET_LOCATION + WIDTH_LOCATION / 2, OFFSET_BOTTOM + HEIGHT
            );
            float y;
            for (int i = 1; i < LOCATIONS; i++)
            {
                y = OFFSET_BOTTOM + (i * HEIGHT_LOCATION);
                if (i == 2 || i == 6)
                {
                    directcontent.MoveTo(OFFSET_LOCATION, y);
                    directcontent.LineTo(OFFSET_LOCATION + WIDTH_LOCATION, y);
                }
                else
                {
                    directcontent.MoveTo(OFFSET_LOCATION + WIDTH_LOCATION / 2, y);
                    directcontent.LineTo(OFFSET_LOCATION + WIDTH_LOCATION, y);
                }
                directcontent.MoveTo(OFFSET_LEFT, y);
                directcontent.LineTo(OFFSET_LEFT + WIDTH, y);
            }
            directcontent.Stroke();
            directcontent.RestoreState();
        }
Esempio n. 2
0
        /// <summary>
        /// Renders the object in a document using a <see cref="PdfContentByte"/> by invoking the <see cref="Render(ContentWriter, Vector2D)"/> method.
        /// This method can be overridden in derived classes to specify rendering.
        /// </summary>
        /// <param name="cb">The <see cref="PdfContentByte"/> used for rendering.</param>
        /// <param name="offset">The calculated offset for the rendered item.</param>
        protected internal virtual void Render(PdfContentByte cb, Vector2D offset)
        {
            using (var writer = new ContentWriter(cb))
            {
                var stroke = this as StrokeObject;
                var fill = this as FillObject;

                bool hasstroke = stroke?.BorderColor.HasValue ?? false;
                bool hasfill = fill?.FillColor.HasValue ?? false;

                if (hasstroke)
                {
                    cb.SetLineWidth((float)stroke.BorderWidth.Value(UnitsOfMeasure.Points));
                    cb.SetColorStroke(new Color(stroke.BorderColor.Value));
                }
                if (hasfill)
                    cb.SetColorFill(new Color(fill.FillColor.Value));

                Render(writer, offset);

                if (hasstroke && hasfill)
                {
                    if (writer.CloseShape)
                        cb.ClosePathFillStroke();
                    else
                        cb.FillStroke();
                }
                else if (hasstroke)
                {
                    if (writer.CloseShape)
                        cb.ClosePathStroke();
                    else
                        cb.Stroke();
                }
                else if (hasfill)
                    cb.Fill();
            }
        }
Esempio n. 3
0
// ---------------------------------------------------------------------------    
    /**
     * Draws a row of squares.
     * @param canvas the canvas to which the squares have to be drawn
     * @param x      X coordinate to position the row
     * @param y      Y coordinate to position the row
     * @param side   the side of the square
     * @param gutter the space between the squares
     */
    public void CreateSquares(PdfContentByte canvas,
      float x, float y, float side, float gutter) {
      canvas.SaveState();
      canvas.SetColorStroke(new GrayColor(0.2f));
      canvas.SetColorFill(new GrayColor(0.9f));
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.Stroke();
      x = x + side + gutter;
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.ClosePathStroke();
      x = x + side + gutter;
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.Fill();
      x = x + side + gutter;
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.FillStroke();
      x = x + side + gutter;
      canvas.MoveTo(x, y);
      canvas.LineTo(x + side, y);
      canvas.LineTo(x + side, y + side);
      canvas.LineTo(x, y + side);
      canvas.ClosePathFillStroke();
      canvas.RestoreState();
    }