From 5e9c0df54c7fbc2f8eb0001c83bdd11c791e28ee Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Tue, 18 Apr 2006 08:20:40 +0000 Subject: [PATCH] Better formatting of strings Textbased Items use StringTrimming and System.Drawing.ContentAlignment git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1313 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../SharpReport/Designer/Report.cs | 5 - .../Designer/VisualControls/ControlHelper.cs | 35 ++--- .../VisualControls/FunctionControl.cs | 30 ++-- .../VisualControls/ReportCircleControl.cs | 10 +- .../VisualControls/ReportControlBase.cs | 21 ++- .../VisualControls/ReportDbTextControl.cs | 4 +- .../VisualControls/ReportImageControl.cs | 10 +- .../VisualControls/ReportLineControl.cs | 9 +- .../VisualControls/ReportObjectControlBase.cs | 37 +---- .../VisualControls/ReportRectangleControl.cs | 10 +- .../VisualControls/ReportRowControl.cs | 26 ++-- .../VisualControls/ReportTextControl.cs | 34 +++-- .../Functions/MiscFunctions/PageNumber.cs | 2 +- .../Functions/MiscFunctions/Today.cs | 2 +- .../ReportItems/TextBased/ItemsHelper.cs | 6 +- .../ReportItems/TextBased/ReportDataItem.cs | 12 +- .../ReportItems/TextBased/ReportTextItem.cs | 3 +- .../BaseItems/BaseReportItem.cs | 24 +-- .../BaseItems/BaseReportObject.cs | 1 + .../SharpReportCore/BaseItems/BaseTextItem.cs | 138 ++++++++++++++---- .../BaseItems/Functions/BasePageNumber.cs | 2 +- .../BaseItems/Functions/BaseToday.cs | 2 +- .../SharpReportCore/BaseItems/RowItem.cs | 38 +++-- .../SharpReportCore/BaseItems/TableItem.cs | 62 ++++++++ .../Collections/Collections.cs | 26 ++++ .../SharpReportCore/Globals/GlobalValues.cs | 6 +- .../Printing/AbstractRenderer.cs | 4 +- .../Printing/RenderDataReport.cs | 4 +- .../SharpReportCore/SharpReportCore.csproj | 1 + 29 files changed, 380 insertions(+), 184 deletions(-) create mode 100644 src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs index 8f8835d2d6..abb26ff322 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs @@ -395,7 +395,6 @@ namespace SharpReport.Designer{ this.visualDetail.Location = new System.Drawing.Point(0, 140); this.visualDetail.Name = "visualDetail"; this.visualDetail.Size = new System.Drawing.Size(400, 72); - this.visualDetail.StringAlignment = System.Drawing.StringAlignment.Near; this.visualDetail.TabIndex = 3; this.visualDetail.SectionChanged += new EventHandler (this.SectionSizeChanged); // @@ -407,7 +406,6 @@ namespace SharpReport.Designer{ this.visualPageFooter.Location = new System.Drawing.Point(0, 212); this.visualPageFooter.Name = "visualPageFooter"; this.visualPageFooter.Size = new System.Drawing.Size(400, 68); - this.visualPageFooter.StringAlignment = System.Drawing.StringAlignment.Near; this.visualPageFooter.TabIndex = 6; this.visualDetail.SectionChanged += new EventHandler (this.SectionSizeChanged); // @@ -419,7 +417,6 @@ namespace SharpReport.Designer{ this.visualFooter.Location = new System.Drawing.Point(0, 280); this.visualFooter.Name = "visualFooter"; this.visualFooter.Size = new System.Drawing.Size(400, 76); - this.visualFooter.StringAlignment = System.Drawing.StringAlignment.Near; this.visualFooter.TabIndex = 7; this.visualDetail.SectionChanged += new EventHandler (this.SectionSizeChanged); // @@ -431,7 +428,6 @@ namespace SharpReport.Designer{ this.visualPageHeader.Location = new System.Drawing.Point(0, 56); this.visualPageHeader.Name = "visualPageHeader"; this.visualPageHeader.Size = new System.Drawing.Size(400, 84); - this.visualPageHeader.StringAlignment = System.Drawing.StringAlignment.Near; this.visualPageHeader.TabIndex = 1; this.visualDetail.SectionChanged += new EventHandler (this.SectionSizeChanged); // @@ -443,7 +439,6 @@ namespace SharpReport.Designer{ this.visualReportHeader.Location = new System.Drawing.Point(0, 0); this.visualReportHeader.Name = "visualReportHeader"; this.visualReportHeader.Size = new System.Drawing.Size(400, 56); - this.visualReportHeader.StringAlignment = System.Drawing.StringAlignment.Near; this.visualReportHeader.TabIndex = 0; this.visualDetail.SectionChanged += new EventHandler (this.SectionSizeChanged); // diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs index 28b5015426..72e3ac78f0 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs @@ -15,7 +15,7 @@ namespace SharpReport.Designer /// /// Description of ControlHelper. /// - public class ControlHelper{ + internal class ControlHelper{ Control control; public ControlHelper(Control control){ @@ -35,27 +35,27 @@ namespace SharpReport.Designer } - public void DrawEdges (PaintEventArgs e) { + this.DrawEdges (e,this.BuildFocusRectangle); + } + + public void DrawEdges (PaintEventArgs e,Rectangle rectangle) { int arc = 5; - Rectangle r = this.BuildFocusRectangle; using (Pen p = new Pen (Color.Black)) { - - e.Graphics.DrawRectangle (p, - r); + e.Graphics.DrawRectangle (p,rectangle); } using (Pen pb = new Pen(this.control.BackColor)){ //top - int leftLine = r.Left + arc; - int rightLine = r.Left + r.Width - arc; - int botLine = r.Top + r.Height; + int leftLine = rectangle.Left + arc; + int rightLine = rectangle.Left + rectangle.Width - arc; + int botLine = rectangle.Top + rectangle.Height; //top e.Graphics.DrawLine (pb, - leftLine,r.Top, - rightLine, r.Top); + leftLine,rectangle.Top, + rightLine, rectangle.Top); //bottom e.Graphics.DrawLine (pb, @@ -63,17 +63,18 @@ namespace SharpReport.Designer rightLine,botLine); //left - int top = r.Top + arc; - int down = r.Top + r.Height - arc; + int top = rectangle.Top + arc; + int down = rectangle.Top + rectangle.Height - arc; e.Graphics.DrawLine(pb, - r.Left,top, - r.Left,down); + rectangle.Left,top, + rectangle.Left,down); //right e.Graphics.DrawLine(pb, - r.Left + r.Width,top, - r.Left + r.Width,down); + rectangle.Left + rectangle.Width,top, + rectangle.Left + rectangle.Width,down); } + } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/FunctionControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/FunctionControl.cs index 761b351a58..fe08d7c391 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/FunctionControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/FunctionControl.cs @@ -19,7 +19,7 @@ namespace SharpReport.Designer /// internal class FunctionControl : ReportControlBase { string functionValue; - + StringFormat stringFormat; public FunctionControl() { InitializeComponent(); @@ -32,18 +32,21 @@ namespace SharpReport.Designer } #region Overrides - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) { - base.OnPaint(e); - Graphics g = e.Graphics; - - StringFormat f = base.StringFormat; - f.Alignment = base.StringAlignment; - g.DrawString(this.Text + functionValue, + base.OnPaint(pea); + base.DrawEdges (pea); + base.DrawDecorations(pea); + +// StringFormat f = base.StringFormat; +// f.Alignment = base.StringAlignment; +// f.LineAlignment = StringAlignment.Center; + + pea.Graphics.DrawString(this.Text + functionValue, this.Font, new SolidBrush(this.ForeColor), new Rectangle(0, 0, this.Width - 1, this.Height - 1), - f); + this.stringFormat); } /// @@ -66,7 +69,14 @@ namespace SharpReport.Designer } } - + public StringFormat StringFormat{ + set { + if (this.stringFormat != value) { + this.stringFormat = value; + this.Invalidate(); + } + } + } #endregion #region Windows Forms Designer generated code diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportCircleControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportCircleControl.cs index 4ac13c7a6c..1115956d42 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportCircleControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportCircleControl.cs @@ -32,12 +32,14 @@ namespace SharpReport.Designer{ } #region overrides - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){ - base.OnPaint(e); - shape.FillShape(e.Graphics, + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){ + base.OnPaint(pea); + base.DrawEdges (pea); + base.DrawDecorations(pea); + shape.FillShape(pea.Graphics, new SolidFillPattern(this.BackColor), (RectangleF)this.ClientRectangle); - shape.DrawShape (e.Graphics, + shape.DrawShape (pea.Graphics, new BaseLine (this.ForeColor,base.DashStyle,base.Thickness), (RectangleF)this.ClientRectangle); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs index 43a5a6251f..71a1ea8781 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs @@ -96,23 +96,32 @@ namespace SharpReport.Designer{ base.OnControlChanged(); } - private void DrawDecorations(Graphics g){ + + protected void DrawDecorations(PaintEventArgs e){ // it is not said that the // focused object in all the app // is the current report item! // So I don't check this.Focused. if (lblBottomRight.Visible){ - g.Clear(this.Body.BackColor); - ControlPaint.DrawFocusRectangle(g, + e.Graphics.Clear(this.Body.BackColor); + ControlPaint.DrawFocusRectangle(e.Graphics, controlHelper.BuildFocusRectangle); } } - + + protected void DrawEdges (PaintEventArgs e,Rectangle rectangle) { + controlHelper.DrawEdges(e,rectangle); + } + + + protected void DrawEdges (PaintEventArgs e) { + controlHelper.DrawEdges(e); + } + + protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){ base.OnPaint(e); - controlHelper.DrawEdges(e); - this.DrawDecorations(e.Graphics); } protected override void OnResize(EventArgs e){ diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs index 785a7374bc..bd525741d5 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs @@ -8,6 +8,7 @@ */ using System; +using System.Drawing; using System.Windows.Forms; using SharpReportCore; @@ -18,12 +19,13 @@ namespace SharpReport.Designer{ /// internal class ReportDbTextControl : ReportTextControl{ + public ReportDbTextControl():base(){ InitializeComponent(); this.Size = GlobalValues.PreferedSize; base.Name = this.Name; } - + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){ base.Text = this.Text; base.OnPaint(pea); diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs index 358a4f38ea..c4f7eb709a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs @@ -37,14 +37,16 @@ namespace SharpReport.ReportItems { this.UpdateStyles(); } - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { - base.OnPaint (e); + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) { + base.OnPaint (pea); + base.DrawEdges (pea); + base.DrawDecorations(pea); if (this.image != null) { if (this.scaleImageToSize) { - e.Graphics.DrawImageUnscaled(image,0,0); + pea.Graphics.DrawImageUnscaled(image,0,0); } else { - e.Graphics.DrawImage(image,0,0,this.Width,this.Height); + pea.Graphics.DrawImage(image,0,0,this.Width,this.Height); } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportLineControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportLineControl.cs index 3ad82ae798..42b4ffa126 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportLineControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportLineControl.cs @@ -36,9 +36,12 @@ namespace SharpReport.Designer{ } #region overrides - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { - base.OnPaint(e); - shape.DrawShape(e.Graphics, + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) { + base.OnPaint(pea); + base.DrawEdges (pea); + base.DrawDecorations(pea); + + shape.DrawShape(pea.Graphics, new BaseLine (this.ForeColor,base.DashStyle,base.Thickness), (RectangleF)this.ClientRectangle); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportObjectControlBase.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportObjectControlBase.cs index 1b42023078..faf4991794 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportObjectControlBase.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportObjectControlBase.cs @@ -21,11 +21,8 @@ namespace SharpReport.Designer /// and can have some common members managed easier. /// - public abstract class ReportObjectControlBase : UserControl - { - private StringAlignment stringAlignment = StringAlignment.Near; - private StringFormat stringFormat; - + public abstract class ReportObjectControlBase : UserControl { + /// /// This Event fire's when anything in the VisualControl Design changes like /// Size,Location,BackColor etc. @@ -55,38 +52,12 @@ namespace SharpReport.Designer // does not coincide with the "rendered object" // so "this" identifies the whole report object // and "Body" identifies the rendered control - public virtual Control Body - { + public virtual Control Body{ get { return this; } } - - /// - /// Use the same StringFormat we use in printing the report - /// - public StringFormat StringFormat { - get { - return stringFormat; - } - set { - stringFormat = value; - } - } - - - /// - /// use the same StringAlignment we use in printing - /// - public StringAlignment StringAlignment { - get { - return stringAlignment; - } - set { - stringAlignment = value; - this.Invalidate(); - } - } + #endregion #region Windows Forms Designer generated code diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs index 83d423ec5a..0b0763aa45 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs @@ -39,13 +39,15 @@ namespace SharpReport.Designer { } #region overrides - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { - base.OnPaint(e); - shape.FillShape(e.Graphics, + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) { + base.OnPaint(pea); + base.DrawEdges (pea); + base.DrawDecorations(pea); + shape.FillShape(pea.Graphics, new SolidFillPattern(this.BackColor), (RectangleF)this.ClientRectangle); - shape.DrawShape (e.Graphics, + shape.DrawShape (pea.Graphics, new BaseLine (this.ForeColor,base.DashStyle,base.Thickness), (RectangleF)this.ClientRectangle); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs index e6973c4c22..0ffed654de 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs @@ -20,8 +20,7 @@ namespace SharpReport.Designer{ /// Description of ReportTableControl. /// - public class ReportRowControl:ReportControlBase{ - ControlHelper controlHelper; + internal class ReportRowControl:ReportControlBase{ public ReportRowControl():base(){ InitializeComponent(); @@ -34,19 +33,24 @@ namespace SharpReport.Designer{ this.Size = new Size((GlobalValues.PreferedSize.Width * 2) + 10, GlobalValues.PreferedSize.Height + 10); - - controlHelper = new ControlHelper((Control)this); } + + #region overrides - protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){ - base.OnPaint(e); - TextDrawer tx = new TextDrawer(); - - tx.DrawString(e.Graphics,this.Name, + protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){ + base.OnPaint(pea); + + Rectangle r = new Rectangle(0,5,this.ClientSize.Width - 1,this.ClientSize.Height - 6); + base.DrawEdges (pea,r); + base.DrawDecorations(pea); + + StringFormat fmt = GlobalValues.StandartStringFormat(); + fmt.LineAlignment = StringAlignment.Near; + pea.Graphics.DrawString(this.Name, this.Font, new SolidBrush(this.ForeColor), - new Rectangle(1,0,e.ClipRectangle.Width,(int)this.Font.GetHeight(e.Graphics) + 2), - new StringFormat()); + new Rectangle(7,0,pea.ClipRectangle.Width,(int)this.Font.GetHeight(pea.Graphics) + 2), + fmt); } public override string ToString() { diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs index 7e34c3640d..af19ca0363 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs @@ -18,8 +18,7 @@ namespace SharpReport.Designer{ /// Description of ReportTextItem. /// internal class ReportTextControl : ReportControlBase{ - - private TextDrawer textDrawer = new TextDrawer(); + StringFormat stringFormat; public ReportTextControl():base(){ InitializeComponent(); @@ -42,15 +41,27 @@ namespace SharpReport.Designer{ base.Text = value; } } - + + public StringFormat StringFormat{ + set { + if (this.stringFormat != value) { + this.stringFormat = value; + this.Invalidate(); + } + } + } protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){ base.OnPaint(pea); + base.DrawEdges (pea); + base.DrawDecorations(pea); + + if (this.stringFormat == null) { + this.stringFormat = GlobalValues.StandartStringFormat(); + this.stringFormat.LineAlignment = StringAlignment.Center; + } - Graphics graphics = pea.Graphics; - StringFormat fmt = GlobalValues.StandartStringFormat(); - fmt.Alignment = this.StringAlignment; string str; if (String.IsNullOrEmpty(this.Text)) { @@ -58,12 +69,11 @@ namespace SharpReport.Designer{ } else { str = this.Text; } - textDrawer.DrawString(graphics, - str, - this.Font, - new SolidBrush(this.ForeColor), - (RectangleF)this.ClientRectangle, - fmt); + + pea.Graphics.DrawString(str,this.Font, + new SolidBrush(this.ForeColor), + (RectangleF)this.ClientRectangle, + this.stringFormat); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs index 9e7fb1c526..7f8a46972b 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs @@ -54,7 +54,7 @@ namespace SharpReport.ReportItems.Functions { private void GrapFromBase() { this.visualControl.SuspendLayout(); - visualControl.StringFormat = base.StandartStringFormat; + visualControl.StringFormat = base.StringFormat; this.visualControl.ResumeLayout(); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs index ab87b7dd0d..edb4a7eefa 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs @@ -57,7 +57,7 @@ namespace SharpReport.ReportItems.Functions { private void GrapFromBase() { this.visualControl.SuspendLayout(); - visualControl.StringFormat = base.StandartStringFormat; + visualControl.StringFormat = base.StringFormat; this.visualControl.ResumeLayout(); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs index dd027b861c..b5e4aceaef 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs @@ -53,9 +53,9 @@ namespace SharpReport { control.Font = item.Font; control.Name = item.Name; BaseTextItem b = item as BaseTextItem; - if (b != null) { - control.StringAlignment = b.StringAlignment; - } +// if (b != null) { +// control. = b.StringAlignment; +// } } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs index 67493f1f99..7a0ef28e1c 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs @@ -21,10 +21,8 @@ namespace SharpReport.ReportItems{ public class ReportDataItem : BaseDataItem ,IDesignable{ - private ReportDbTextControl visualControl; -// bool initDone; - + #region Constructors public ReportDataItem() : this(String.Empty){ @@ -40,7 +38,7 @@ namespace SharpReport.ReportItems{ visualControl = new ReportDbTextControl(); this.visualControl.Text = base.ColumnName; - visualControl.StringFormat = base.StandartStringFormat; + visualControl.StringFormat = base.StringFormat; this.Text = base.ColumnName; ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); @@ -64,8 +62,10 @@ namespace SharpReport.ReportItems{ #endregion #region events's + private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); + this.visualControl.StringFormat = base.StringFormat; this.HandlePropertyChanged(e.PropertyName); } @@ -96,9 +96,8 @@ namespace SharpReport.ReportItems{ } #endregion - - #region Property's + public override Size Size { get { return base.Size; @@ -171,6 +170,7 @@ namespace SharpReport.ReportItems{ public new event PropertyChangedEventHandler PropertyChanged; public event EventHandler Selected; + #endregion /* diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs index 13219d73ec..414b6bca24 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs @@ -32,7 +32,7 @@ namespace SharpReport.ReportItems { visualControl = new ReportTextControl(); this.Text = visualControl.Name; - visualControl.StringFormat = base.StandartStringFormat; + visualControl.StringFormat = base.StringFormat; ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); @@ -53,6 +53,7 @@ namespace SharpReport.ReportItems { #region events private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); + this.visualControl.StringFormat = base.StringFormat; this.HandlePropertyChanged(e.PropertyName); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs index a7ab8cbeba..e342b97d8a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs @@ -8,18 +8,17 @@ // //------------------------------------------------------------------------------ -namespace SharpReportCore { - using System; - using System.ComponentModel; - using System.Xml.Serialization; - - using System.Drawing; - - /// - /// This Class is the BaseClass for - /// and - /// + +using System; +using System.Drawing; +using System.ComponentModel; +using System.Xml.Serialization; +/// +/// This Class is the BaseClass for +/// and +/// +namespace SharpReportCore { public class BaseReportItem : SharpReportCore.BaseReportObject, IItemRenderer{ @@ -125,6 +124,7 @@ namespace SharpReportCore { } } + [Category("Appearance")] public virtual Color ForeColor { get { return foreColor; @@ -135,7 +135,7 @@ namespace SharpReportCore { } } - + [Category("Appearance")] public virtual Font Font { get { return this.font; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs index 48bafe1962..5a653dc8e4 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs @@ -152,6 +152,7 @@ namespace SharpReportCore { } } + [Category("Appearance")] public virtual Color BackColor { get { return backColor; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs index 14b8fa68f8..0ff7465971 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs @@ -8,9 +8,10 @@ // //------------------------------------------------------------------------------ using System; -using System.ComponentModel; using System.Drawing; - +using System.ComponentModel; +using System.Xml.Serialization; + using SharpReportCore; /// @@ -25,18 +26,93 @@ namespace SharpReportCore { private string text; private string formatString = String.Empty; - private StringAlignment stringAlignment = StringAlignment.Near; - private StringFormat standartStringFormat; + private StringFormat stringFormat; + private StringTrimming stringTrimming; private TextDrawer textDrawer = new TextDrawer(); + private ContentAlignment contentAlignment; #region Constructor - public BaseTextItem():base() { - this.standartStringFormat = GlobalValues.StandartStringFormat(); + this.stringFormat = StringFormat.GenericTypographic; + this.contentAlignment = ContentAlignment.MiddleLeft; + this.stringTrimming = StringTrimming.EllipsisCharacter; } #endregion + private StringFormat BuildStringFormat(){ + StringFormat format = StringFormat.GenericTypographic; + format.Trimming = this.stringTrimming; + format.FormatFlags = StringFormatFlags.LineLimit; + +// if (base.RightToLeft) +// { +// format1.FormatFlags |= StringFormatFlags.DirectionRightToLeft; +// } + + ContentAlignment alignment = this.contentAlignment; + if (alignment <= ContentAlignment.MiddleCenter){ + switch (alignment){ + case ContentAlignment.TopLeft:{ + format.Alignment = StringAlignment.Near; + format.LineAlignment = StringAlignment.Near; + return format; + } + case ContentAlignment.TopCenter:{ + format.Alignment = StringAlignment.Center; + format.LineAlignment = StringAlignment.Near; + return format; + } + case (ContentAlignment.TopCenter | ContentAlignment.TopLeft):{ + return format; + } + case ContentAlignment.TopRight:{ + format.Alignment = StringAlignment.Far; + format.LineAlignment = StringAlignment.Near; + return format; + } + case ContentAlignment.MiddleLeft:{ + format.Alignment = StringAlignment.Near; + format.LineAlignment = StringAlignment.Center; + return format; + } + case ContentAlignment.MiddleCenter:{ + format.Alignment = StringAlignment.Center; + format.LineAlignment = StringAlignment.Center; + return format; + } + } + return format; + } + if (alignment <= ContentAlignment.BottomLeft){ + if (alignment == ContentAlignment.MiddleRight){ + format.Alignment = StringAlignment.Far; + format.LineAlignment = StringAlignment.Center; + return format; + } + if (alignment != ContentAlignment.BottomLeft){ + return format; + } + } + else{ + if (alignment != ContentAlignment.BottomCenter){ + if (alignment == ContentAlignment.BottomRight) + { + format.Alignment = StringAlignment.Far; + format.LineAlignment = StringAlignment.Far; + } + return format; + } + format.Alignment = StringAlignment.Center; + format.LineAlignment = StringAlignment.Far; + return format; + } + format.Alignment = StringAlignment.Near; + format.LineAlignment = StringAlignment.Far; + return format; + } + + public override void Render(ReportPageEventArgs rpea) { if (rpea == null) { throw new ArgumentNullException("rpea"); @@ -69,6 +145,7 @@ namespace SharpReportCore { Decorate (e,System.Drawing.Rectangle.Ceiling (rect)); return rect; } + /// /// Measure the Size of the String rectangle /// @@ -79,7 +156,7 @@ namespace SharpReportCore { measureSizeF = rpea.PrintPageEventArgs.Graphics.MeasureString(text, this.Font, this.Size.Width, - StandartStringFormat); + this.stringFormat); return measureSizeF; } @@ -97,9 +174,7 @@ namespace SharpReportCore { if (rpea == null) { throw new ArgumentException (this.Name); } - StringFormat fmt = StandartStringFormat; - fmt.Alignment = this.StringAlignment; - + StringFormat fmt = this.stringFormat; textDrawer.DrawString(rpea.PrintPageEventArgs.Graphics, toPrint, this.Font, @@ -129,43 +204,46 @@ namespace SharpReportCore { } - /// - /// StringAlignment Near = Left,Center,Far = Right - /// - - [Browsable(true), - Category("Appearance"), - Description("Alignment of Output Near,Center,Far")] - public virtual StringAlignment StringAlignment { + public virtual string Text { get { - return stringAlignment; + return text; } set { - stringAlignment = value; - base.NotifyPropertyChanged("StringAligment"); + text = value; + base.NotifyPropertyChanged("Text"); } } - public virtual string Text { + + [Category("Appearance")] + public StringTrimming StringTrimming { get { - return text; + return stringTrimming; } set { - text = value; - base.NotifyPropertyChanged("Text"); + stringTrimming = value; + base.NotifyPropertyChanged("StringTrimming"); } } - [Browsable(false)] - public StringFormat StandartStringFormat { + [Category("Appearance")] + public System.Drawing.ContentAlignment ContentAlignment { get { - return standartStringFormat; + return this.contentAlignment; } set { - standartStringFormat = value; + this.contentAlignment = value; + base.NotifyPropertyChanged("ContentAlignment"); + } + } + + [Browsable(false)] + [XmlIgnoreAttribute] + public StringFormat StringFormat { + get { + return this.BuildStringFormat(); } } - } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs index 0718d85ff3..3970b77d41 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs @@ -41,7 +41,7 @@ namespace SharpReportCore { //Printout the textpart base.PrintTheStuff (rpea,this.Text,rect); //here we print the functionpart - StringFormat fmt = StandartStringFormat; + StringFormat fmt = StringFormat; fmt.Alignment = StringAlignment.Far; fmt.LineAlignment = StringAlignment.Near; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs index 36e576de93..8401c81d3f 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs @@ -37,7 +37,7 @@ namespace SharpReportCore { base.PrintTheStuff (rpea,this.Text,rect); //here we print the functionpart allway's with Stringalignment.Far - StringFormat fmt = StandartStringFormat; + StringFormat fmt = StringFormat; fmt.Alignment = StringAlignment.Far; fmt.LineAlignment = StringAlignment.Near; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs index 1ab7034164..7239901b55 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs @@ -21,8 +21,10 @@ namespace SharpReportCore{ public class RowItem:BaseReportItem,IContainerItem{ private string tableName; - ReportItemCollection items; - Padding padding; + private ReportItemCollection items; + private Padding padding; + private Color secondaryBackColor; + private int changeBackColorEveryNRow; public RowItem():this (String.Empty){ } @@ -33,8 +35,7 @@ namespace SharpReportCore{ this.Items.Added += OnAdded; } - void OnAdded (object sender, CollectionItemEventArgs e){ - + void OnAdded (object sender, CollectionItemEventArgs e){ System.Console.WriteLine(""); System.Console.WriteLine("RowItem:OnAdded"); } @@ -90,19 +91,32 @@ namespace SharpReportCore{ #region properties - - public string TableName { + + + + [Category("Appearance"), + Description("Change the Backcolor on every 'N' Row")] + public Color SecondaryBackColor { get { - - return tableName; + return this.secondaryBackColor; } set { - tableName = value; + this.secondaryBackColor = value; + base.NotifyPropertyChanged("SecondaryBackColor"); } } - - + [Category("Appearance")] + public int ChangeBackColorEveryNRow { + get { + return changeBackColorEveryNRow; + } + set { + changeBackColorEveryNRow = value; + base.NotifyPropertyChanged("ChangeBackColorEveryNRow"); + + } + } #endregion @@ -114,11 +128,11 @@ namespace SharpReportCore{ } set { padding = value; + base.NotifyPropertyChanged("Padding"); } } public bool IsValidChild(BaseReportItem childControl){ -// BaseDataItem bdi = childControl as BaseDataItem; BaseReportItem bdi = childControl as BaseDataItem; if (bdi != null) { return true; diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs new file mode 100644 index 0000000000..728b91fe2d --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs @@ -0,0 +1,62 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 17.04.2006 + * Time: 15:35 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.ComponentModel; +using System.Windows.Forms; + +namespace SharpReportCore.BaseItems { + /// + /// Description of TableItem. + /// + public class TableItem :BaseReportItem,IContainerItem{ + private Padding padding; +// private string tableName; + + public TableItem(){ + + } + + + /* + [Category("Databinding")] + public string TableName { + get { + return tableName; + } +// set { +// tableName = value; +// } + } + */ + #region Interface implementation of 'IContainerItem' + public System.Windows.Forms.Padding Padding { + get { + return this.padding; + } + set { + this.padding = value; + base.NotifyPropertyChanged("Padding"); + } + } + + public ReportItemCollection Items { + get { + throw new NotImplementedException(); + } + } + + public bool IsValidChild(BaseReportItem childControl){ + throw new NotImplementedException(); + } + + #endregion + + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs index ecf2572da7..de10890fd7 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs @@ -219,4 +219,30 @@ namespace SharpReportCore{ } } + /* + /// + /// This class holds a COllection + /// used in + public class RowItemCollection : List { + + public event EventHandler> Added; + public event EventHandler> Removed; + + public new void Add(IItemRenderer item){ + base.Add(item); + this.OnAdded (item); + } + + + + public new bool Remove(IItemRenderer item) + { + if (base.Remove (item)) { + this.OnRemoved(item); + return true; + } + return false; + } + } + */ } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs index b058c679c0..744a7fe316 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs @@ -93,9 +93,9 @@ namespace SharpReportCore { public static StringFormat StandartStringFormat() { StringFormat sFormat = StringFormat.GenericTypographic; sFormat.FormatFlags |= StringFormatFlags.LineLimit; - - sFormat.Trimming |= StringTrimming.EllipsisCharacter; - sFormat.LineAlignment |= StringAlignment.Near; +// +// sFormat.Trimming |= StringTrimming.EllipsisCharacter; +// sFormat.LineAlignment |= StringAlignment.Near; return sFormat; } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs index 1277481902..b38f6bf3c2 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs @@ -316,11 +316,11 @@ namespace SharpReportCore { BaseDataItem it = item as BaseDataItem; str = it.DbValue; } - // TODO need a much better way + sizeF = e.PrintPageEventArgs.Graphics.MeasureString(str, myItem.Font, myItem.Size.Width, - GlobalValues.StandartStringFormat()); + myItem.StringFormat); } else { sizeF = new SizeF (item.Size.Width,item.Size.Height); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs index 25f5a11d93..c7bb557bbe 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs @@ -130,6 +130,7 @@ namespace SharpReportCore { this.RemoveSectionEvents(); } + //TODO how should we handle ReportFooter, print it on an seperate page ???? private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){ base.MeasureReportFooter(rpea); @@ -155,7 +156,7 @@ namespace SharpReportCore { } protected override void BeginPrintPage(object sender, ReportPageEventArgs rpea) { - + System.Console.WriteLine("!!! Beginprintpage"); if (rpea == null) { throw new ArgumentNullException("rpea"); } @@ -243,6 +244,7 @@ namespace SharpReportCore { protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) { + System.Console.WriteLine("!! Page End"); this.DoPageEnd (rpea); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj index 187b90fb8d..a4f13916e9 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj @@ -129,6 +129,7 @@ +