static void FillContexForCurve(WStreamGeometryContext context, Curve c) { foreach (ICurve seg in c.Segments) { var bezSeg = seg as CubicBezierSegment; if (bezSeg != null) { context.BezierTo(Common.WpfPoint(bezSeg.B(1)), Common.WpfPoint(bezSeg.B(2)), Common.WpfPoint(bezSeg.B(3)), true, false); } else { var ls = seg as MLineSegment; if (ls != null) { context.LineTo(Common.WpfPoint(ls.End), true, false); } else { var ellipse = seg as MEllipse; if (ellipse != null) { double sweepAngle = EllipseSweepAngle(ellipse); bool largeArc = Math.Abs(sweepAngle) >= Math.PI; MRectangle box = ellipse.FullBox(); context.ArcTo(Common.WpfPoint(ellipse.End), new WSize(box.Width / 2, box.Height / 2), sweepAngle, largeArc, sweepAngle < 0 ? WSweepDirection.Counterclockwise : WSweepDirection.Clockwise, true, true); } else { throw new NotImplementedException(); } } } } }
internal static void FillContextForICurve(WStreamGeometryContext context, ICurve iCurve) { context.BeginFigure(Common.WpfPoint(iCurve.Start), false, false); var c = iCurve as Curve; if (c != null) { FillContexForCurve(context, c); } else { var cubicBezierSeg = iCurve as CubicBezierSegment; if (cubicBezierSeg != null) { context.BezierTo(Common.WpfPoint(cubicBezierSeg.B(1)), Common.WpfPoint(cubicBezierSeg.B(2)), Common.WpfPoint(cubicBezierSeg.B(3)), true, false); } else { var ls = iCurve as MLineSegment; if (ls != null) { context.LineTo(Common.WpfPoint(ls.End), true, false); } else { var rr = iCurve as RoundedRect; if (rr != null) { FillContexForCurve(context, rr.Curve); } else { var poly = iCurve as MPolyline; if (poly != null) { FillContexForPolyline(context, poly); } else { var ellipse = iCurve as MEllipse; if (ellipse != null) { double sweepAngle = EllipseSweepAngle(ellipse); bool largeArc = Math.Abs(sweepAngle) >= Math.PI; MRectangle box = ellipse.FullBox(); context.ArcTo(Common.WpfPoint(ellipse.End), new WSize(box.Width / 2, box.Height / 2), sweepAngle, largeArc, sweepAngle < 0 ? WSweepDirection.Counterclockwise : WSweepDirection.Clockwise, true, true); } else { throw new NotImplementedException(); } } } } } } }