From 51e498de074854575df5631194b2d0a3164c77e8 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier <peter.forstmeier@t-online.de> Date: Sat, 25 Jan 2014 18:29:36 +0100 Subject: [PATCH] Wpf - Circle --- .../ICSharpCode.Reporting.csproj | 2 + .../Src/Exporter/Visitors/AbstractVisitor.cs | 6 +++ .../Src/Exporter/Visitors/IVisitor.cs | 1 + .../Src/Items/Graphics/BaseCircleItem.cs | 31 +++++++++++++++ .../PageBuilder/ExportColumns/ExportCircle.cs | 38 +++++++++++++++++++ .../Src/Pdf/PdfVisitor.cs | 2 + .../Src/Wpf/Visitor/WpfVisitor.cs | 36 ++++++++++++++---- 7 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseCircleItem.cs create mode 100644 src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportCircle.cs diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj index 3da4a9973f..330bda352c 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj @@ -144,6 +144,7 @@ <Compile Include="Src\Globals\GlobalValues.cs" /> <Compile Include="Src\Interfaces\IReportModel.cs" /> <Compile Include="Src\Items\BaseTextItem.cs" /> + <Compile Include="Src\Items\Graphics\BaseCircleItem.cs" /> <Compile Include="Src\Items\Graphics\BaseGraphics.cs" /> <Compile Include="Src\Items\Graphics\BaseLineItem.cs" /> <Compile Include="Src\Items\Graphics\BaseRectangleItem.cs" /> @@ -157,6 +158,7 @@ <Compile Include="Src\PageBuilder\Converter\ContainerConverter.cs" /> <Compile Include="Src\PageBuilder\Converter\IContainerConverter.cs" /> <Compile Include="Src\PageBuilder\DataPageBuilder.cs" /> + <Compile Include="Src\PageBuilder\ExportColumns\ExportCircle.cs" /> <Compile Include="Src\PageBuilder\ExportColumns\ExportColumn.cs" /> <Compile Include="Src\PageBuilder\ExportColumns\ExportContainer.cs" /> <Compile Include="Src\PageBuilder\ExportColumns\ExportLine.cs" /> 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 0e29974a1b..6874b2cd20 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 @@ -61,6 +61,12 @@ namespace ICSharpCode.Reporting.Exporter.Visitors } + + public virtual void Visit (ExportCircle exportCircle) { + + } + + protected bool ShouldSetBackcolor (ExportColumn exportColumn) { return exportColumn.BackColor != Color.White; } 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 e84203f356..c5c3ac06b4 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 @@ -18,5 +18,6 @@ namespace ICSharpCode.Reporting.Exporter.Visitors void Visit(ExportText exportColumn); void Visit(ExportLine exportGraphics); void Visit (ExportRectangle exportRectangle); + void Visit (ExportCircle exportCircle); } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseCircleItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseCircleItem.cs new file mode 100644 index 0000000000..01de8ba18c --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseCircleItem.cs @@ -0,0 +1,31 @@ +// 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 +{ + /// <summary> + /// Description of BaseCircleItem. + /// </summary> + public class BaseCircleItem:BaseGraphics + { + public BaseCircleItem() + { + } + + public override IExportColumn CreateExportColumn() + { + var ex = new ExportCircle(); + 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/ExportCircle.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportCircle.cs new file mode 100644 index 0000000000..7e4194e46a --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportCircle.cs @@ -0,0 +1,38 @@ +// 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; + +namespace ICSharpCode.Reporting.PageBuilder.ExportColumns +{ + /// <summary> + /// Description of ExportCircle. + /// </summary> + public class ExportCircle:ExportColumn,IExportGraphics,IAcceptor + { + public ExportCircle() + { + } + + + 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;} + + public LineCap StartLineCap {get;set;} + + public LineCap EndLineCap {get;set;} + } +} 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 9ea0d39867..39cac815a5 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Pdf/PdfVisitor.cs @@ -85,6 +85,8 @@ namespace ICSharpCode.Reporting.Pdf gfx.DrawRectangle(pen,new XRect(columnLocation.ToXPoints(), exportRectangle.Size.ToXSize())); } + + public PdfPage PdfPage {get; private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs index 3443a7b382..b7c4de2e0a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs @@ -82,8 +82,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor { var pen = FixedDocumentCreator.CreateWpfPen(exportGraphics); var visual = new DrawingVisual(); - using (var dc = visual.RenderOpen()) - { + using (var dc = visual.RenderOpen()){ dc.DrawLine(pen, new Point(exportGraphics.Location.X, exportGraphics.Location.Y), new Point(exportGraphics.Location.X + exportGraphics.Size.Width,exportGraphics.Location.Y)); @@ -98,17 +97,40 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor var pen = FixedDocumentCreator.CreateWpfPen(exportRectangle); var visual = new DrawingVisual(); - using (var dc = visual.RenderOpen()) - {dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportRectangle.BackColor), - pen, - new Rect(exportRectangle.Location.X,exportRectangle.Location.Y, - exportRectangle.Size.Width,exportRectangle.Size.Height)); + using (var dc = visual.RenderOpen()){ + dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportRectangle.BackColor), + pen, + new Rect(exportRectangle.Location.X,exportRectangle.Location.Y, + exportRectangle.Size.Width,exportRectangle.Size.Height)); } DrawingElement m = new DrawingElement(visual); UIElement = m; } + public override void Visit(ExportCircle exportCircle) + { + var pen = FixedDocumentCreator.CreateWpfPen(exportCircle); + var rad = CalcRad(exportCircle.Size); + + var visual = new DrawingVisual(); + using (var dc = visual.RenderOpen()){ + + dc.DrawEllipse(FixedDocumentCreator.ConvertBrush(exportCircle.BackColor), + pen, + new Point(exportCircle.Location.X + rad.X, + exportCircle.Location.Y + rad.Y), + rad.X, + rad.Y); + + + } + DrawingElement m = new DrawingElement(visual); + UIElement = m; + } + Point CalcRad(System.Drawing.Size size) { + return new Point(size.Width /2,size.Height /2); + } protected UIElement UIElement {get;private set;}