コード例 #1
0
        private void ParseSVGHorizontalCommand(PDFGraphicsPath path, char cmd, bool absolute, string[] args)
        {
            PDFUnit h;
            int     index = 0;


            while (index < args.Length)
            {
                //must be at least one, but can optionally be more
                if (index == 0 || !string.IsNullOrEmpty(args[index]))
                {
                    if (AssertParseUnit(args, ref index, cmd, out h))
                    {
                        if (absolute)
                        {
                            path.HorizontalLineTo(h);
                        }
                        else
                        {
                            path.HorizontalLineFor(h);
                        }
                    }
                }
                else if (string.IsNullOrEmpty(args[index]))
                {
                    index++;
                }
            }
        }
コード例 #2
0
        public void HorizontalLineFor_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);

            PDFUnit h = 40;

            target.HorizontalLineFor(h);

            pos = new PDFPoint(pos.X + h, pos.Y);
            Assert.AreEqual(target.Cursor, pos);
            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, pos);
        }