Browse Source

RoundedRectangle in Pdf

pull/14/head
peterforstmeier 15 years ago
parent
commit
20f5ec1954
  1. 10
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/Graphics/BaseRectangleItem.cs
  2. 4
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/BaseExportColumn.cs
  3. 2
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportText.cs
  4. 1
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/Graphics/Border.cs
  5. 22
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/Graphics/RectangleShape.cs

10
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/BaseItems/Graphics/BaseRectangleItem.cs

@ -48,16 +48,20 @@ namespace ICSharpCode.Reports.Core {
throw new ArgumentNullException("rpea"); throw new ArgumentNullException("rpea");
} }
base.Render(rpea); base.Render(rpea);
Rectangle rect = base.DisplayRectangle; Rectangle rectangle = base.DisplayRectangle;
StandardPrinter.FillBackground(rpea.PrintPageEventArgs.Graphics,this.BaseStyleDecorator); StandardPrinter.FillBackground(rpea.PrintPageEventArgs.Graphics,this.BaseStyleDecorator);
BaseLine line = new BaseLine(base.ForeColor,base.DashStyle,base.Thickness,LineCap.Round,LineCap.Round,DashCap.Round); BaseLine line = new BaseLine(base.ForeColor,base.DashStyle,base.Thickness,LineCap.Round,LineCap.Round,DashCap.Round);
using (Pen pen = line.CreatePen(line.Thickness)){ using (Pen pen = line.CreatePen(line.Thickness)){
if (pen != null) if (pen != null)
{ {
shape.CornerRadius = this.CornerRadius; shape.CornerRadius = this.CornerRadius;
GraphicsPath path1 = shape.CreatePath(rect);
rpea.PrintPageEventArgs.Graphics.DrawPath(pen, path1); GraphicsPath gfxPath = shape.CreatePath(rectangle);
rpea.PrintPageEventArgs.Graphics.FillPath(new SolidBrush(BackColor), gfxPath);;
rpea.PrintPageEventArgs.Graphics.DrawPath(pen, gfxPath);
} }
} }
} }

4
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/BaseExportColumn.cs

@ -80,11 +80,13 @@ namespace ICSharpCode.Reports.Core.Exporter
protected virtual void Decorate () protected virtual void Decorate ()
{ {
RectangleShape shape = new RectangleShape(); RectangleShape shape = new RectangleShape();
shape.DrawShape(this.pdfWriter.DirectContent, shape.DrawShape(this.pdfWriter.DirectContent,
null, null,
this.styleDecorator, this.styleDecorator,
ConvertToPdfRectangle()); ConvertToPdfRectangle());
this.DrawFrame(); this.DrawFrame();
} }
#endregion #endregion
@ -142,8 +144,6 @@ namespace ICSharpCode.Reports.Core.Exporter
} }
private void DrawFrame () private void DrawFrame ()
{ {
if (this.styleDecorator.DrawBorder) { if (this.styleDecorator.DrawBorder) {

2
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Exporter/ExportColumns/ExportText.cs

@ -59,6 +59,7 @@ namespace ICSharpCode.Reports.Core.Exporter {
} }
base.Decorate(); base.Decorate();
PdfContentByte contentByte = base.PdfWriter.DirectContent; PdfContentByte contentByte = base.PdfWriter.DirectContent;
CalculatePdfFormat pdfFormat = new CalculatePdfFormat(this.StyleDecorator,font); CalculatePdfFormat pdfFormat = new CalculatePdfFormat(this.StyleDecorator,font);
@ -75,6 +76,7 @@ namespace ICSharpCode.Reports.Core.Exporter {
} }
Chunk chunk = new Chunk(formatedText,font); Chunk chunk = new Chunk(formatedText,font);
columnText.AddText(chunk); columnText.AddText(chunk);
columnText.Go(); columnText.Go();

1
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/Graphics/Border.cs

@ -53,6 +53,7 @@ namespace ICSharpCode.Reports.Core {
} }
contentByte.SetColorStroke(style.PdfFrameColor); contentByte.SetColorStroke(style.PdfFrameColor);
contentByte.SetColorFill(style.PdfBackColor);
contentByte.SetLineWidth(UnitConverter.FromPixel(baseline.Thickness).Point); contentByte.SetLineWidth(UnitConverter.FromPixel(baseline.Thickness).Point);
contentByte.MoveTo(rectangle.Left ,rectangle.Top ); contentByte.MoveTo(rectangle.Left ,rectangle.Top );

22
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Printing/Graphics/RectangleShape.cs

@ -32,8 +32,6 @@ namespace ICSharpCode.Reports.Core {
public override GraphicsPath CreatePath(Rectangle rectangle ) public override GraphicsPath CreatePath(Rectangle rectangle )
{ {
//http://stackoverflow.com/questions/628261/how-to-draw-rounded-rectangle-with-variable-width-border-inside-of-specific-bound //http://stackoverflow.com/questions/628261/how-to-draw-rounded-rectangle-with-variable-width-border-inside-of-specific-bound
//http://www.switchonthecode.com/tutorials/csharp-creating-rounded-rectangles-using-a-graphics-path
//http://www.codeproject.com/KB/GDI-plus/ExtendedGraphics.aspx
GraphicsPath gfxPath = new GraphicsPath(); GraphicsPath gfxPath = new GraphicsPath();
if (CornerRadius == 0) if (CornerRadius == 0)
@ -42,12 +40,10 @@ namespace ICSharpCode.Reports.Core {
} }
else else
{ {
gfxPath.AddArc(rectangle.X, rectangle.Y,CornerRadius , CornerRadius, 180, 90); gfxPath.AddArc(rectangle.X, rectangle.Y,CornerRadius , CornerRadius, 180, 90);
gfxPath.AddArc(rectangle.X + rectangle.Width - CornerRadius, rectangle.Y, CornerRadius, CornerRadius, 270, 90); gfxPath.AddArc(rectangle.X + rectangle.Width - CornerRadius, rectangle.Y, CornerRadius, CornerRadius, 270, 90);
gfxPath.AddArc(rectangle.X + rectangle.Width - CornerRadius, rectangle.Y + rectangle.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90); gfxPath.AddArc(rectangle.X + rectangle.Width - CornerRadius, rectangle.Y + rectangle.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90);
gfxPath.AddArc(rectangle.X, rectangle.Y + rectangle.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90); gfxPath.AddArc(rectangle.X, rectangle.Y + rectangle.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90);
} }
gfxPath.CloseAllFigures(); gfxPath.CloseAllFigures();
return gfxPath; return gfxPath;
@ -75,6 +71,7 @@ namespace ICSharpCode.Reports.Core {
IBaseStyleDecorator style, IBaseStyleDecorator style,
iTextSharp.text.Rectangle rectangle) iTextSharp.text.Rectangle rectangle)
{ {
if (contentByte == null) { if (contentByte == null) {
throw new ArgumentNullException("contentByte"); throw new ArgumentNullException("contentByte");
} }
@ -85,16 +82,17 @@ namespace ICSharpCode.Reports.Core {
if (rectangle == null) { if (rectangle == null) {
throw new ArgumentNullException("rectangle"); throw new ArgumentNullException("rectangle");
} }
float t;
if (line == null) { if (line == null) {
t = 1; BaseShape.FillBackGround(contentByte,style,rectangle);
} else { }
t = line.Thickness; else
{
BaseShape.SetupShape(contentByte,style);
contentByte.SetLineWidth(UnitConverter.FromPixel(line.Thickness).Point);
contentByte.RoundRectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, rectangle.Height, CornerRadius);
BaseShape.FinishShape(contentByte);
} }
BaseShape.SetupShape(contentByte,style);
contentByte.SetLineWidth(UnitConverter.FromPixel(t).Point);
contentByte.RoundRectangle(rectangle.Left, rectangle.Bottom, rectangle.Width, rectangle.Height, CornerRadius);
BaseShape.FinishShape(contentByte);
} }

Loading…
Cancel
Save