public void Parses_Implicit_Line_Command_After_Move(string pathData) { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse(pathData); var figure = pathGeometry.Figures[0]; var segment = figure.Segments[0]; Assert.IsType <LineSegment>(segment); var lineSegment = (LineSegment)segment; Assert.Equal(new Point(10, 10), lineSegment.Point); figure = pathGeometry.Figures[1]; segment = figure.Segments[0]; Assert.IsType <LineSegment>(segment); lineSegment = (LineSegment)segment; Assert.Equal(new Point(20, 20), lineSegment.Point); } }
public static string Transform(string path, double shiftX, double shiftY, double scaleX, double scaleY) { var writer = new PathWriter(new Point(shiftX, shiftY), new Point(scaleX, scaleY)); var parser = new PathMarkupParser(writer); parser.Parse(path); return(writer.GetPath()); }
public void Throws_InvalidDataException_On_None_Defined_Command(string pathData) { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { Assert.Throws<InvalidDataException>(() => parser.Parse(pathData)); } }
internal static string ParseGeometry(string pathString, IFormatProvider formatProvider) { var fillRule = FillRule.EvenOdd; var context = new GeneratedStreamGeometryContext(); var parser = new PathMarkupParser(context); parser.Parse(pathString, ref fillRule); return(context.Generated); }
public void Move_Line_RelativeVerticalLine() { StreamGeometry geometry = new StreamGeometry(); MockContext context = new MockContext(); PathMarkupParser target = new PathMarkupParser(geometry, context); target.Parse("M3,4 L5,6 v7"); Assert.AreEqual("M3,4 L5,6 L5,13 ", context.Trace); }
public void Move_Line_HorizontalLine() { StreamGeometry geometry = new StreamGeometry(); MockContext context = new MockContext(); PathMarkupParser target = new PathMarkupParser(geometry, context); target.Parse("M3,4 L5,6 H7"); Assert.AreEqual("M3,4 L5,6 L7,6 ", context.Trace); }
public void Move_RelativeLine_RelativeLine() { StreamGeometry geometry = new StreamGeometry(); MockContext context = new MockContext(); PathMarkupParser target = new PathMarkupParser(geometry, context); target.Parse("M3,4 l5,6 7,8"); Assert.AreEqual("M3,4 L8,10 L15,18 ", context.Trace); }
public void Parses_FillMode_Before_Move() { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse("F 1M0,0"); Assert.Equal(FillRule.NonZero, pathGeometry.FillRule); } }
public void Should_AlwaysEndFigure(string pathData) { var context = new Mock <IGeometryContext>(); using (var parser = new PathMarkupParser(context.Object)) { parser.Parse(pathData); } context.Verify(v => v.EndFigure(It.IsAny <bool>()), Times.AtLeastOnce()); }
public void Should_Parse(string pathData) { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse(pathData); Assert.True(true); } }
public void Parses_Close() { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse("M0 0L10 10z"); var figure = pathGeometry.Figures[0]; Assert.True(figure.IsClosed); } }
public void Parses_Move() { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse("M10 10"); var figure = pathGeometry.Figures[0]; Assert.Equal(new Point(10, 10), figure.StartPoint); } }
public void Parse_Large_Path() { const string PathData = "F1 M 16.6309 18.6563C 17.1309 8.15625 29.8809 14.1563 29.8809 14.1563C 30.8809 11.1563 34.1308 11.4063" + " 34.1308 11.4063C 33.5 12 34.6309 13.1563 34.6309 13.1563C 32.1309 13.1562 31.1309 14.9062 31.1309 14.9" + "062C 41.1309 23.9062 32.6309 27.9063 32.6309 27.9062C 24.6309 24.9063 21.1309 22.1562 16.6309 18.6563 Z" + " M 16.6309 19.9063C 21.6309 24.1563 25.1309 26.1562 31.6309 28.6562C 31.6309 28.6562 26.3809 39.1562 18" + ".3809 36.1563C 18.3809 36.1563 18 38 16.3809 36.9063C 15 36 16.3809 34.9063 16.3809 34.9063C 16.3809 34" + ".9063 10.1309 30.9062 16.6309 19.9063 Z "; var streamGeometry = new StreamGeometry(); using (var context = streamGeometry.Open()) using (var parser = new PathMarkupParser(context)) { parser.Parse(PathData); } }
public void Parses_Scientific_Notation_Double() { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse("M -1.01725E-005 -1.01725e-005"); var figure = pathGeometry.Figures[0]; Assert.Equal( new Point( double.Parse("-1.01725E-005", NumberStyles.Float, CultureInfo.InvariantCulture), double.Parse("-1.01725E-005", NumberStyles.Float, CultureInfo.InvariantCulture)), figure.StartPoint); } }
public void Parses_Line() { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse("M0 0L10 10"); var figure = pathGeometry.Figures[0]; var segment = figure.Segments[0]; Assert.IsType<LineSegment>(segment); var lineSegment = (LineSegment)segment; Assert.Equal(new Point(10, 10), lineSegment.Point); } }
public void Should_Parse_Flags_Without_Separator() { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse("a.898.898 0 01.27.188"); var figure = pathGeometry.Figures[0]; var segments = figure.Segments; Assert.NotNull(segments); Assert.Equal(1, segments.Count); var arcSegment = segments[0]; Assert.IsType <ArcSegment>(arcSegment); } }
public void CloseFigure_Should_Move_CurrentPoint_To_CreateFigurePoint() { var pathGeometry = new PathGeometry(); using (var context = new PathGeometryContext(pathGeometry)) using (var parser = new PathMarkupParser(context)) { parser.Parse("M10,10L100,100Z m10,10"); Assert.Equal(2, pathGeometry.Figures.Count); var figure = pathGeometry.Figures[0]; Assert.Equal(new Point(10, 10), figure.StartPoint); Assert.Equal(true, figure.IsClosed); Assert.Equal(new Point(100, 100), ((LineSegment)figure.Segments[0]).Point); figure = pathGeometry.Figures[1]; Assert.Equal(new Point(20, 20), figure.StartPoint); } }