/// <summary> /// Outputs the border for this block in the specified rect with the border style /// </summary> /// <param name="bg">The background style</param> /// <param name="border">The border style</param> /// <param name="context">The current render context</param> /// <param name="rect">The rectangle that shoud be rendered as the border</param> protected virtual void OutputBorder(PDFBrush bg, PDFPenBorders border, PDFRenderContext context, PDFRect rect) { PDFGraphics g = context.Graphics; if (null != border.AllPen && border.AllSides > 0) { if (border.CornerRadius.HasValue && border.CornerRadius.Value != PDFUnit.Zero) { g.DrawRoundRectangle(border.AllPen, rect, border.AllSides, border.CornerRadius.Value); } else { g.DrawRectangle(border.AllPen, rect, border.AllSides); } } if (null != border.TopPen) { if (border.CornerRadius.HasValue && border.CornerRadius.Value != PDFUnit.Zero) { g.DrawRoundRectangle(border.TopPen, rect, Sides.Top, border.CornerRadius.Value); } else { g.DrawRectangle(border.TopPen, rect, Sides.Top); } } if (null != border.RightPen) { if (border.CornerRadius.HasValue && border.CornerRadius.Value != PDFUnit.Zero) { g.DrawRoundRectangle(border.RightPen, rect, Sides.Right, border.CornerRadius.Value); } else { g.DrawRectangle(border.RightPen, rect, Sides.Right); } } if (null != border.BottomPen) { if (border.CornerRadius.HasValue && border.CornerRadius.Value != PDFUnit.Zero) { g.DrawRoundRectangle(border.BottomPen, rect, Sides.Bottom, border.CornerRadius.Value); } else { g.DrawRectangle(border.BottomPen, rect, Sides.Bottom); } } if (null != border.LeftPen) { if (border.CornerRadius.HasValue && border.CornerRadius.Value != PDFUnit.Zero) { g.DrawRoundRectangle(border.LeftPen, rect, Sides.Left, border.CornerRadius.Value); } else { g.DrawRectangle(border.LeftPen, rect, Sides.Left); } } }
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); }