private void ParseSVGLineCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args) { PDFUnit x, y; int index = 0; 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)) { return; } if (!AssertParseUnit(args, ref index, cmd, out y)) { return; } if (absolute) { path.LineTo(new PDFPoint(x, y)); } else { path.LineFor(new PDFPoint(x, y)); } } else if (string.IsNullOrEmpty(args[index])) { index++; } } }
public void LineFor_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.LineTo(pos); Assert.AreEqual(target.Cursor, pos); Assert.AreEqual(target.Paths[0].Operations.Count, 1); Assert.IsInstanceOfType(target.Paths[0].Operations[0], typeof(PathLineData)); PathLineData data = (PathLineData)target.Paths[0].Operations[0]; Assert.AreEqual(data.LineTo, pos); PDFPoint pos2 = new PDFPoint(40, 40); target.LineFor(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(PathLineData)); data = (PathLineData)target.Paths[0].Operations[1]; Assert.AreEqual(data.LineTo, total); }