示例#1
0
        public void DrawRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }

            this.SaveGraphicsState();
            PDFRect rect = new PDFRect(x, y, width, height);

            pen.SetUpGraphics(this, rect);
            this.RenderRectangle(x, y, width, height);
            this.RenderStrokePathOp();
            pen.ReleaseGraphics(this, rect);
            this.RestoreGraphicsState();
        }
示例#2
0
        public void DrawRoundRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Sides sides, PDFUnit cornerRadius)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }

            PDFRect bounds = new PDFRect(x, y, width, height);

            this.SaveGraphicsState();
            pen.SetUpGraphics(this, bounds);
            this.DoOutputRoundRectangleWithSidesPath(x, y, width, height, cornerRadius, sides);
            this.RenderStrokePathOp();
            pen.ReleaseGraphics(this, bounds);
            this.RestoreGraphicsState();
        }
示例#3
0
        public void DrawElipse(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }
            PDFRect bounds = new PDFRect(x, y, width, height);

            this.SaveGraphicsState();
            pen.SetUpGraphics(this, bounds);

            OutputElipsePoints(x, y, width, height);
            this.RenderCloseStrokePathOp();

            pen.ReleaseGraphics(this, bounds);

            this.RestoreGraphicsState();
        }
        /// <summary>
        /// Internal method to render the grid
        /// </summary>
        protected virtual void DoRenderGrid(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, PDFUnit spacing)
        {
            this.Writer.WriteOpCodeS(PDFOpCode.SaveState);
            PDFRect bounds = new PDFRect(x, y, width, height);

            pen.SetUpGraphics(this, bounds);


            //Draw the vertical lines
            OutputVerticalLines(x.RealValue, y.RealValue, width.RealValue, height.RealValue, spacing.RealValue);

            //Draw the horizontal Lines
            OutputHorizontalLines(x.RealValue, y.RealValue, width.RealValue, height.RealValue, spacing.RealValue);


            pen.ReleaseGraphics(this, bounds);

            this.Writer.WriteOpCodeS(PDFOpCode.RestoreState);
        }
示例#5
0
        private void OutputPath(PDFBrush brush, PDFPen pen, PDFPoint location, PDFGraphicsPath path)
        {
            PDFRect bounds = new PDFRect(path.Bounds.X + location.X, path.Bounds.Y + location.Y, path.Bounds.Width, path.Bounds.Height);

            if (null != brush)
            {
                brush.SetUpGraphics(this, bounds);
            }
            if (null != pen)
            {
                pen.SetUpGraphics(this, bounds);
            }

            PDFPoint cursor = PDFPoint.Empty;

            foreach (Path p in path.SubPaths)
            {
                RenderPathData(location, p, ref cursor);
            }

            if (null != brush && null != pen)
            {
                this.RenderFillAndStrokePathOp(path.Mode == GraphicFillMode.EvenOdd);
            }
            else if (null != brush)
            {
                this.RenderFillPathOp(path.Mode == GraphicFillMode.EvenOdd);
            }
            else if (null != pen)
            {
                this.RenderStrokePathOp();
            }


            if (null != brush)
            {
                brush.ReleaseGraphics(this, bounds);
            }
            if (null != pen)
            {
                pen.ReleaseGraphics(this, bounds);
            }
        }
示例#6
0
        public void DrawRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Sides sides)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }

            PDFRect rect = new PDFRect(x, y, width, height);

            this.SaveGraphicsState();
            pen.SetUpGraphics(this, rect);

            //check to see if we are outputting all sides
            if (sides == (Sides.Top | Sides.Right | Sides.Left | Sides.Bottom))
            {
                this.RenderRectangle(x, y, width, height);
            }
            else
            {
                bool recalc = true; //flag to identifiy if the last op moved the cursor to the next correct position

                if ((sides & Sides.Top) > 0)
                {
                    this.RenderLine(x, y, x + width, y);
                    recalc = false;
                }
                else
                {
                    recalc = true;
                }

                if ((sides & Sides.Right) > 0)
                {
                    if (recalc == false)
                    {
                        this.RenderContinuationLine(x + width, y + height);
                    }
                    else
                    {
                        this.RenderLine(x + width, y, x + width, y + height);
                    }
                    recalc = false;
                }
                else
                {
                    recalc = true;
                }

                if ((sides & Sides.Bottom) > 0)
                {
                    if (recalc == false)
                    {
                        this.RenderContinuationLine(x, y + height);
                    }
                    else
                    {
                        this.RenderLine(x + width, y + height, x, y + height);
                    }
                    recalc = false;
                }
                else
                {
                    recalc = true;
                }

                if ((sides & Sides.Left) > 0)
                {
                    if (recalc == false)
                    {
                        this.RenderContinuationLine(x, y);
                    }
                    else
                    {
                        this.RenderLine(x, y + height, x, y);
                    }
                }
            }
            this.RenderStrokePathOp();
            pen.ReleaseGraphics(this, rect);

            this.RestoreGraphicsState();
        }