public void MoveTo(PDFPoint start)
        {
            PathMoveData move = new PathMoveData();

            move.MoveTo = start;
            CurrentPath.Add(move);
            IncludeInBounds(start);
            Cursor = start;
        }
        public void MoveBy(PDFPoint delta)
        {
            PathMoveData move = new PathMoveData();
            PDFPoint     pos  = ConvertDeltaToActual(delta);

            move.MoveTo = pos;
            CurrentPath.Add(move);
            IncludeInBounds(pos);
            Cursor = pos;
        }
Beispiel #3
0
        private void RenderPathOp(PathData data, PDFPoint location, ref PDFPoint cursor)
        {
            switch (data.Type)
            {
            case PathDataType.Move:
                PathMoveData move = (PathMoveData)data;
                cursor = move.MoveTo;
                this.RenderMoveTo(move.MoveTo.X + location.X, move.MoveTo.Y + location.Y);
                break;

            case PathDataType.Line:
                PathLineData line = (PathLineData)data;
                cursor = line.LineTo;
                this.RenderLineTo(line.LineTo.X + location.X, line.LineTo.Y + location.Y);
                break;

            case PathDataType.Rect:
                PathRectData rect = (PathRectData)data;
                cursor = rect.Rect.Location;
                this.RenderRectangle(rect.Rect.X + location.X, rect.Rect.Y + location.Y, rect.Rect.Width, rect.Rect.Height);
                break;

            case PathDataType.SubPath:
                PathSubPathData sub = (PathSubPathData)data;
                this.RenderPathData(location, sub.InnerPath, ref cursor);
                break;

            case PathDataType.Bezier:
                PathBezierCurveData bez = (PathBezierCurveData)data;
                cursor = bez.EndPoint;
                if (bez.HasStartHandle && bez.HasEndHandle)
                {
                    this.RenderBezierCurveTo(bez.EndPoint.X + location.X, bez.EndPoint.Y + location.Y,
                                             bez.StartHandle.X + location.X, bez.StartHandle.Y + location.Y,
                                             bez.EndHandle.X + location.X, bez.EndHandle.Y + location.Y);
                }
                else if (bez.HasStartHandle)
                {
                    this.RenderBezierCurveToWithStartHandleOnly(bez.EndPoint.X + location.X, bez.EndPoint.Y + location.Y,
                                                                bez.StartHandle.X + location.X, bez.StartHandle.Y + location.Y);
                }
                else if (bez.HasEndHandle)
                {
                    this.RenderBezierCurveToWithEndHandleOnly(bez.EndPoint.X + location.X, bez.EndPoint.Y + location.Y,
                                                              bez.EndHandle.X + location.X, bez.EndHandle.Y + location.Y);
                }
                else
                {
                    this.RenderLineTo(bez.Points[2].X, bez.Points[2].Y);
                }

                break;

            case PathDataType.Arc:
                IEnumerable <PathBezierCurveData> segments;
                PathArcData arc = (PathArcData)data;
                segments = PathDataHelper.GetBezierCurvesForArc(cursor, arc);
                foreach (PathBezierCurveData segment in segments)
                {
                    this.RenderBezierCurveTo(segment.EndPoint.X + location.X,
                                             segment.EndPoint.Y + location.Y,
                                             segment.StartHandle.X + location.X,
                                             segment.StartHandle.Y + location.Y,
                                             segment.EndHandle.X + location.X,
                                             segment.EndHandle.Y + location.Y);
                }
                cursor = arc.EndPoint;
                break;

            case PathDataType.Quadratic:
                IEnumerable <PathBezierCurveData> quadSegments;
                PathQuadraticCurve quad = (PathQuadraticCurve)data;
                quadSegments = PathDataHelper.GetBezierCurvesForQuadratic(cursor, quad);
                foreach (PathBezierCurveData quadSeg in quadSegments)
                {
                    this.RenderBezierCurveTo(quadSeg.EndPoint.X + location.X, quadSeg.EndPoint.Y + location.Y,
                                             quadSeg.StartHandle.X + location.X, quadSeg.StartHandle.Y + location.Y,
                                             quadSeg.EndHandle.X + location.X, quadSeg.EndHandle.Y + location.Y);
                }
                cursor = quad.EndPoint;
                break;

            case PathDataType.Close:
                this.RenderClosePathOp();
                cursor = PDFPoint.Empty;
                break;

            default:
                throw new ArgumentOutOfRangeException("data.Type");
            }
        }