Browse Source

Different Types of Decorator's (Base,text and Graphic)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1998 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
eb9b3b780f
  1. 2
      src/AddIns/Misc/SharpReport/SharpReport.sln
  2. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs
  3. 7
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseGraphicItem.cs
  4. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs
  5. 5
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs
  6. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs
  7. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs
  8. 75
      src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/BaseStyleDecorator.cs
  9. 48
      src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/GraphicStyleDecorator.cs
  10. 69
      src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/Decorators/TextStyleDecorator.cs
  11. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/BaseExportColumn.cs
  12. 26
      src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportGraphic.cs
  13. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportText.cs
  14. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/IExportColumnBuilder .cs
  15. 11
      src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/PageBuilder.cs
  16. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs
  17. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/ReportViewer/ReportViewer.cs
  18. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj

2
src/AddIns/Misc/SharpReport/SharpReport.sln

@ -1,6 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 9.00 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}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReportCore", "SharpReportCore\SharpReportCore.csproj", "{4B2239FF-8FD6-431D-9D22-1B8049BA6917}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReport", "SharpReport\SharpReport.csproj", "{F5563727-8309-4AC3-BACA-EB28EFD8A1D0}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReport", "SharpReport\SharpReport.csproj", "{F5563727-8309-4AC3-BACA-EB28EFD8A1D0}"

6
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs

@ -65,11 +65,9 @@ namespace SharpReportCore {
#endregion #endregion
#region IExportColumnBuilder implementation #region IExportColumnBuilder implementation
// public new IPerformLine CreateExportColumn(Graphics graphics) public new BaseExportColumn CreateExportColumn(Graphics graphics){
public new BaseExportColumn CreateExportColumn(Graphics graphics)
{
string toPrint = CheckForNullValue(); string toPrint = CheckForNullValue();
BaseStyleDecorator st = base.CreateItemStyle(graphics); TextStyleDecorator st = base.CreateItemStyle(graphics);
ExportText item = new ExportText(st,false); ExportText item = new ExportText(st,false);
item.Text = base.FormatOutput(toPrint, item.Text = base.FormatOutput(toPrint,
this.FormatString, this.FormatString,

7
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseGraphicItem.cs

@ -31,13 +31,14 @@ namespace SharpReportCore {
public BaseGraphicItem():base() { public BaseGraphicItem():base() {
} }
protected BaseStyleDecorator CreateItemStyle (BaseShape shape) { protected GraphicStyleDecorator CreateItemStyle (BaseShape shape) {
BaseStyleDecorator style = new BaseStyleDecorator(); GraphicStyleDecorator style = new GraphicStyleDecorator(shape);
style.Size = this.Size; style.Size = this.Size;
style.Location = this.Location; style.Location = this.Location;
style.BackColor = this.BackColor; style.BackColor = this.BackColor;
style.ForeColor = this.ForeColor; style.ForeColor = this.ForeColor;
style.Shape = shape;
style.Thickness = this.thickness; style.Thickness = this.thickness;
style.DashStyle = this.dashStyle; style.DashStyle = this.dashStyle;
return style; return style;

8
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs

@ -49,16 +49,15 @@ namespace SharpReportCore {
public BaseExportColumn CreateExportColumn(Graphics graphics){ public BaseExportColumn CreateExportColumn(Graphics graphics){
BaseStyleDecorator st = this.CreateItemStyle(graphics); TextStyleDecorator st = this.CreateItemStyle(graphics);
ExportText item = new ExportText(st,false); ExportText item = new ExportText(st,false);
item.Text = this.text; item.Text = this.text;
return item; return item;
} }
protected TextStyleDecorator CreateItemStyle (Graphics g) {
protected BaseStyleDecorator CreateItemStyle (Graphics g) { TextStyleDecorator style = new TextStyleDecorator();
BaseStyleDecorator style = new BaseStyleDecorator();
SizeF measureSizeF = new SizeF (); SizeF measureSizeF = new SizeF ();
measureSizeF = g.MeasureString(text, measureSizeF = g.MeasureString(text,
this.Font, this.Font,
@ -76,7 +75,6 @@ namespace SharpReportCore {
style.StringFormat = this.stringFormat; style.StringFormat = this.stringFormat;
style.StringTrimming = this.stringTrimming; style.StringTrimming = this.stringTrimming;
style.ContentAlignment = this.contentAlignment; style.ContentAlignment = this.contentAlignment;
return style; return style;
} }

5
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs

@ -11,6 +11,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using SharpReportCore.Exporters; using SharpReportCore.Exporters;
/// <summary> /// <summary>
///This class drwas a Circle ///This class drwas a Circle
/// </summary> /// </summary>
@ -31,9 +32,9 @@ namespace SharpReportCore {
#region IExportColumnBuilder #region IExportColumnBuilder
public BaseExportColumn CreateExportColumn(Graphics graphics){ public BaseExportColumn CreateExportColumn(Graphics graphics){
BaseStyleDecorator style = base.CreateItemStyle(this.shape); GraphicStyleDecorator style = base.CreateItemStyle(this.shape);
ExportGraphic item = new ExportGraphic(style,false); ExportGraphic item = new ExportGraphic(style,false);
return item; return item as ExportGraphic;
} }
#endregion #endregion

4
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs

@ -36,9 +36,9 @@ namespace SharpReportCore {
#region IExportColumnBuilder implementation #region IExportColumnBuilder implementation
public BaseExportColumn CreateExportColumn(Graphics graphics){ public BaseExportColumn CreateExportColumn(Graphics graphics){
BaseStyleDecorator style = base.CreateItemStyle(this.shape); GraphicStyleDecorator style = base.CreateItemStyle(this.shape);
ExportGraphic item = new ExportGraphic(style,false); ExportGraphic item = new ExportGraphic(style,false);
return item; return item as ExportGraphic;
} }
#endregion #endregion

4
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs

@ -34,9 +34,9 @@ namespace SharpReportCore {
#region IExportColumnBuilder #region IExportColumnBuilder
public BaseExportColumn CreateExportColumn(Graphics graphics){ public BaseExportColumn CreateExportColumn(Graphics graphics){
BaseStyleDecorator style = base.CreateItemStyle(this.shape); GraphicStyleDecorator style = base.CreateItemStyle(this.shape);
ExportGraphic item = new ExportGraphic(style,false); ExportGraphic item = new ExportGraphic(style,false);
return item; return item as ExportGraphic;
} }
#endregion #endregion

75
src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/BaseStyleDecorator.cs

@ -9,7 +9,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
namespace SharpReportCore.Exporters namespace SharpReportCore.Exporters
{ {
/// <summary> /// <summary>
@ -22,15 +22,6 @@ namespace SharpReportCore.Exporters
private Color foreColor; private Color foreColor;
private Point location; private Point location;
private Size size; 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){ public BaseStyleDecorator():this(Color.White,Color.Black){
} }
@ -86,41 +77,7 @@ 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 { public Rectangle DisplayRectangle {
get { get {
@ -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() {
}
}
} }

48
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
{
/// <summary>
/// Description of GraphicStyleDecorator.
/// </summary>
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; }
}
}
}

69
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
{
/// <summary>
/// Description of TextStyleDecorator.
/// </summary>
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;
}
}
}
}

4
src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/BaseExportColumn.cs

@ -15,8 +15,8 @@ namespace SharpReportCore.Exporters
/// <summary> /// <summary>
/// Description of BaseLineItem. /// Description of BaseLineItem.
/// </summary> /// </summary>
public class BaseExportColumn :IPerformLine public class BaseExportColumn{
{
BaseStyleDecorator styleDecorator; BaseStyleDecorator styleDecorator;
bool isContainer; bool isContainer;

26
src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportGraphic.cs

@ -8,13 +8,14 @@
*/ */
using System; using System;
using System.Drawing;
namespace SharpReportCore.Exporters namespace SharpReportCore.Exporters
{ {
/// <summary> /// <summary>
/// Description of ExportGraphic. /// Description of ExportGraphic.
/// </summary> /// </summary>
public class ExportGraphic:BaseExportColumn,IPerformLine public class ExportGraphic:BaseExportColumn
{ {
public ExportGraphic():base() public ExportGraphic():base()
{ {
@ -22,15 +23,24 @@ namespace SharpReportCore.Exporters
public ExportGraphic (BaseStyleDecorator itemStyle,bool isContainer):base(itemStyle,isContainer){ public ExportGraphic (BaseStyleDecorator itemStyle,bool isContainer):base(itemStyle,isContainer){
} }
public void DrawGraphic (Graphics graphics) {
public override BaseStyleDecorator StyleDecorator { if (graphics == null) {
get { throw new ArgumentNullException("graphics");
return base.StyleDecorator;
}
set {
base.StyleDecorator = value;
} }
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;
// }
// }
} }
} }

2
src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/ExportText.cs

@ -13,7 +13,7 @@ namespace SharpReportCore.Exporters {
/// <summary> /// <summary>
/// Description of LineItem. /// Description of LineItem.
/// </summary> /// </summary>
public class ExportText :BaseExportColumn,IPerformLine{ public class ExportText :BaseExportColumn{
string text; string text;
public ExportText():base(){ public ExportText():base(){

4
src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/ExportColumns/IExportColumnBuilder .cs

@ -19,11 +19,11 @@ namespace SharpReportCore
public interface IExportColumnBuilder{ public interface IExportColumnBuilder{
BaseExportColumn CreateExportColumn (Graphics graphics); BaseExportColumn CreateExportColumn (Graphics graphics);
} }
/*
public interface IPerformLine{ public interface IPerformLine{
BaseStyleDecorator StyleDecorator { BaseStyleDecorator StyleDecorator {
get;set; get;set;
} }
} }
*/
} }

11
src/AddIns/Misc/SharpReport/SharpReportCore/Exporter/PageBuilder.cs

@ -206,15 +206,16 @@ namespace SharpReportCore.Exporters
BaseSection section = this.reportModel.PageFooter; BaseSection section = this.reportModel.PageFooter;
this.DoConvert (this.reportModel.PageFooter,this.singlePage.SectionBounds.PageFooterRectangle.Top); 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()); // System.Console.WriteLine("\tdisplay {0}",li.ToString());
ExportText l = li as ExportText; // ExportText l = li as ExportText;
if (l != null) { if (li != null) {
System.Console.WriteLine("\t\t{0} / {1} ",l.StyleDecorator.Location,l.Text); System.Console.WriteLine("\t\t{0} / {1} ",l.StyleDecorator.Location,l.Text);
} }
} }
*/
private void Write () { private void Write () {
this.dataNavigator = this.dataManager.GetNavigator; this.dataNavigator = this.dataManager.GetNavigator;
Graphics graphics = reportModel.ReportSettings.PageSettings.PrinterSettings.CreateMeasurementGraphics(); Graphics graphics = reportModel.ReportSettings.PageSettings.PrinterSettings.CreateMeasurementGraphics();

2
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs

@ -68,7 +68,7 @@ namespace SharpReportCore {
} }
public static void PaintString (Graphics graphics,string text, public static void PaintString (Graphics graphics,string text,
SharpReportCore.Exporters.BaseStyleDecorator decorator) { SharpReportCore.Exporters.TextStyleDecorator decorator) {
// d.DrawString(gr, // d.DrawString(gr,
// ex.ToString(), // ex.ToString(),

4
src/AddIns/Misc/SharpReport/SharpReportCore/ReportViewer/ReportViewer.cs

@ -91,10 +91,10 @@ namespace SharpReportCore.ReportViewer
// System.Console.WriteLine("{0}",ex.GetType()); // System.Console.WriteLine("{0}",ex.GetType());
ExportGraphic eg = ex as ExportGraphic; ExportGraphic eg = ex as ExportGraphic;
if (eg != null) { if (eg != null) {
eg.StyleDecorator.DrawGraphic(gr); eg.DrawGraphic(gr);
} else { } else {
TextDrawer.PaintString(gr,ex.ToString(),ex.StyleDecorator); TextDrawer.PaintString(gr,ex.ToString(),(TextStyleDecorator)ex.StyleDecorator);
} }
} else { } else {

3
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj

@ -155,6 +155,8 @@
</EmbeddedResource> </EmbeddedResource>
<Compile Include="Exporter\ExporterCollection.cs" /> <Compile Include="Exporter\ExporterCollection.cs" />
<Compile Include="Exporter\ExportColumns\ExportGraphic.cs" /> <Compile Include="Exporter\ExportColumns\ExportGraphic.cs" />
<Compile Include="Exporter\Decorators\TextStyleDecorator.cs" />
<Compile Include="Exporter\Decorators\GraphicStyleDecorator.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="BaseItems" /> <Folder Include="BaseItems" />
@ -185,6 +187,7 @@
<Content Include="ReportViewer\Resources\Icons.16x16.Print.png" /> <Content Include="ReportViewer\Resources\Icons.16x16.Print.png" />
<Content Include="ReportViewer\Resources\Icons.16x16.BrowserBefore.png" /> <Content Include="ReportViewer\Resources\Icons.16x16.BrowserBefore.png" />
<Content Include="ReportViewer\Resources\Icons.16x16.BrowserAfter.png" /> <Content Include="ReportViewer\Resources\Icons.16x16.BrowserAfter.png" />
<Folder Include="Exporter\Decorators" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project> </Project>
Loading…
Cancel
Save