Browse Source

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
shortcuts
Peter Forstmeier 20 years ago
parent
commit
5e9c0df54c
  1. 5
      src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs
  2. 35
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs
  3. 28
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/FunctionControl.cs
  4. 10
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportCircleControl.cs
  5. 19
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs
  6. 2
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs
  7. 10
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs
  8. 9
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportLineControl.cs
  9. 33
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportObjectControlBase.cs
  10. 10
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs
  11. 24
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs
  12. 28
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs
  13. 2
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs
  14. 2
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs
  15. 6
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs
  16. 10
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs
  17. 3
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs
  18. 22
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs
  19. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs
  20. 134
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs
  21. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs
  22. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs
  23. 32
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs
  24. 62
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs
  25. 26
      src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs
  26. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs
  27. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  28. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  29. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj

5
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.Location = new System.Drawing.Point(0, 140);
this.visualDetail.Name = "visualDetail"; this.visualDetail.Name = "visualDetail";
this.visualDetail.Size = new System.Drawing.Size(400, 72); this.visualDetail.Size = new System.Drawing.Size(400, 72);
this.visualDetail.StringAlignment = System.Drawing.StringAlignment.Near;
this.visualDetail.TabIndex = 3; this.visualDetail.TabIndex = 3;
this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged); this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged);
// //
@ -407,7 +406,6 @@ namespace SharpReport.Designer{
this.visualPageFooter.Location = new System.Drawing.Point(0, 212); this.visualPageFooter.Location = new System.Drawing.Point(0, 212);
this.visualPageFooter.Name = "visualPageFooter"; this.visualPageFooter.Name = "visualPageFooter";
this.visualPageFooter.Size = new System.Drawing.Size(400, 68); this.visualPageFooter.Size = new System.Drawing.Size(400, 68);
this.visualPageFooter.StringAlignment = System.Drawing.StringAlignment.Near;
this.visualPageFooter.TabIndex = 6; this.visualPageFooter.TabIndex = 6;
this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged); this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged);
// //
@ -419,7 +417,6 @@ namespace SharpReport.Designer{
this.visualFooter.Location = new System.Drawing.Point(0, 280); this.visualFooter.Location = new System.Drawing.Point(0, 280);
this.visualFooter.Name = "visualFooter"; this.visualFooter.Name = "visualFooter";
this.visualFooter.Size = new System.Drawing.Size(400, 76); this.visualFooter.Size = new System.Drawing.Size(400, 76);
this.visualFooter.StringAlignment = System.Drawing.StringAlignment.Near;
this.visualFooter.TabIndex = 7; this.visualFooter.TabIndex = 7;
this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged); this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged);
// //
@ -431,7 +428,6 @@ namespace SharpReport.Designer{
this.visualPageHeader.Location = new System.Drawing.Point(0, 56); this.visualPageHeader.Location = new System.Drawing.Point(0, 56);
this.visualPageHeader.Name = "visualPageHeader"; this.visualPageHeader.Name = "visualPageHeader";
this.visualPageHeader.Size = new System.Drawing.Size(400, 84); this.visualPageHeader.Size = new System.Drawing.Size(400, 84);
this.visualPageHeader.StringAlignment = System.Drawing.StringAlignment.Near;
this.visualPageHeader.TabIndex = 1; this.visualPageHeader.TabIndex = 1;
this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged); this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged);
// //
@ -443,7 +439,6 @@ namespace SharpReport.Designer{
this.visualReportHeader.Location = new System.Drawing.Point(0, 0); this.visualReportHeader.Location = new System.Drawing.Point(0, 0);
this.visualReportHeader.Name = "visualReportHeader"; this.visualReportHeader.Name = "visualReportHeader";
this.visualReportHeader.Size = new System.Drawing.Size(400, 56); this.visualReportHeader.Size = new System.Drawing.Size(400, 56);
this.visualReportHeader.StringAlignment = System.Drawing.StringAlignment.Near;
this.visualReportHeader.TabIndex = 0; this.visualReportHeader.TabIndex = 0;
this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged); this.visualDetail.SectionChanged += new EventHandler<SectionChangedEventArgs> (this.SectionSizeChanged);
// //

35
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs

@ -15,7 +15,7 @@ namespace SharpReport.Designer
/// <summary> /// <summary>
/// Description of ControlHelper. /// Description of ControlHelper.
/// </summary> /// </summary>
public class ControlHelper{ internal class ControlHelper{
Control control; Control control;
public ControlHelper(Control control){ public ControlHelper(Control control){
@ -35,27 +35,27 @@ namespace SharpReport.Designer
} }
public void DrawEdges (PaintEventArgs e) { public void DrawEdges (PaintEventArgs e) {
this.DrawEdges (e,this.BuildFocusRectangle);
}
public void DrawEdges (PaintEventArgs e,Rectangle rectangle) {
int arc = 5; int arc = 5;
Rectangle r = this.BuildFocusRectangle;
using (Pen p = new Pen (Color.Black)) { using (Pen p = new Pen (Color.Black)) {
e.Graphics.DrawRectangle (p,rectangle);
e.Graphics.DrawRectangle (p,
r);
} }
using (Pen pb = new Pen(this.control.BackColor)){ using (Pen pb = new Pen(this.control.BackColor)){
//top //top
int leftLine = r.Left + arc; int leftLine = rectangle.Left + arc;
int rightLine = r.Left + r.Width - arc; int rightLine = rectangle.Left + rectangle.Width - arc;
int botLine = r.Top + r.Height; int botLine = rectangle.Top + rectangle.Height;
//top //top
e.Graphics.DrawLine (pb, e.Graphics.DrawLine (pb,
leftLine,r.Top, leftLine,rectangle.Top,
rightLine, r.Top); rightLine, rectangle.Top);
//bottom //bottom
e.Graphics.DrawLine (pb, e.Graphics.DrawLine (pb,
@ -63,17 +63,18 @@ namespace SharpReport.Designer
rightLine,botLine); rightLine,botLine);
//left //left
int top = r.Top + arc; int top = rectangle.Top + arc;
int down = r.Top + r.Height - arc; int down = rectangle.Top + rectangle.Height - arc;
e.Graphics.DrawLine(pb, e.Graphics.DrawLine(pb,
r.Left,top, rectangle.Left,top,
r.Left,down); rectangle.Left,down);
//right //right
e.Graphics.DrawLine(pb, e.Graphics.DrawLine(pb,
r.Left + r.Width,top, rectangle.Left + rectangle.Width,top,
r.Left + r.Width,down); rectangle.Left + rectangle.Width,down);
} }
} }
} }

28
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/FunctionControl.cs

@ -19,7 +19,7 @@ namespace SharpReport.Designer
/// </summary> /// </summary>
internal class FunctionControl : ReportControlBase { internal class FunctionControl : ReportControlBase {
string functionValue; string functionValue;
StringFormat stringFormat;
public FunctionControl() public FunctionControl()
{ {
InitializeComponent(); InitializeComponent();
@ -32,18 +32,21 @@ namespace SharpReport.Designer
} }
#region Overrides #region Overrides
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea)
{ {
base.OnPaint(e); base.OnPaint(pea);
Graphics g = e.Graphics; base.DrawEdges (pea);
base.DrawDecorations(pea);
// StringFormat f = base.StringFormat;
// f.Alignment = base.StringAlignment;
// f.LineAlignment = StringAlignment.Center;
StringFormat f = base.StringFormat; pea.Graphics.DrawString(this.Text + functionValue,
f.Alignment = base.StringAlignment;
g.DrawString(this.Text + functionValue,
this.Font, this.Font,
new SolidBrush(this.ForeColor), new SolidBrush(this.ForeColor),
new Rectangle(0, 0, this.Width - 1, this.Height - 1), new Rectangle(0, 0, this.Width - 1, this.Height - 1),
f); this.stringFormat);
} }
/// <summary> /// <summary>
@ -66,7 +69,14 @@ namespace SharpReport.Designer
} }
} }
public StringFormat StringFormat{
set {
if (this.stringFormat != value) {
this.stringFormat = value;
this.Invalidate();
}
}
}
#endregion #endregion
#region Windows Forms Designer generated code #region Windows Forms Designer generated code

10
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportCircleControl.cs

@ -32,12 +32,14 @@ namespace SharpReport.Designer{
} }
#region overrides #region overrides
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){ protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){
base.OnPaint(e); base.OnPaint(pea);
shape.FillShape(e.Graphics, base.DrawEdges (pea);
base.DrawDecorations(pea);
shape.FillShape(pea.Graphics,
new SolidFillPattern(this.BackColor), new SolidFillPattern(this.BackColor),
(RectangleF)this.ClientRectangle); (RectangleF)this.ClientRectangle);
shape.DrawShape (e.Graphics, shape.DrawShape (pea.Graphics,
new BaseLine (this.ForeColor,base.DashStyle,base.Thickness), new BaseLine (this.ForeColor,base.DashStyle,base.Thickness),
(RectangleF)this.ClientRectangle); (RectangleF)this.ClientRectangle);
} }

19
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs

@ -96,23 +96,32 @@ namespace SharpReport.Designer{
base.OnControlChanged(); base.OnControlChanged();
} }
private void DrawDecorations(Graphics g){
protected void DrawDecorations(PaintEventArgs e){
// it is not said that the // it is not said that the
// focused object in all the app // focused object in all the app
// is the current report item! // is the current report item!
// So I don't check this.Focused. // So I don't check this.Focused.
if (lblBottomRight.Visible){ if (lblBottomRight.Visible){
g.Clear(this.Body.BackColor); e.Graphics.Clear(this.Body.BackColor);
ControlPaint.DrawFocusRectangle(g, ControlPaint.DrawFocusRectangle(e.Graphics,
controlHelper.BuildFocusRectangle); 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){ protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){
base.OnPaint(e); base.OnPaint(e);
controlHelper.DrawEdges(e);
this.DrawDecorations(e.Graphics);
} }
protected override void OnResize(EventArgs e){ protected override void OnResize(EventArgs e){

2
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportDbTextControl.cs

@ -8,6 +8,7 @@
*/ */
using System; using System;
using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using SharpReportCore; using SharpReportCore;
@ -18,6 +19,7 @@ namespace SharpReport.Designer{
/// </summary> /// </summary>
internal class ReportDbTextControl : ReportTextControl{ internal class ReportDbTextControl : ReportTextControl{
public ReportDbTextControl():base(){ public ReportDbTextControl():base(){
InitializeComponent(); InitializeComponent();
this.Size = GlobalValues.PreferedSize; this.Size = GlobalValues.PreferedSize;

10
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportImageControl.cs

@ -37,14 +37,16 @@ namespace SharpReport.ReportItems {
this.UpdateStyles(); this.UpdateStyles();
} }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) {
base.OnPaint (e); base.OnPaint (pea);
base.DrawEdges (pea);
base.DrawDecorations(pea);
if (this.image != null) { if (this.image != null) {
if (this.scaleImageToSize) { if (this.scaleImageToSize) {
e.Graphics.DrawImageUnscaled(image,0,0); pea.Graphics.DrawImageUnscaled(image,0,0);
} else { } else {
e.Graphics.DrawImage(image,0,0,this.Width,this.Height); pea.Graphics.DrawImage(image,0,0,this.Width,this.Height);
} }
} }

9
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportLineControl.cs

@ -36,9 +36,12 @@ namespace SharpReport.Designer{
} }
#region overrides #region overrides
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) {
base.OnPaint(e); base.OnPaint(pea);
shape.DrawShape(e.Graphics, base.DrawEdges (pea);
base.DrawDecorations(pea);
shape.DrawShape(pea.Graphics,
new BaseLine (this.ForeColor,base.DashStyle,base.Thickness), new BaseLine (this.ForeColor,base.DashStyle,base.Thickness),
(RectangleF)this.ClientRectangle); (RectangleF)this.ClientRectangle);
} }

33
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportObjectControlBase.cs

@ -21,10 +21,7 @@ namespace SharpReport.Designer
/// and can have some common members managed easier. /// and can have some common members managed easier.
/// </summary> /// </summary>
public abstract class ReportObjectControlBase : UserControl public abstract class ReportObjectControlBase : UserControl {
{
private StringAlignment stringAlignment = StringAlignment.Near;
private StringFormat stringFormat;
/// <summary> /// <summary>
/// This Event fire's when anything in the VisualControl Design changes like /// This Event fire's when anything in the VisualControl Design changes like
@ -55,38 +52,12 @@ namespace SharpReport.Designer
// does not coincide with the "rendered object" // does not coincide with the "rendered object"
// so "this" identifies the whole report object // so "this" identifies the whole report object
// and "Body" identifies the rendered control // and "Body" identifies the rendered control
public virtual Control Body public virtual Control Body{
{
get { get {
return this; return this;
} }
} }
/// <summary>
/// Use the same StringFormat we use in printing the report
/// </summary>
public StringFormat StringFormat {
get {
return stringFormat;
}
set {
stringFormat = value;
}
}
/// <summary>
/// use the same StringAlignment we use in printing
/// </summary>
public StringAlignment StringAlignment {
get {
return stringAlignment;
}
set {
stringAlignment = value;
this.Invalidate();
}
}
#endregion #endregion
#region Windows Forms Designer generated code #region Windows Forms Designer generated code

10
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs

@ -39,13 +39,15 @@ namespace SharpReport.Designer {
} }
#region overrides #region overrides
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) {
base.OnPaint(e); base.OnPaint(pea);
shape.FillShape(e.Graphics, base.DrawEdges (pea);
base.DrawDecorations(pea);
shape.FillShape(pea.Graphics,
new SolidFillPattern(this.BackColor), new SolidFillPattern(this.BackColor),
(RectangleF)this.ClientRectangle); (RectangleF)this.ClientRectangle);
shape.DrawShape (e.Graphics, shape.DrawShape (pea.Graphics,
new BaseLine (this.ForeColor,base.DashStyle,base.Thickness), new BaseLine (this.ForeColor,base.DashStyle,base.Thickness),
(RectangleF)this.ClientRectangle); (RectangleF)this.ClientRectangle);
} }

24
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs

@ -20,8 +20,7 @@ namespace SharpReport.Designer{
/// Description of ReportTableControl. /// Description of ReportTableControl.
/// </summary> /// </summary>
public class ReportRowControl:ReportControlBase{ internal class ReportRowControl:ReportControlBase{
ControlHelper controlHelper;
public ReportRowControl():base(){ public ReportRowControl():base(){
InitializeComponent(); InitializeComponent();
@ -34,19 +33,24 @@ namespace SharpReport.Designer{
this.Size = new Size((GlobalValues.PreferedSize.Width * 2) + 10, this.Size = new Size((GlobalValues.PreferedSize.Width * 2) + 10,
GlobalValues.PreferedSize.Height + 10); GlobalValues.PreferedSize.Height + 10);
controlHelper = new ControlHelper((Control)this);
} }
#region overrides #region overrides
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e){ protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){
base.OnPaint(e); base.OnPaint(pea);
TextDrawer tx = new TextDrawer();
Rectangle r = new Rectangle(0,5,this.ClientSize.Width - 1,this.ClientSize.Height - 6);
base.DrawEdges (pea,r);
base.DrawDecorations(pea);
tx.DrawString(e.Graphics,this.Name, StringFormat fmt = GlobalValues.StandartStringFormat();
fmt.LineAlignment = StringAlignment.Near;
pea.Graphics.DrawString(this.Name,
this.Font, this.Font,
new SolidBrush(this.ForeColor), new SolidBrush(this.ForeColor),
new Rectangle(1,0,e.ClipRectangle.Width,(int)this.Font.GetHeight(e.Graphics) + 2), new Rectangle(7,0,pea.ClipRectangle.Width,(int)this.Font.GetHeight(pea.Graphics) + 2),
new StringFormat()); fmt);
} }
public override string ToString() { public override string ToString() {

28
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs

@ -18,8 +18,7 @@ namespace SharpReport.Designer{
/// Description of ReportTextItem. /// Description of ReportTextItem.
/// </summary> /// </summary>
internal class ReportTextControl : ReportControlBase{ internal class ReportTextControl : ReportControlBase{
StringFormat stringFormat;
private TextDrawer textDrawer = new TextDrawer();
public ReportTextControl():base(){ public ReportTextControl():base(){
InitializeComponent(); InitializeComponent();
@ -43,14 +42,26 @@ namespace SharpReport.Designer{
} }
} }
public StringFormat StringFormat{
set {
if (this.stringFormat != value) {
this.stringFormat = value;
this.Invalidate();
}
}
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){ protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){
base.OnPaint(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; string str;
if (String.IsNullOrEmpty(this.Text)) { if (String.IsNullOrEmpty(this.Text)) {
@ -58,12 +69,11 @@ namespace SharpReport.Designer{
} else { } else {
str = this.Text; str = this.Text;
} }
textDrawer.DrawString(graphics,
str, pea.Graphics.DrawString(str,this.Font,
this.Font,
new SolidBrush(this.ForeColor), new SolidBrush(this.ForeColor),
(RectangleF)this.ClientRectangle, (RectangleF)this.ClientRectangle,
fmt); this.stringFormat);
} }

2
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs

@ -54,7 +54,7 @@ namespace SharpReport.ReportItems.Functions {
private void GrapFromBase() { private void GrapFromBase() {
this.visualControl.SuspendLayout(); this.visualControl.SuspendLayout();
visualControl.StringFormat = base.StandartStringFormat; visualControl.StringFormat = base.StringFormat;
this.visualControl.ResumeLayout(); this.visualControl.ResumeLayout();
} }

2
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/Today.cs

@ -57,7 +57,7 @@ namespace SharpReport.ReportItems.Functions {
private void GrapFromBase() { private void GrapFromBase() {
this.visualControl.SuspendLayout(); this.visualControl.SuspendLayout();
visualControl.StringFormat = base.StandartStringFormat; visualControl.StringFormat = base.StringFormat;
this.visualControl.ResumeLayout(); this.visualControl.ResumeLayout();
} }

6
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs

@ -53,9 +53,9 @@ namespace SharpReport {
control.Font = item.Font; control.Font = item.Font;
control.Name = item.Name; control.Name = item.Name;
BaseTextItem b = item as BaseTextItem; BaseTextItem b = item as BaseTextItem;
if (b != null) { // if (b != null) {
control.StringAlignment = b.StringAlignment; // control. = b.StringAlignment;
} // }
} }

10
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs

@ -21,9 +21,7 @@ namespace SharpReport.ReportItems{
public class ReportDataItem : BaseDataItem ,IDesignable{ public class ReportDataItem : BaseDataItem ,IDesignable{
private ReportDbTextControl visualControl; private ReportDbTextControl visualControl;
// bool initDone;
#region Constructors #region Constructors
@ -40,7 +38,7 @@ namespace SharpReport.ReportItems{
visualControl = new ReportDbTextControl(); visualControl = new ReportDbTextControl();
this.visualControl.Text = base.ColumnName; this.visualControl.Text = base.ColumnName;
visualControl.StringFormat = base.StandartStringFormat; visualControl.StringFormat = base.StringFormat;
this.Text = base.ColumnName; this.Text = base.ColumnName;
ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this);
@ -64,8 +62,10 @@ namespace SharpReport.ReportItems{
#endregion #endregion
#region events's #region events's
private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ private void BasePropertyChange (object sender, PropertyChangedEventArgs e){
ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); ItemsHelper.UpdateControlFromTextBase(this.visualControl,this);
this.visualControl.StringFormat = base.StringFormat;
this.HandlePropertyChanged(e.PropertyName); this.HandlePropertyChanged(e.PropertyName);
} }
@ -96,9 +96,8 @@ namespace SharpReport.ReportItems{
} }
#endregion #endregion
#region Property's #region Property's
public override Size Size { public override Size Size {
get { get {
return base.Size; return base.Size;
@ -171,6 +170,7 @@ namespace SharpReport.ReportItems{
public new event PropertyChangedEventHandler PropertyChanged; public new event PropertyChangedEventHandler PropertyChanged;
public event EventHandler <EventArgs> Selected; public event EventHandler <EventArgs> Selected;
#endregion #endregion
/* /*

3
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs

@ -32,7 +32,7 @@ namespace SharpReport.ReportItems {
visualControl = new ReportTextControl(); visualControl = new ReportTextControl();
this.Text = visualControl.Name; this.Text = visualControl.Name;
visualControl.StringFormat = base.StandartStringFormat; visualControl.StringFormat = base.StringFormat;
ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this);
@ -53,6 +53,7 @@ namespace SharpReport.ReportItems {
#region events #region events
private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ private void BasePropertyChange (object sender, PropertyChangedEventArgs e){
ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); ItemsHelper.UpdateControlFromTextBase(this.visualControl,this);
this.visualControl.StringFormat = base.StringFormat;
this.HandlePropertyChanged(e.PropertyName); this.HandlePropertyChanged(e.PropertyName);
} }

22
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs

@ -8,18 +8,17 @@
// </autogenerated> // </autogenerated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
namespace SharpReportCore {
using System;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Drawing;
/// <summary> using System;
/// This Class is the BaseClass for <see cref="BaseTextItem"></see> using System.Drawing;
/// and <see cref="BaseGraphicItem"></see> using System.ComponentModel;
/// </summary> using System.Xml.Serialization;
/// <summary>
/// This Class is the BaseClass for <see cref="BaseTextItem"></see>
/// and <see cref="BaseGraphicItem"></see>
/// </summary>
namespace SharpReportCore {
public class BaseReportItem : SharpReportCore.BaseReportObject, public class BaseReportItem : SharpReportCore.BaseReportObject,
IItemRenderer{ IItemRenderer{
@ -125,6 +124,7 @@ namespace SharpReportCore {
} }
} }
[Category("Appearance")]
public virtual Color ForeColor { public virtual Color ForeColor {
get { get {
return foreColor; return foreColor;
@ -135,7 +135,7 @@ namespace SharpReportCore {
} }
} }
[Category("Appearance")]
public virtual Font Font { public virtual Font Font {
get { get {
return this.font; return this.font;

1
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs

@ -152,6 +152,7 @@ namespace SharpReportCore {
} }
} }
[Category("Appearance")]
public virtual Color BackColor { public virtual Color BackColor {
get { get {
return backColor; return backColor;

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

@ -8,8 +8,9 @@
// </autogenerated> // </autogenerated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
using System; using System;
using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.ComponentModel;
using System.Xml.Serialization;
using SharpReportCore; using SharpReportCore;
@ -25,18 +26,93 @@ namespace SharpReportCore {
private string text; private string text;
private string formatString = String.Empty; private string formatString = String.Empty;
private StringAlignment stringAlignment = StringAlignment.Near; private StringFormat stringFormat;
private StringFormat standartStringFormat; private StringTrimming stringTrimming;
private TextDrawer textDrawer = new TextDrawer(); private TextDrawer textDrawer = new TextDrawer();
private ContentAlignment contentAlignment;
#region Constructor #region Constructor
public BaseTextItem():base() { public BaseTextItem():base() {
this.standartStringFormat = GlobalValues.StandartStringFormat(); this.stringFormat = StringFormat.GenericTypographic;
this.contentAlignment = ContentAlignment.MiddleLeft;
this.stringTrimming = StringTrimming.EllipsisCharacter;
} }
#endregion #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) { public override void Render(ReportPageEventArgs rpea) {
if (rpea == null) { if (rpea == null) {
throw new ArgumentNullException("rpea"); throw new ArgumentNullException("rpea");
@ -69,6 +145,7 @@ namespace SharpReportCore {
Decorate (e,System.Drawing.Rectangle.Ceiling (rect)); Decorate (e,System.Drawing.Rectangle.Ceiling (rect));
return rect; return rect;
} }
///<summary> ///<summary>
/// Measure the Size of the String rectangle /// Measure the Size of the String rectangle
/// </summary> /// </summary>
@ -79,7 +156,7 @@ namespace SharpReportCore {
measureSizeF = rpea.PrintPageEventArgs.Graphics.MeasureString(text, measureSizeF = rpea.PrintPageEventArgs.Graphics.MeasureString(text,
this.Font, this.Font,
this.Size.Width, this.Size.Width,
StandartStringFormat); this.stringFormat);
return measureSizeF; return measureSizeF;
} }
@ -97,9 +174,7 @@ namespace SharpReportCore {
if (rpea == null) { if (rpea == null) {
throw new ArgumentException (this.Name); throw new ArgumentException (this.Name);
} }
StringFormat fmt = StandartStringFormat; StringFormat fmt = this.stringFormat;
fmt.Alignment = this.StringAlignment;
textDrawer.DrawString(rpea.PrintPageEventArgs.Graphics, textDrawer.DrawString(rpea.PrintPageEventArgs.Graphics,
toPrint, toPrint,
this.Font, this.Font,
@ -129,43 +204,46 @@ namespace SharpReportCore {
} }
///<summary> public virtual string Text {
/// StringAlignment Near = Left,Center,Far = Right
/// </summary>
[Browsable(true),
Category("Appearance"),
Description("Alignment of Output Near,Center,Far")]
public virtual StringAlignment StringAlignment {
get { get {
return stringAlignment; return text;
} }
set { set {
stringAlignment = value; text = value;
base.NotifyPropertyChanged("StringAligment"); base.NotifyPropertyChanged("Text");
} }
} }
public virtual string Text {
[Category("Appearance")]
public StringTrimming StringTrimming {
get { get {
return text; return stringTrimming;
} }
set { set {
text = value; stringTrimming = value;
base.NotifyPropertyChanged("Text"); base.NotifyPropertyChanged("StringTrimming");
} }
} }
[Browsable(false)] [Category("Appearance")]
public StringFormat StandartStringFormat { public System.Drawing.ContentAlignment ContentAlignment {
get { get {
return standartStringFormat; return this.contentAlignment;
} }
set { set {
standartStringFormat = value; this.contentAlignment = value;
base.NotifyPropertyChanged("ContentAlignment");
} }
} }
[Browsable(false)]
[XmlIgnoreAttribute]
public StringFormat StringFormat {
get {
return this.BuildStringFormat();
}
}
} }
} }

2
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs

@ -41,7 +41,7 @@ namespace SharpReportCore {
//Printout the textpart //Printout the textpart
base.PrintTheStuff (rpea,this.Text,rect); base.PrintTheStuff (rpea,this.Text,rect);
//here we print the functionpart //here we print the functionpart
StringFormat fmt = StandartStringFormat; StringFormat fmt = StringFormat;
fmt.Alignment = StringAlignment.Far; fmt.Alignment = StringAlignment.Far;
fmt.LineAlignment = StringAlignment.Near; fmt.LineAlignment = StringAlignment.Near;

2
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs

@ -37,7 +37,7 @@ namespace SharpReportCore {
base.PrintTheStuff (rpea,this.Text,rect); base.PrintTheStuff (rpea,this.Text,rect);
//here we print the functionpart allway's with Stringalignment.Far //here we print the functionpart allway's with Stringalignment.Far
StringFormat fmt = StandartStringFormat; StringFormat fmt = StringFormat;
fmt.Alignment = StringAlignment.Far; fmt.Alignment = StringAlignment.Far;
fmt.LineAlignment = StringAlignment.Near; fmt.LineAlignment = StringAlignment.Near;

32
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs

@ -21,8 +21,10 @@ namespace SharpReportCore{
public class RowItem:BaseReportItem,IContainerItem{ public class RowItem:BaseReportItem,IContainerItem{
private string tableName; private string tableName;
ReportItemCollection items; private ReportItemCollection items;
Padding padding; private Padding padding;
private Color secondaryBackColor;
private int changeBackColorEveryNRow;
public RowItem():this (String.Empty){ public RowItem():this (String.Empty){
} }
@ -34,7 +36,6 @@ namespace SharpReportCore{
} }
void OnAdded (object sender, CollectionItemEventArgs<IItemRenderer> e){ void OnAdded (object sender, CollectionItemEventArgs<IItemRenderer> e){
System.Console.WriteLine(""); System.Console.WriteLine("");
System.Console.WriteLine("RowItem:OnAdded"); System.Console.WriteLine("RowItem:OnAdded");
} }
@ -91,18 +92,31 @@ namespace SharpReportCore{
#region properties #region properties
public string TableName {
get {
return tableName;
[Category("Appearance"),
Description("Change the Backcolor on every 'N' Row")]
public Color SecondaryBackColor {
get {
return this.secondaryBackColor;
} }
set { set {
tableName = value; this.secondaryBackColor = value;
base.NotifyPropertyChanged("SecondaryBackColor");
} }
} }
[Category("Appearance")]
public int ChangeBackColorEveryNRow {
get {
return changeBackColorEveryNRow;
}
set {
changeBackColorEveryNRow = value;
base.NotifyPropertyChanged("ChangeBackColorEveryNRow");
}
}
#endregion #endregion
@ -114,11 +128,11 @@ namespace SharpReportCore{
} }
set { set {
padding = value; padding = value;
base.NotifyPropertyChanged("Padding");
} }
} }
public bool IsValidChild(BaseReportItem childControl){ public bool IsValidChild(BaseReportItem childControl){
// BaseDataItem bdi = childControl as BaseDataItem;
BaseReportItem bdi = childControl as BaseDataItem; BaseReportItem bdi = childControl as BaseDataItem;
if (bdi != null) { if (bdi != null) {
return true; return true;

62
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 {
/// <summary>
/// Description of TableItem.
/// </summary>
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
}
}

26
src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs

@ -219,4 +219,30 @@ namespace SharpReportCore{
} }
} }
/*
/// <summary>
/// This class holds a COllection <see cref="RowItem"></see>
/// used in <see cref="TableItem"></see></summary>
public class RowItemCollection : List<RowItem> {
public event EventHandler<CollectionItemEventArgs<IItemRenderer>> Added;
public event EventHandler<CollectionItemEventArgs<IItemRenderer>> 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;
}
}
*/
} }

6
src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalValues.cs

@ -93,9 +93,9 @@ namespace SharpReportCore {
public static StringFormat StandartStringFormat() { public static StringFormat StandartStringFormat() {
StringFormat sFormat = StringFormat.GenericTypographic; StringFormat sFormat = StringFormat.GenericTypographic;
sFormat.FormatFlags |= StringFormatFlags.LineLimit; sFormat.FormatFlags |= StringFormatFlags.LineLimit;
//
sFormat.Trimming |= StringTrimming.EllipsisCharacter; // sFormat.Trimming |= StringTrimming.EllipsisCharacter;
sFormat.LineAlignment |= StringAlignment.Near; // sFormat.LineAlignment |= StringAlignment.Near;
return sFormat; return sFormat;
} }

4
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs

@ -316,11 +316,11 @@ namespace SharpReportCore {
BaseDataItem it = item as BaseDataItem; BaseDataItem it = item as BaseDataItem;
str = it.DbValue; str = it.DbValue;
} }
// TODO need a much better way
sizeF = e.PrintPageEventArgs.Graphics.MeasureString(str, sizeF = e.PrintPageEventArgs.Graphics.MeasureString(str,
myItem.Font, myItem.Font,
myItem.Size.Width, myItem.Size.Width,
GlobalValues.StandartStringFormat()); myItem.StringFormat);
} else { } else {
sizeF = new SizeF (item.Size.Width,item.Size.Height); sizeF = new SizeF (item.Size.Width,item.Size.Height);
} }

4
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs

@ -130,6 +130,7 @@ namespace SharpReportCore {
this.RemoveSectionEvents(); this.RemoveSectionEvents();
} }
//TODO how should we handle ReportFooter, print it on an seperate page ???? //TODO how should we handle ReportFooter, print it on an seperate page ????
private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){ private void DoReportFooter (PointF startAt,ReportPageEventArgs rpea){
base.MeasureReportFooter(rpea); base.MeasureReportFooter(rpea);
@ -155,7 +156,7 @@ namespace SharpReportCore {
} }
protected override void BeginPrintPage(object sender, ReportPageEventArgs rpea) { protected override void BeginPrintPage(object sender, ReportPageEventArgs rpea) {
System.Console.WriteLine("!!! Beginprintpage");
if (rpea == null) { if (rpea == null) {
throw new ArgumentNullException("rpea"); throw new ArgumentNullException("rpea");
} }
@ -243,6 +244,7 @@ namespace SharpReportCore {
protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) { protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) {
System.Console.WriteLine("!! Page End");
this.DoPageEnd (rpea); this.DoPageEnd (rpea);
} }

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

@ -129,6 +129,7 @@
<Compile Include="DataManager\DataNavigator.cs" /> <Compile Include="DataManager\DataNavigator.cs" />
<Compile Include="Interfaces\IDataNavigator.cs" /> <Compile Include="Interfaces\IDataNavigator.cs" />
<Compile Include="Events\PrintEventArgs.cs" /> <Compile Include="Events\PrintEventArgs.cs" />
<Compile Include="BaseItems\TableItem.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="BaseItems" /> <Folder Include="BaseItems" />

Loading…
Cancel
Save