private void ParseSVGMoveCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args) { int index = 0; PDFUnit x, y; while (index < args.Length) { //must be at least an x and y, but can optionally be more x and y's if (index == 0 || !string.IsNullOrEmpty(args[index])) { if (AssertParseUnit(args, ref index, cmd, out x) && AssertParseUnit(args, ref index, cmd, out y)) { if (absolute) { path.MoveTo(new PDFPoint(x, y)); } else { path.MoveBy(new PDFPoint(x, y)); } } } else if (string.IsNullOrEmpty(args[index])) { index++; } } }
public void MoveBy_Test() { PDFGraphicsPath target = new PDFGraphicsPath(); Assert.IsTrue(target.Paths.Count == 1); Assert.IsTrue(target.HasCurrentPath); Assert.AreEqual(target.Cursor, PDFPoint.Empty); PDFPoint pos = new PDFPoint(10, 10); target.MoveTo(pos); Assert.AreEqual(target.Cursor, pos); Assert.AreEqual(target.Paths[0].Operations.Count, 1); Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathMoveData)); PathMoveData data = (PathMoveData)target.Paths[0].Operations[0]; Assert.AreEqual(data.MoveTo, pos); PDFPoint pos2 = new PDFPoint(40, 40); target.MoveBy(pos2); PDFPoint total = new PDFPoint(pos.X + pos2.X, pos.Y + pos2.Y); Assert.AreEqual(target.Cursor, total); Assert.AreEqual(target.Paths[0].Operations.Count, 2); Assert.IsInstanceOfType(target.Paths[0].Operations[1], typeof(PathMoveData)); data = (PathMoveData)target.Paths[0].Operations[1]; Assert.AreEqual(data.MoveTo, total); }