From eb9b3b780fca5d76beda042482052cde15f3f366 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Sun, 29 Oct 2006 14:33:55 +0000 Subject: [PATCH] Different Types of Decorator's (Base,text and Graphic) git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1998 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/AddIns/Misc/SharpReport/SharpReport.sln | 2 +- .../SharpReportCore/BaseItems/BaseDataItem.cs | 6 +- .../BaseItems/BaseGraphicItem.cs | 7 +- .../SharpReportCore/BaseItems/BaseTextItem.cs | 12 ++- .../BaseItems/Graphics/BaseCircleItem.cs | 5 +- .../BaseItems/Graphics/BaseLineItem.cs | 4 +- .../BaseItems/Graphics/BaseRectangleItem.cs | 4 +- .../SharpReportCore/BaseItems/RowItem.cs | 2 +- .../Exporter/BaseStyleDecorator.cs | 79 +------------------ .../Decorators/GraphicStyleDecorator.cs | 48 +++++++++++ .../Exporter/Decorators/TextStyleDecorator.cs | 69 ++++++++++++++++ .../ExportColumns/BaseExportColumn.cs | 4 +- .../Exporter/ExportColumns/ExportGraphic.cs | 26 ++++-- .../Exporter/ExportColumns/ExportText.cs | 2 +- .../ExportColumns/IExportColumnBuilder .cs | 4 +- .../SharpReportCore/Exporter/PageBuilder.cs | 11 +-- .../Printing/Text/TextDrawer.cs | 2 +- .../ReportViewer/ReportViewer.cs | 4 +- .../SharpReportCore/SharpReportCore.csproj | 3 + 19 files changed, 175 insertions(+), 119 deletions(-) create mode 100644 src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/GraphicStyleDecorator.cs create mode 100644 src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/TextStyleDecorator.cs diff --git a/src/AddIns/Misc/SharpReport/SharpReport.sln b/src/AddIns/Misc/SharpReport/SharpReport.sln index 006999d60f..6f57599647 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport.sln +++ b/src/AddIns/Misc/SharpReport/SharpReport.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.1.0.1987 +# SharpDevelop 2.1.0.1997 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReportCore", "SharpReportCore\SharpReportCore.csproj", "{4B2239FF-8FD6-431D-9D22-1B8049BA6917}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReport", "SharpReport\SharpReport.csproj", "{F5563727-8309-4AC3-BACA-EB28EFD8A1D0}" diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs index 6a6757cf6d..d067e4fed2 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs @@ -65,11 +65,9 @@ namespace SharpReportCore { #endregion #region IExportColumnBuilder implementation -// public new IPerformLine CreateExportColumn(Graphics graphics) - public new BaseExportColumn CreateExportColumn(Graphics graphics) - { + public new BaseExportColumn CreateExportColumn(Graphics graphics){ string toPrint = CheckForNullValue(); - BaseStyleDecorator st = base.CreateItemStyle(graphics); + TextStyleDecorator st = base.CreateItemStyle(graphics); ExportText item = new ExportText(st,false); item.Text = base.FormatOutput(toPrint, this.FormatString, diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseGraphicItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseGraphicItem.cs index 5d4fbb4cd7..8d1d6d3020 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseGraphicItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseGraphicItem.cs @@ -31,13 +31,14 @@ namespace SharpReportCore { public BaseGraphicItem():base() { } - protected BaseStyleDecorator CreateItemStyle (BaseShape shape) { - BaseStyleDecorator style = new BaseStyleDecorator(); + protected GraphicStyleDecorator CreateItemStyle (BaseShape shape) { + GraphicStyleDecorator style = new GraphicStyleDecorator(shape); + style.Size = this.Size; style.Location = this.Location; style.BackColor = this.BackColor; style.ForeColor = this.ForeColor; - style.Shape = shape; + style.Thickness = this.thickness; style.DashStyle = this.dashStyle; return style; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs index be08c24336..957edbc251 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs @@ -49,16 +49,15 @@ namespace SharpReportCore { public BaseExportColumn CreateExportColumn(Graphics graphics){ - BaseStyleDecorator st = this.CreateItemStyle(graphics); + TextStyleDecorator st = this.CreateItemStyle(graphics); ExportText item = new ExportText(st,false); item.Text = this.text; return item; } - - - protected BaseStyleDecorator CreateItemStyle (Graphics g) { - BaseStyleDecorator style = new BaseStyleDecorator(); + + protected TextStyleDecorator CreateItemStyle (Graphics g) { + TextStyleDecorator style = new TextStyleDecorator(); SizeF measureSizeF = new SizeF (); measureSizeF = g.MeasureString(text, this.Font, @@ -76,10 +75,9 @@ namespace SharpReportCore { style.StringFormat = this.stringFormat; style.StringTrimming = this.stringTrimming; style.ContentAlignment = this.contentAlignment; - return style; } - + #endregion protected string FormatOutput(string valueToFormat,string format, diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs index cff20bb040..8ae62b4bc1 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs @@ -11,6 +11,7 @@ using System; using System.Drawing; using SharpReportCore.Exporters; + /// ///This class drwas a Circle /// @@ -31,9 +32,9 @@ namespace SharpReportCore { #region IExportColumnBuilder public BaseExportColumn CreateExportColumn(Graphics graphics){ - BaseStyleDecorator style = base.CreateItemStyle(this.shape); + GraphicStyleDecorator style = base.CreateItemStyle(this.shape); ExportGraphic item = new ExportGraphic(style,false); - return item; + return item as ExportGraphic; } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs index de028709c5..ddd54cfc38 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs @@ -36,9 +36,9 @@ namespace SharpReportCore { #region IExportColumnBuilder implementation public BaseExportColumn CreateExportColumn(Graphics graphics){ - BaseStyleDecorator style = base.CreateItemStyle(this.shape); + GraphicStyleDecorator style = base.CreateItemStyle(this.shape); ExportGraphic item = new ExportGraphic(style,false); - return item; + return item as ExportGraphic; } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs index b7fb57827f..cfc6cdcce3 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs @@ -34,9 +34,9 @@ namespace SharpReportCore { #region IExportColumnBuilder public BaseExportColumn CreateExportColumn(Graphics graphics){ - BaseStyleDecorator style = base.CreateItemStyle(this.shape); + GraphicStyleDecorator style = base.CreateItemStyle(this.shape); ExportGraphic item = new ExportGraphic(style,false); - return item; + return item as ExportGraphic; } #endregion diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs index ef627207d9..48637f0032 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs @@ -58,7 +58,7 @@ namespace SharpReportCore{ protected BaseStyleDecorator CreateItemStyle (Graphics g) { BaseStyleDecorator style = new BaseStyleDecorator(); - + style.BackColor = this.BackColor; style.ForeColor = this.ForeColor; style.Location = this.Location; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/BaseStyleDecorator.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/BaseStyleDecorator.cs index bcfffbff6f..d8fe8b4ddc 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/BaseStyleDecorator.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/BaseStyleDecorator.cs @@ -9,7 +9,7 @@ using System; using System.Drawing; - using System.Drawing.Drawing2D; +using System.Drawing.Drawing2D; namespace SharpReportCore.Exporters { /// @@ -22,15 +22,6 @@ namespace SharpReportCore.Exporters private Color foreColor; private Point location; private Size size; - private Font font; - - private StringFormat stringFormat; - private StringTrimming stringTrimming; - private ContentAlignment contentAlignment; - - private BaseShape shape; - private int thickness = 1; - private DashStyle dashStyle = DashStyle.Solid; public BaseStyleDecorator():this(Color.White,Color.Black){ } @@ -86,42 +77,8 @@ namespace SharpReportCore.Exporters } } - public Font Font { - get { - return font; - } - set { - font = value; - } - } - - public StringFormat StringFormat { - get { - return stringFormat; - } - set { - stringFormat = value; - } - } - - public StringTrimming StringTrimming { - get { - return stringTrimming; - } - set { - stringTrimming = value; - } - } - - public ContentAlignment ContentAlignment { - get { - return contentAlignment; - } - set { - contentAlignment = value; - } - } + public Rectangle DisplayRectangle { get { return new Rectangle(this.location.X,this.location.Y, @@ -129,36 +86,6 @@ namespace SharpReportCore.Exporters } } - public void DrawGraphic (Graphics graphics) { - if (graphics == null) { - throw new ArgumentNullException("graphics"); - } - - this.shape.DrawShape(graphics, - new BaseLine (this.foreColor,this.dashStyle,this.thickness), - this.DisplayRectangle); - } - - public BaseShape Shape { - get { return shape; } - set { shape = value; } - } - public int Thickness { - get { return thickness; } - set { thickness = value; } - } - - public DashStyle DashStyle { - get { return dashStyle; } - set { dashStyle = value; } - } - - } - - public class TextDecorator :BaseStyleDecorator - { - TextDecorator () :base() { - - } } + } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/GraphicStyleDecorator.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/GraphicStyleDecorator.cs new file mode 100644 index 0000000000..e31d8ff470 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/GraphicStyleDecorator.cs @@ -0,0 +1,48 @@ +/* + * Erstellt mit SharpDevelop. + * Benutzer: Forstmeier Peter + * Datum: 29.10.2006 + * Zeit: 14:52 + * + * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern. + */ + +using System; +using System.Drawing; +using System.Drawing.Drawing2D; +namespace SharpReportCore.Exporters +{ + /// + /// Description of GraphicStyleDecorator. + /// + public class GraphicStyleDecorator:BaseStyleDecorator + { + private BaseShape shape; + private int thickness = 1; + private DashStyle dashStyle = DashStyle.Solid; + + public GraphicStyleDecorator(BaseShape shape):base(){ + if (shape == null) { + throw new ArgumentNullException("shape"); + } + this.shape = shape; + } + + + public BaseShape Shape { + get { return shape; } + set { shape = value; } + } + public int Thickness { + get { return thickness; } + set { thickness = value; } + } + + public DashStyle DashStyle { + get { return dashStyle; } + set { dashStyle = value; } + } + + + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/TextStyleDecorator.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/TextStyleDecorator.cs new file mode 100644 index 0000000000..ac33847b02 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/TextStyleDecorator.cs @@ -0,0 +1,69 @@ +/* + * Erstellt mit SharpDevelop. + * Benutzer: Forstmeier Peter + * Datum: 29.10.2006 + * Zeit: 14:27 + * + * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern. + */ + +using System; +using System.Drawing; + +namespace SharpReportCore.Exporters +{ + /// + /// Description of TextStyleDecorator. + /// + public class TextStyleDecorator:BaseStyleDecorator + { + private Font font; + + private StringFormat stringFormat; + private StringTrimming stringTrimming; + private ContentAlignment contentAlignment; + + public TextStyleDecorator():base() + { + } + + + + public Font Font { + get { + return font; + } + set { + font = value; + } + } + + + public StringFormat StringFormat { + get { + return stringFormat; + } + set { + stringFormat = value; + } + } + + public StringTrimming StringTrimming { + get { + return stringTrimming; + } + set { + stringTrimming = value; + } + } + + public ContentAlignment ContentAlignment { + get { + return contentAlignment; + } + set { + contentAlignment = value; + } + } + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/BaseExportColumn.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/BaseExportColumn.cs index 5f45300ffc..c3e3e15040 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/BaseExportColumn.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/BaseExportColumn.cs @@ -15,8 +15,8 @@ namespace SharpReportCore.Exporters /// /// Description of BaseLineItem. /// - public class BaseExportColumn :IPerformLine - { + public class BaseExportColumn{ + BaseStyleDecorator styleDecorator; bool isContainer; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportGraphic.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportGraphic.cs index f78a93bb8b..d2324bb58d 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportGraphic.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportGraphic.cs @@ -8,13 +8,14 @@ */ using System; +using System.Drawing; namespace SharpReportCore.Exporters { /// /// Description of ExportGraphic. /// - public class ExportGraphic:BaseExportColumn,IPerformLine + public class ExportGraphic:BaseExportColumn { public ExportGraphic():base() { @@ -22,15 +23,24 @@ namespace SharpReportCore.Exporters public ExportGraphic (BaseStyleDecorator itemStyle,bool isContainer):base(itemStyle,isContainer){ } - - public override BaseStyleDecorator StyleDecorator { - get { - return base.StyleDecorator; - } - set { - base.StyleDecorator = value; + public void DrawGraphic (Graphics graphics) { + if (graphics == null) { + throw new ArgumentNullException("graphics"); } + GraphicStyleDecorator style = (GraphicStyleDecorator) base.StyleDecorator; + style.Shape.DrawShape(graphics, + new BaseLine (style.ForeColor,style.DashStyle,style.Thickness), + style.DisplayRectangle); } +// public override BaseStyleDecorator StyleDecorator { +// get { +// return base.StyleDecorator as GraphicStyleDecorator; +// } +// set { +// base.StyleDecorator = value; +// } +// } + } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportText.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportText.cs index a2430cb4e5..20a63aacbe 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportText.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportText.cs @@ -13,7 +13,7 @@ namespace SharpReportCore.Exporters { /// /// Description of LineItem. /// - public class ExportText :BaseExportColumn,IPerformLine{ + public class ExportText :BaseExportColumn{ string text; public ExportText():base(){ diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/IExportColumnBuilder .cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/IExportColumnBuilder .cs index e978b41d0b..f3c96c7743 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/IExportColumnBuilder .cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/IExportColumnBuilder .cs @@ -19,11 +19,11 @@ namespace SharpReportCore public interface IExportColumnBuilder{ BaseExportColumn CreateExportColumn (Graphics graphics); } - + /* public interface IPerformLine{ BaseStyleDecorator StyleDecorator { get;set; } } - + */ } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/PageBuilder.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/PageBuilder.cs index a7d567cbd4..64ffd1ca92 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/PageBuilder.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/PageBuilder.cs @@ -206,15 +206,16 @@ namespace SharpReportCore.Exporters BaseSection section = this.reportModel.PageFooter; this.DoConvert (this.reportModel.PageFooter,this.singlePage.SectionBounds.PageFooterRectangle.Top); } - - private void display (IPerformLine li) { + /* + private void display (BaseStyleDecorator li) { +// private void display (IPerformLine li) { // System.Console.WriteLine("\tdisplay {0}",li.ToString()); - ExportText l = li as ExportText; - if (l != null) { +// ExportText l = li as ExportText; + if (li != null) { System.Console.WriteLine("\t\t{0} / {1} ",l.StyleDecorator.Location,l.Text); } } - + */ private void Write () { this.dataNavigator = this.dataManager.GetNavigator; Graphics graphics = reportModel.ReportSettings.PageSettings.PrinterSettings.CreateMeasurementGraphics(); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs index fd52cf5a4b..8c7eb44154 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs @@ -68,7 +68,7 @@ namespace SharpReportCore { } public static void PaintString (Graphics graphics,string text, - SharpReportCore.Exporters.BaseStyleDecorator decorator) { + SharpReportCore.Exporters.TextStyleDecorator decorator) { // d.DrawString(gr, // ex.ToString(), diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportViewer/ReportViewer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportViewer/ReportViewer.cs index 5c04ad3169..f96a6dbc0c 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportViewer/ReportViewer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportViewer/ReportViewer.cs @@ -91,10 +91,10 @@ namespace SharpReportCore.ReportViewer // System.Console.WriteLine("{0}",ex.GetType()); ExportGraphic eg = ex as ExportGraphic; if (eg != null) { - eg.StyleDecorator.DrawGraphic(gr); + eg.DrawGraphic(gr); } else { - TextDrawer.PaintString(gr,ex.ToString(),ex.StyleDecorator); + TextDrawer.PaintString(gr,ex.ToString(),(TextStyleDecorator)ex.StyleDecorator); } } else { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj index 8e5cbe588d..445a4f8fdc 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj @@ -155,6 +155,8 @@ + + @@ -185,6 +187,7 @@ + \ No newline at end of file