public void CubicForWithHandleEnd_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            PDFPoint pos = new PDFPoint(10, 10);

            target.MoveTo(pos);
            Assert.AreEqual(target.Cursor, pos);

            PDFPoint end         = new PDFPoint(100, 100);
            PDFPoint handleStart = new PDFPoint(0, 50);
            PDFPoint handleEnd   = new PDFPoint(50, 100);

            target.CubicCurveForWithHandleEnd(end, handleEnd);

            end         = end.Offset(pos);
            handleEnd   = handleEnd.Offset(pos);
            handleStart = handleStart.Offset(pos);

            Assert.AreEqual(target.Cursor, end);
            Assert.AreEqual(target.Paths[0].Operations.Count, 2);
            Assert.IsInstanceOfType(target.Paths[0].Operations[1], typeof(PathBezierCurveData));

            PathBezierCurveData data = (PathBezierCurveData)target.Paths[0].Operations[1];

            Assert.AreEqual(data.Points.Length, 3);
            Assert.IsFalse(data.HasStartHandle);
            Assert.IsTrue(data.HasEndHandle);
            Assert.AreEqual(data.EndPoint, end);
            Assert.AreEqual(data.StartHandle, PDFPoint.Empty);
            Assert.AreEqual(data.EndHandle, handleEnd);
        }
        public void Bounds_Test()
        {
            PDFGraphicsPath target = new PDFGraphicsPath();

            Assert.IsTrue(target.Paths.Count == 1);
            Assert.IsTrue(target.HasCurrentPath);

            PDFPoint pos = new PDFPoint(10, 10);

            target.MoveTo(pos);

            PDFPoint end         = new PDFPoint(100, 100);
            PDFPoint handleStart = new PDFPoint(0, 50);
            PDFPoint handleEnd   = new PDFPoint(50, 100);

            target.CubicCurveForWithHandleEnd(end, handleEnd);

            end         = end.Offset(pos);
            handleEnd   = handleEnd.Offset(pos);
            handleStart = handleStart.Offset(pos);

            PDFRect bounds = target.Bounds;

            Assert.AreEqual(bounds.X, PDFUnit.Zero);
            Assert.AreEqual(bounds.Y, PDFUnit.Zero);
            Assert.AreEqual(bounds.Width, end.X);
            Assert.AreEqual(bounds.Height, end.Y);
        }
        protected override PDFObjectRef DoOutputToPDF(PDFRenderContext context, PDFWriter writer)
        {
            PDFSize  prevSize  = context.Space;
            PDFPoint prevLoc   = context.Offset;
            Style    laststyle = context.FullStyle;

            PDFObjectRef oref;

            if (this.Owner is IPDFRenderComponent)
            {
                PDFPoint loc = context.Offset;
                loc = loc.Offset(this.TotalBounds.Location);
                PDFSize            size = this.TotalBounds.Size;
                PDFPositionOptions opts = this.PositionOptions;

                context.Offset = loc;
                context.Space  = size;

                if (opts.Margins.IsEmpty == false)
                {
                    loc  = loc.Offset(opts.Margins.Left, opts.Margins.Top);
                    size = size.Subtract(opts.Margins);
                }

                PDFPenBorders border = this.FullStyle.CreateBorderPen();


                PDFBrush background = this.FullStyle.CreateBackgroundBrush();

                PDFRect borderRect = new PDFRect(loc, size);
                if (null != background)
                {
                    this.OutputBackground(background, border.HasBorders? border.CornerRadius : null, context, borderRect);
                }


                if (opts.Padding.IsEmpty == false)
                {
                    loc  = loc.Offset(opts.Padding.Left, opts.Padding.Top);
                    size = size.Subtract(opts.Padding);
                }

                //Set the offset, size and full style on the context
                context.Offset    = loc;
                context.Space     = size;
                context.FullStyle = this.FullStyle;
                if (context.ShouldLogDebug)
                {
                    context.TraceLog.Begin(TraceLevel.Verbose, "Layout Item", "Beginning the rendering the referenced component " + this.Owner + " with context offset of " + context.Offset + " and space " + context.Space);
                }
                else if (context.ShouldLogVerbose)
                {
                    context.TraceLog.Add(TraceLevel.Verbose, "Layout Item", "Rendering the referenced component " + this.Owner + " with context offset of " + context.Offset + " and space " + context.Space);
                }
                //Then make the component render itself
                oref = (this.Owner as IPDFRenderComponent).OutputToPDF(context, writer);

                Component owner = this.Owner as Component;
                if (null != owner)
                {
                    owner.SetArrangement(context, context.FullStyle, borderRect);
                }

                //finally if we have a border then write this
                if (null != border)
                {
                    this.OutputBorder(background, border, context, borderRect);
                }

                if (context.ShouldLogDebug)
                {
                    context.TraceLog.End(TraceLevel.Verbose, "Layout Item", "Completed the rendering the referenced component " + this.Owner + " and arrangement set to border rect " + borderRect);
                }
            }
            else
            {
                oref = base.DoOutputToPDF(context, writer);
            }

            context.Space     = prevSize;
            context.Offset    = prevLoc;
            context.FullStyle = laststyle;

            return(oref);
        }