@@ -477,173 +477,19 @@ internal DrawingGroup LoadGroup(IList<Shape> elements, Rect? viewBox, bool isSwi
477477 if ( shape is PathShape )
478478 {
479479 PathShape r = shape as PathShape ;
480- // PathFigure p = null;
481- Point lastPoint = new Point ( 0 , 0 ) ;
482-
483- // PathShape.CurveTo lastc = null;
484- // PathShape.QuadraticCurveTo lastq = null;
485- Point lastcirPoint = new Point ( 0 , 0 ) ;
486- PathGeometry path = PathGeometry . CreateFromGeometry ( PathGeometry . Parse ( r . Data ) ) ;
487- //PathGeometry path = new PathGeometry();
488-
489- /*
490- foreach (PathShape.PathElement element in r.Elements)
480+ var svg = this . SVG ;
481+ if ( r . Fill == null || r . Fill . IsEmpty ( svg ) )
491482 {
492- bool isRelative = element.IsRelative;
493- if (element is PathShape.MoveTo)
483+ if ( r . Stroke == null || r . Stroke . IsEmpty ( svg ) )
494484 {
495- p = new PathFigure();
496- p.IsClosed = r.ClosePath;
497- if (isRelative) p.StartPoint = lastPoint + (Vector)((PathShape.MoveTo)element).Point;
498- else p.StartPoint = ((PathShape.MoveTo)element).Point;
499- lastPoint = p.StartPoint;
500- path.Figures.Add(p);
501- continue;
502- }
503- if (element is PathShape.LineTo)
504- {
505- PathShape.LineTo lineto = element as PathShape.LineTo;
506- foreach (Point point in lineto.Points)
507- {
508- if (isRelative)
509- {
510- Point newpoint = lastPoint + (Vector)point;
511- lastPoint = newpoint;
512- p.Segments.Add(new LineSegment(newpoint, true));
513- }
514- else
515- {
516- if (lineto.PositionType == PathShape.LineTo.eType.Point) lastPoint = point;
517- if (lineto.PositionType == PathShape.LineTo.eType.Horizontal) lastPoint = new Point(point.X, lastPoint.Y);
518- if (lineto.PositionType == PathShape.LineTo.eType.Vertical) lastPoint = new Point(lastPoint.X, point.Y);
519- p.Segments.Add(new LineSegment(lastPoint, true));
520- }
521- }
522- continue;
523- }
524- if (element is PathShape.CurveTo)
525- {
526- PathShape.CurveTo c = element as PathShape.CurveTo;
527- Point startPoint = lastPoint;
528- BezierSegment s = new BezierSegment();
529- if (isRelative)
530- {
531- s.Point1 = lastPoint + (Vector)c.CtrlPoint1;
532-
533- if (c.Command == 's')
534- {
535- // first control point is a mirrored point of last end control point
536- //s.Point1 = lastPoint + new Vector(lastc.Point.X - dx, lastc.Point.Y - dy);
537- //s.Point1 = new Point(lastctrlpoint.X+2, lastctrlpoint.Y+2);
538-
539- double dx = lastc.CtrlPoint2.X - lastc.Point.X;
540- double dy = lastc.CtrlPoint2.Y - lastc.Point.Y;
541- s.Point1 = new Point(lastcirPoint.X - dx, lastcirPoint.Y - dy);
542- //s.Point1 = lastctrlpoint;
543- }
544-
545- s.Point2 = lastPoint + (Vector)c.CtrlPoint2;
546- s.Point3 = lastPoint + (Vector)c.Point;
547- }
548- else
549- {
550- if (c.Command == 's')
551- {
552- // first control point is a mirrored point of last end control point
553- //s.Point1 = lastPoint + new Vector(lastc.Point.X - dx, lastc.Point.Y - dy);
554- //s.Point1 = new Point(lastctrlpoint.X+2, lastctrlpoint.Y+2);
555-
556- double dx = lastc.CtrlPoint2.X - lastc.Point.X;
557- double dy = lastc.CtrlPoint2.Y - lastc.Point.Y;
558- s.Point1 = new Point(lastcirPoint.X - dx, lastcirPoint.Y - dy);
559- }
560- else s.Point1 = c.CtrlPoint1;
561- s.Point2 = c.CtrlPoint2;
562- s.Point3 = c.Point;
563- }
564- lastPoint = s.Point3;
565- p.Segments.Add(s);
566-
567- lastc = c;
568- lastcirPoint = s.Point3;
569-
570- //debugPoints.Add(new ControlLine(startPoint, s.Point1));
571- //debugPoints.Add(new ControlLine(s.Point3, s.Point2));
572- continue;
573- }
574- if (element is PathShape.QuadraticCurveTo)
575- {
576- PathShape.QuadraticCurveTo c = element as PathShape.QuadraticCurveTo;
577- Point startPoint = lastPoint;
578- QuadraticBezierSegment s = new QuadraticBezierSegment();
579- if (isRelative)
580- {
581- s.Point1 = lastPoint + (Vector)c.CtrlPoint1;
582-
583- if (c.Command == 'q' && lastq != null) // fix for horse svg! needed ?? or is it wrong in SVG?
584- {
585- // first control point is a mirrored point of last end control point
586- //s.Point1 = lastPoint + new Vector(lastc.Point.X - dx, lastc.Point.Y - dy);
587- //s.Point1 = new Point(lastctrlpoint.X+2, lastctrlpoint.Y+2);
588-
589- double dx = lastq.CtrlPoint1.X - lastq.Point.X;
590- double dy = lastq.CtrlPoint1.Y - lastq.Point.Y;
591- s.Point1 = new Point(lastcirPoint.X - dx, lastcirPoint.Y - dy);
592- //s.Point1 = lastctrlpoint;
593- }
594-
595- s.Point2 = lastPoint + (Vector)c.Point;
596- }
597- else
598- {
599- if (c.Command == 'q')
600- {
601- // first control point is a mirrored point of last end control point
602- //s.Point1 = lastPoint + new Vector(lastc.Point.X - dx, lastc.Point.Y - dy);
603- //s.Point1 = new Point(lastctrlpoint.X+2, lastctrlpoint.Y+2);
604-
605- double dx = lastq.CtrlPoint1.X - lastq.Point.X;
606- double dy = lastq.CtrlPoint1.Y - lastq.Point.Y;
607- s.Point1 = new Point(lastcirPoint.X - dx, lastcirPoint.Y - dy);
608- }
609- else s.Point1 = c.CtrlPoint1;
610- s.Point2 = c.Point;
611- }
612- lastPoint = s.Point2;
613- p.Segments.Add(s);
614-
615- lastq = c;
616- lastcirPoint = s.Point2;
617-
618- //debugPoints.Add(new ControlLine(startPoint, s.Point1));
619- //debugPoints.Add(new ControlLine(s.Point3, s.Point2));
620- continue;
621- }
622- if (element is PathShape.EllipticalArcTo)
623- {
624- PathShape.EllipticalArcTo c = element as PathShape.EllipticalArcTo;
625- ArcSegment s = new ArcSegment();
626- if (isRelative) s.Point = lastPoint + new Vector(c.X, c.Y);
627- else s.Point = new Point(c.X, c.Y);
628-
629- s.Size = new Size(c.RX, c.RY);
630- s.RotationAngle = c.AxisRotation;
631- s.SweepDirection = SweepDirection.Counterclockwise;
632- if (c.Clockwise) s.SweepDirection = SweepDirection.Clockwise;
633- s.IsLargeArc = c.LargeArc;
634- lastPoint = s.Point;
635- p.Segments.Add(s);
636- continue;
485+ var fill = new Fill ( svg ) ;
486+ fill . PaintServerKey = this . SVG . PaintServers . Parse ( "black" ) ;
487+ r . Fill = fill ;
637488 }
638489 }
639- */
640- /*
641- if (r.Transform != null)
642- path.Transform = r.Transform;
643- */
490+ PathGeometry path = PathGeometry . CreateFromGeometry ( PathGeometry . Parse ( r . Data ) ) ;
644491 var di = this . NewDrawingItem ( shape , path ) ;
645492 AddDrawingToGroup ( grp , shape , di ) ;
646- //}
647493 }
648494 }
649495
0 commit comments