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. 30
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/FunctionControl.cs
  4. 10
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportCircleControl.cs
  5. 21
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs
  6. 4
      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. 37
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportObjectControlBase.cs
  10. 10
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs
  11. 26
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs
  12. 34
      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. 12
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs
  17. 3
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs
  18. 24
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs
  19. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs
  20. 138
      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. 38
      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{ @@ -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<SectionChangedEventArgs> (this.SectionSizeChanged);
//
@ -407,7 +406,6 @@ namespace SharpReport.Designer{ @@ -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<SectionChangedEventArgs> (this.SectionSizeChanged);
//
@ -419,7 +417,6 @@ namespace SharpReport.Designer{ @@ -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<SectionChangedEventArgs> (this.SectionSizeChanged);
//
@ -431,7 +428,6 @@ namespace SharpReport.Designer{ @@ -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<SectionChangedEventArgs> (this.SectionSizeChanged);
//
@ -443,7 +439,6 @@ namespace SharpReport.Designer{ @@ -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<SectionChangedEventArgs> (this.SectionSizeChanged);
//

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

@ -15,7 +15,7 @@ namespace SharpReport.Designer @@ -15,7 +15,7 @@ namespace SharpReport.Designer
/// <summary>
/// Description of ControlHelper.
/// </summary>
public class ControlHelper{
internal class ControlHelper{
Control control;
public ControlHelper(Control control){
@ -35,27 +35,27 @@ namespace SharpReport.Designer @@ -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 @@ -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);
}
}
}

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

@ -19,7 +19,7 @@ namespace SharpReport.Designer @@ -19,7 +19,7 @@ namespace SharpReport.Designer
/// </summary>
internal class FunctionControl : ReportControlBase {
string functionValue;
StringFormat stringFormat;
public FunctionControl()
{
InitializeComponent();
@ -32,18 +32,21 @@ namespace SharpReport.Designer @@ -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);
}
/// <summary>
@ -66,7 +69,14 @@ namespace SharpReport.Designer @@ -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

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

@ -32,12 +32,14 @@ namespace SharpReport.Designer{ @@ -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);
}

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

@ -96,23 +96,32 @@ namespace SharpReport.Designer{ @@ -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){

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

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using SharpReportCore;
@ -18,12 +19,13 @@ namespace SharpReport.Designer{ @@ -18,12 +19,13 @@ namespace SharpReport.Designer{
/// </summary>
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);

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

@ -37,14 +37,16 @@ namespace SharpReport.ReportItems { @@ -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);
}
}

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

@ -36,9 +36,12 @@ namespace SharpReport.Designer{ @@ -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);
}

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

@ -21,11 +21,8 @@ namespace SharpReport.Designer @@ -21,11 +21,8 @@ namespace SharpReport.Designer
/// and can have some common members managed easier.
/// </summary>
public abstract class ReportObjectControlBase : UserControl
{
private StringAlignment stringAlignment = StringAlignment.Near;
private StringFormat stringFormat;
public abstract class ReportObjectControlBase : UserControl {
/// <summary>
/// This Event fire's when anything in the VisualControl Design changes like
/// Size,Location,BackColor etc.
@ -55,38 +52,12 @@ namespace SharpReport.Designer @@ -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;
}
}
/// <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
#region Windows Forms Designer generated code

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

@ -39,13 +39,15 @@ namespace SharpReport.Designer { @@ -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);
}

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

@ -20,8 +20,7 @@ namespace SharpReport.Designer{ @@ -20,8 +20,7 @@ namespace SharpReport.Designer{
/// Description of ReportTableControl.
/// </summary>
public class ReportRowControl:ReportControlBase{
ControlHelper controlHelper;
internal class ReportRowControl:ReportControlBase{
public ReportRowControl():base(){
InitializeComponent();
@ -34,19 +33,24 @@ namespace SharpReport.Designer{ @@ -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() {

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

@ -18,8 +18,7 @@ namespace SharpReport.Designer{ @@ -18,8 +18,7 @@ namespace SharpReport.Designer{
/// Description of ReportTextItem.
/// </summary>
internal class ReportTextControl : ReportControlBase{
private TextDrawer textDrawer = new TextDrawer();
StringFormat stringFormat;
public ReportTextControl():base(){
InitializeComponent();
@ -42,15 +41,27 @@ namespace SharpReport.Designer{ @@ -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{ @@ -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);
}

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

@ -54,7 +54,7 @@ namespace SharpReport.ReportItems.Functions { @@ -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();
}

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

@ -57,7 +57,7 @@ namespace SharpReport.ReportItems.Functions { @@ -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();
}

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

@ -53,9 +53,9 @@ namespace SharpReport { @@ -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;
// }
}

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

@ -21,10 +21,8 @@ namespace SharpReport.ReportItems{ @@ -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{ @@ -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{ @@ -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{ @@ -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{ @@ -171,6 +170,7 @@ namespace SharpReport.ReportItems{
public new event PropertyChangedEventHandler PropertyChanged;
public event EventHandler <EventArgs> Selected;
#endregion
/*

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

@ -32,7 +32,7 @@ namespace SharpReport.ReportItems { @@ -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 { @@ -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);
}

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

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

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

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

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

@ -8,9 +8,10 @@ @@ -8,9 +8,10 @@
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.ComponentModel;
using System.Drawing;
using System.ComponentModel;
using System.Xml.Serialization;
using SharpReportCore;
/// <summary>
@ -25,18 +26,93 @@ namespace 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 { @@ -69,6 +145,7 @@ namespace SharpReportCore {
Decorate (e,System.Drawing.Rectangle.Ceiling (rect));
return rect;
}
///<summary>
/// Measure the Size of the String rectangle
/// </summary>
@ -79,7 +156,7 @@ namespace SharpReportCore { @@ -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 { @@ -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 { @@ -129,43 +204,46 @@ namespace SharpReportCore {
}
///<summary>
/// StringAlignment Near = Left,Center,Far = Right
/// </summary>
[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();
}
}
}
}

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

@ -41,7 +41,7 @@ namespace SharpReportCore { @@ -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;

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

@ -37,7 +37,7 @@ namespace SharpReportCore { @@ -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;

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

@ -21,8 +21,10 @@ namespace SharpReportCore{ @@ -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{ @@ -33,8 +35,7 @@ namespace SharpReportCore{
this.Items.Added += OnAdded;
}
void OnAdded (object sender, CollectionItemEventArgs<IItemRenderer> e){
void OnAdded (object sender, CollectionItemEventArgs<IItemRenderer> e){
System.Console.WriteLine("");
System.Console.WriteLine("RowItem:OnAdded");
}
@ -90,19 +91,32 @@ namespace SharpReportCore{ @@ -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{ @@ -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;

62
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/TableItem.cs

@ -0,0 +1,62 @@ @@ -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{ @@ -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 { @@ -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;
}

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

@ -316,11 +316,11 @@ namespace SharpReportCore { @@ -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);
}

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

@ -130,6 +130,7 @@ namespace SharpReportCore { @@ -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 { @@ -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 { @@ -243,6 +244,7 @@ namespace SharpReportCore {
protected override void PrintPageEnd(object sender, ReportPageEventArgs rpea) {
System.Console.WriteLine("!! Page End");
this.DoPageEnd (rpea);
}

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

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

Loading…
Cancel
Save