private void BuildPath ( PdfContents Contents, PaintOp PaintOperator ) { // every figure is a separated subpath and contains some segments foreach (SysMedia.PathFigure SubPath in MediaPath.Figures) { // get start of sub-path point PointD CurPoint = PathToDrawing(SubPath.StartPoint); PointD StartPoint = CurPoint; Contents.MoveTo(CurPoint); // process all points of one sub-path foreach (SysMedia.PathSegment Seg in SubPath.Segments) { // line segment if (Seg.GetType() == typeof(SysMedia.LineSegment)) { CurPoint = PathToDrawing(((SysMedia.LineSegment)Seg).Point); Contents.LineTo(CurPoint); } // polygon else if (Seg.GetType() == typeof(SysMedia.PolyLineSegment)) { SysMedia.PolyLineSegment LineSegArray = (SysMedia.PolyLineSegment)Seg; foreach (SysWin.Point PolyPoint in LineSegArray.Points) { CurPoint = PathToDrawing(PolyPoint); Contents.LineTo(CurPoint); } } // cubic bezier segment else if (Seg.GetType() == typeof(SysMedia.BezierSegment)) { SysMedia.BezierSegment BezierSeg = (SysMedia.BezierSegment)Seg; CurPoint = PathToDrawing(BezierSeg.Point3); Contents.DrawBezier(PathToDrawing(BezierSeg.Point1), PathToDrawing(BezierSeg.Point2), CurPoint); } // cubic bezier multi segments else if (Seg.GetType() == typeof(SysMedia.PolyBezierSegment)) { SysMedia.PolyBezierSegment BezierSegArray = (SysMedia.PolyBezierSegment)Seg; int Count = BezierSegArray.Points.Count; for (int Index = 0; Index < Count; Index += 3) { CurPoint = PathToDrawing(BezierSegArray.Points[Index + 2]); Contents.DrawBezier(PathToDrawing(BezierSegArray.Points[Index]), PathToDrawing(BezierSegArray.Points[Index + 1]), CurPoint); } } // quadratic bezier segment else if (Seg.GetType() == typeof(SysMedia.QuadraticBezierSegment)) { SysMedia.QuadraticBezierSegment BezierSeg = (SysMedia.QuadraticBezierSegment)Seg; PointD NextPoint = PathToDrawing(BezierSeg.Point2); Contents.DrawBezier(new BezierD(CurPoint, PathToDrawing(BezierSeg.Point1), NextPoint), BezierPointOne.Ignore); CurPoint = NextPoint; } // quadratic bezier multi segments else if (Seg.GetType() == typeof(SysMedia.PolyQuadraticBezierSegment)) { SysMedia.PolyQuadraticBezierSegment BezierSegArray = (SysMedia.PolyQuadraticBezierSegment)Seg; int Count = BezierSegArray.Points.Count; for (int Index = 0; Index < Count; Index += 2) { PointD NextPoint = PathToDrawing(BezierSegArray.Points[Index + 1]); Contents.DrawBezier(new BezierD(CurPoint, PathToDrawing(BezierSegArray.Points[Index]), NextPoint), BezierPointOne.Ignore); CurPoint = NextPoint; } } // draw arc else if (Seg.GetType() == typeof(SysMedia.ArcSegment)) { SysMedia.ArcSegment Arc = (SysMedia.ArcSegment)Seg; PointD NextPoint = PathToDrawing(Arc.Point); ArcType ArcType; if (Arc.SweepDirection == (PathYAxis == YAxisDirection.Down ? SysMedia.SweepDirection.Counterclockwise : SysMedia.SweepDirection.Clockwise)) { ArcType = Arc.IsLargeArc ? ArcType.LargeCounterClockWise : ArcType.SmallCounterClockWise; } else { ArcType = Arc.IsLargeArc ? ArcType.LargeClockWise : ArcType.SmallClockWise; } Contents.DrawArc(CurPoint, NextPoint, SizeToDrawing(Arc.Size), Arc.RotationAngle, ArcType, BezierPointOne.Ignore); CurPoint = NextPoint; } // should no happen else { throw new ApplicationException("Windows Media path: unknown path segment."); } } // for stroke set paint operator for each sub-path if (SubPath.IsClosed) { Contents.SetPaintOp(PaintOp.CloseSubPath); } } // paint operator Contents.SetPaintOp(PaintOperator); return; }