From 6a8ef28a8989438dbd48e9e221985d338ca040af Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Sun, 12 Jan 2014 18:57:39 +0100 Subject: [PATCH] Start implementing Graphic Objects (Line,Rectangle) --- .../ICSharpCode.Reporting.csproj | 4 ++ .../Src/Exporter/Visitors/AbstractVisitor.cs | 8 ++++ .../Src/Exporter/Visitors/DebugVisitor.cs | 6 +++ .../Exporter/Visitors/ExpressionVisitor.cs | 4 ++ .../Src/Exporter/Visitors/IVisitor.cs | 1 + .../Src/Exporter/Visitors/WpfVisitor.cs | 5 +++ .../Src/Items/Graphics/BaseGraphics.cs | 24 +++++++++++ .../Src/Items/Graphics/BaseLineItem.cs | 30 +++++++++++++ .../ExportColumns/ExportGraphics.cs | 43 +++++++++++++++++++ .../Src/Pdf/PdfHelper.cs | 5 +++ .../Src/Pdf/PdfVisitor.cs | 10 +++++ 11 files changed, 140 insertions(+) create mode 100644 src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseGraphics.cs create mode 100644 src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseLineItem.cs create mode 100644 src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportGraphics.cs diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj index 54a2e871b9..b5fc2b5b98 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj @@ -149,6 +149,8 @@ + + @@ -161,6 +163,7 @@ + @@ -199,6 +202,7 @@ + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs index 3ea6a95c23..3d70185399 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs @@ -54,11 +54,19 @@ namespace ICSharpCode.Reporting.Exporter.Visitors } + public virtual void Visit(ExportGraphics exportGraphics) + { + throw new NotImplementedException(); + } + + protected bool ShouldSetBackcolor (ExportColumn exportColumn) { return exportColumn.BackColor != Color.White; } protected Collection Pages {get; private set;} + + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs index 40b00a7729..6ba34260be 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs @@ -35,5 +35,11 @@ namespace ICSharpCode.Reporting.Exporter.Visitors public override void Visit(ExportText exportColumn) { } + + public override void Visit(ExportGraphics exportGraphics) + { +// base.Visit(exportGraphics); + Console.WriteLine("Line from {0} size {1}",exportGraphics.Location,exportGraphics.Size.Width); + } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs index b9741244f6..d3054f51a0 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs @@ -57,6 +57,10 @@ namespace ICSharpCode.Reporting.Exporter.Visitors } } + public override void Visit(ExportGraphics exportGraphics) + { +// base.Visit(exportGraphics); + } object Evaluate(ExportText exportColumn) { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs index c07f962f01..cc0dc46ef8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs @@ -16,5 +16,6 @@ namespace ICSharpCode.Reporting.Exporter.Visitors void Visit(ExportPage page); void Visit(ExportContainer exportColumn); void Visit(ExportText exportColumn); + void Visit(ExportGraphics exportGraphics); } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/WpfVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/WpfVisitor.cs index 89c60504df..c911e39546 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/WpfVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/WpfVisitor.cs @@ -81,6 +81,11 @@ namespace ICSharpCode.Reporting.Exporter.Visitors } + public override void Visit(ExportGraphics exportGraphics) + { +// base.Visit(exportGraphics); + } + protected UIElement UIElement {get;private set;} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseGraphics.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseGraphics.cs new file mode 100644 index 0000000000..a8086ec493 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseGraphics.cs @@ -0,0 +1,24 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System; +using System.Drawing.Drawing2D; + +namespace ICSharpCode.Reporting.Items +{ + /// + /// Description of BaseGraphics. + /// + public class BaseGraphics:PrintableItem + { + public BaseGraphics() + { + this.Thickness = 1; + DashStyle = DashStyle.Solid; + } + + + public virtual int Thickness {get;set;} + + public virtual DashStyle DashStyle {get;set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseLineItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseLineItem.cs new file mode 100644 index 0000000000..08a3884549 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseLineItem.cs @@ -0,0 +1,30 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; + +namespace ICSharpCode.Reporting.Items{ + /// + /// Description of BaseLineItem. + /// + public class BaseLineItem:BaseGraphics + { + public BaseLineItem() + { + } + + public override IExportColumn CreateExportColumn() + { + var ex = new ExportGraphics(); + ex.Location = Location; + ex.ForeColor = ForeColor; + ex.BackColor = BackColor; + ex.Size = Size; + ex.DesiredSize = Size; + ex.Thickness = Thickness; + ex.DashStyle = DashStyle; + return ex; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportGraphics.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportGraphics.cs new file mode 100644 index 0000000000..10f4495bb8 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportGraphics.cs @@ -0,0 +1,43 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) +using System; +using System.Drawing.Drawing2D; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces.Export; + +namespace ICSharpCode.Reporting.PageBuilder.ExportColumns +{ + /// + /// Description of ExportGraphics. + /// + /// + public interface IExportGraphics:IExportColumn { + int Thickness {get;set;} + DashStyle DashStyle {get;set;} + } + + + public class ExportGraphics:ExportColumn,IExportGraphics,IAcceptor + { + public ExportGraphics() + { + } + + + public void Accept(IVisitor visitor) + { + visitor.Visit(this); + } + + + public override ICSharpCode.Reporting.Arrange.IMeasurementStrategy MeasurementStrategy() + { + throw new NotImplementedException(); + } + + public int Thickness {get;set;} + + public DashStyle DashStyle {get;set;} + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfHelper.cs index 7857512c13..c988926ff8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfHelper.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfHelper.cs @@ -54,6 +54,11 @@ namespace ICSharpCode.Reporting.Pdf } + public static XPen PdfPen(IExportGraphics column) { + return new XPen(ToXColor(column.ForeColor),column.Thickness); + } + + public static Point LocationRelToParent (ExportColumn column) { return new Point(column.Parent.Location.X + column.Location.X, column.Parent.Location.Y + column.Location.Y); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs index 1ca792bb57..c8b9a5f457 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs @@ -65,6 +65,16 @@ namespace ICSharpCode.Reporting.Pdf } + + public override void Visit(ExportGraphics exportGraphics) + { + var columnLocation = containerLocation; + columnLocation.Offset(exportGraphics.Location); + var p = PdfHelper.PdfPen(exportGraphics); + gfx.DrawLine(p,columnLocation.ToXPoints(),new Point(exportGraphics.Size.Width,columnLocation.Y).ToXPoints()); + } + + public PdfPage PdfPage {get; private set;} } }