Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
RightToLeft
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterForstmeier committed Jun 29, 2011
1 parent a59bb8e commit bdc54cb
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 118 deletions.
Expand Up @@ -59,6 +59,15 @@ public override void Draw(Graphics graphics)
if (this.stringTrimming != StringTrimming.None) {
designTrimmimg = stringTrimming;
}

// var o = StringFormatFlags.LineLimit;
// new StringFormat(StringFormatFlags.MeasureTrailingSpaces)
// http://msdn.microsoft.com/de-de/library/system.drawing.stringformatflags.aspx
http://www.tutorials.de/net-windows-forms/240717-c-mit-drawstring-senkrecht-drucken.html

if (this.RightToLeft == System.Windows.Forms.RightToLeft.Yes) {
Console.WriteLine("RightToLeft");
}
TextDrawer.DrawString(graphics,this.Text,this.Font,
new SolidBrush(this.ForeColor),
this.ClientRectangle,
Expand All @@ -70,8 +79,8 @@ public override void Draw(Graphics graphics)



[EditorAttribute(typeof(DefaultTextEditor),
typeof(System.Drawing.Design.UITypeEditor) )]
[EditorAttribute(typeof(DefaultTextEditor),
typeof(System.Drawing.Design.UITypeEditor) )]
public override string Text {
get { return base.Text; }
set { base.Text = value;
Expand Down Expand Up @@ -116,9 +125,11 @@ public override void Draw(Graphics graphics)
}
}



[Category("Appearance")]
[EditorAttribute(typeof(System.Drawing.Design.ContentAlignmentEditor),
typeof(System.Drawing.Design.UITypeEditor) )]
[EditorAttribute(typeof(System.Drawing.Design.ContentAlignmentEditor),
typeof(System.Drawing.Design.UITypeEditor) )]
public ContentAlignment ContentAlignment {
get { return contentAlignment; }
set {
Expand All @@ -127,9 +138,17 @@ public override void Draw(Graphics graphics)
}
}


[Category("Appearance")]
public override System.Windows.Forms.RightToLeft RightToLeft {
get { return base.RightToLeft; }
set { base.RightToLeft = value; }
}


#endregion


[Browsable(true),
Category("Databinding"),
Description("Datatype of the underlying Column")]
Expand All @@ -144,18 +163,18 @@ public override void Draw(Graphics graphics)
[Browsable(true),
Category("Expression"),
Description("Enter a valid Expression")]
[EditorAttribute(typeof(DefaultTextEditor),
typeof(System.Drawing.Design.UITypeEditor) )]
[EditorAttribute(typeof(DefaultTextEditor),
typeof(System.Drawing.Design.UITypeEditor) )]
public string Expression {get;set;}

#endregion

#region CanGrow/CanShrink

public bool CanGrow {get;set;}

public bool CanShrink {get;set;}

#endregion
}

Expand Down
Expand Up @@ -73,6 +73,9 @@ public override PropertyDescriptorCollection GetProperties(Attribute[] attribute
prop = props.Find("Expression",true);
allProperties.Add(prop);

prop = props.Find("RightToLeft",true);
allProperties.Add(prop);

return new PropertyDescriptorCollection(allProperties.ToArray());
}
}
Expand Down
Expand Up @@ -49,14 +49,17 @@ private TextDrawer()
if (decorator == null) {
throw new ArgumentNullException("decorator");
}

StringFormat stringFormat = BuildStringFormat(decorator.StringTrimming,decorator.ContentAlignment);

string formattedString = text;

if (! String.IsNullOrEmpty(decorator.FormatString)) {
formattedString = StandardFormatter.FormatOutput(text,decorator.FormatString,decorator.DataType,"yyy");
if (decorator.RightToLeft ==System.Windows.Forms.RightToLeft.Yes) {
stringFormat.FormatFlags = stringFormat.FormatFlags | StringFormatFlags.DirectionRightToLeft;
}

var formattedString = text;
if (! String.IsNullOrEmpty(decorator.FormatString)) {
formattedString = StandardFormatter.FormatOutput(text,decorator.FormatString,decorator.DataType,String.Empty);
}

graphics.TextRenderingHint = TextRenderingHint.AntiAlias;

Expand Down
Expand Up @@ -27,8 +27,9 @@ public BaseGraphicItem():base()
}


protected IGraphicStyleDecorator CreateItemStyle (BaseShape shape) {
GraphicStyleDecorator style = new GraphicStyleDecorator(shape);
protected IGraphicStyleDecorator CreateItemStyle (BaseShape shape)
{
IGraphicStyleDecorator style = new GraphicStyleDecorator(shape);

style.Size = this.Size;
style.Location = this.Location;
Expand Down
Expand Up @@ -66,6 +66,7 @@ public class BaseTextItem : BaseReportItem,IExportColumnBuilder,IReportExpressio
style.ContentAlignment = this.contentAlignment;
style.FormatString = this.formatString;
style.DataType = this.dataType;
style.RightToLeft = this.RightToLeft;

return style;
}
Expand Down Expand Up @@ -120,9 +121,6 @@ public class BaseTextItem : BaseReportItem,IExportColumnBuilder,IReportExpressio
rectangle,
this.stringTrimming,this.contentAlignment);



//TextDrawer.DrawString(rpea.PrintPageEventArgs.Graphics,toPrint,CreateItemStyle());

rpea.LocationAfterDraw = new Point (this.Location.X + this.Size.Width,
this.Location.Y + this.Size.Height);
Expand Down Expand Up @@ -152,11 +150,6 @@ public string DataType
}


///<summary>
/// Formatstring like in MSDN
/// </summary>



public virtual string FormatString {
get {
Expand Down Expand Up @@ -194,6 +187,9 @@ public string DataType
}
}


public System.Windows.Forms.RightToLeft RightToLeft {get;set;}

#region IExpression

public string Expression {get;set;}
Expand Down
Expand Up @@ -101,10 +101,8 @@ protected ExporterCollection ConvertSection (BaseSection section,int dataRow)
gapCalculator.CalculateGapList(section);
int i = 0;


foreach (BaseReportItem item in section.Items)
{

ISimpleContainer simpleContainer = item as ISimpleContainer;

Offset = new Point(Offset.X,Offset.Y + gapCalculator.GapBetweenItems[i] );
Expand Down
Expand Up @@ -60,12 +60,10 @@ protected void BuildNewPage(ExporterCollection myList,BaseSection section)
protected void FirePageFull (ExporterCollection items)
{
var newPage = new NewPageEventArgs (items,SinglePage.SectionBounds);
// EventHelper.Raise<NewPageEventArgs>(PageFull,this,new NewPageEventArgs(items,SinglePage.SectionBounds));
EventHelper.Raise<NewPageEventArgs>(PageFull,this,newPage);
SinglePage.SectionBounds = newPage.SectionBounds;
}


#endregion


Expand Down
Expand Up @@ -57,10 +57,7 @@ public override ExporterCollection Convert(BaseReportItem parent, BaseReportItem
private ExporterCollection ConvertDataRow (ISimpleContainer simpleContainer)
{
ExporterCollection exporterCollection = new ExporterCollection();
// base.CurrentPosition = base.SectionBounds.DetailArea.Location;

base.CurrentPosition = base.SectionBounds.Offset;
// Console.WriteLine("Convertdatarow start {0}",base.CurrentPosition);
BaseSection section = parent as BaseSection;

DefaultLeftPosition = parent.Location.X;
Expand Down Expand Up @@ -157,22 +154,6 @@ void CheckForPageBreak(BaseSection section, ExporterCollection exporterCollectio
protected override Point ForcePageBreak(ExporterCollection exporterCollection, BaseSection section)
{
base.ForcePageBreak(exporterCollection,section);
return CalculateStartPosition(section);
}


private Point CalculateStartPosition(BaseSection section)
{
// var r = base.ReportModel;
// base.SectionBounds.CalculatePageBounds(r);
// var rr = new Point(base.SectionBounds.DetailArea.X,base.SectionBounds.PageHeaderRectangle.Bottom + 1);
// var p = base.SectionBounds.DetailArea.Location;
// var pp = SectionBounds.Offset;
// Console.WriteLine ("PageBreak {0} - detailareaa {1}",rr,p);
// Console.WriteLine("-----------------");
// Console.WriteLine("");
//// return base.SectionBounds.DetailArea.Location;
// return pp;
return SectionBounds.Offset;
}

Expand Down
Expand Up @@ -75,7 +75,6 @@ protected override void BuildReportHeader ()
base.ReportModel.ReportHeader.Size = Size.Empty;
}
base.SectionBounds.CalculatePageBounds(base.ReportModel);
var p = base.SectionBounds.Offset;
}


Expand All @@ -84,7 +83,6 @@ protected override void BuildPageHeader ()
if (SectionBounds.Offset.Y < base.ReportModel.PageHeader.SectionOffset) {
SectionBounds.Offset = new Point(SectionBounds.Offset.X,base.ReportModel.PageHeader.SectionOffset);
}

base.SectionBounds.CalculatePageBounds(base.ReportModel);
ConvertSectionInternal (base.ReportModel.PageHeader);
}
Expand Down
Expand Up @@ -18,32 +18,22 @@ public interface IGraphicStyleDecorator :IBaseStyleDecorator

public class GraphicStyleDecorator:BaseStyleDecorator,IGraphicStyleDecorator
{
private BaseShape shape;
private int thickness = 1;
private DashStyle dashStyle = DashStyle.Solid;

public GraphicStyleDecorator(BaseShape shape):base()
{
if (shape == null) {
throw new ArgumentNullException("shape");
}
this.shape = shape;
this.Shape = shape;
Thickness = 1;
DashStyle = DashStyle.Solid;
}

public BaseShape Shape {get;set;}

public BaseShape Shape {
get { return shape; }
set { shape = value; }
}

public int Thickness {
get { return thickness; }
set { thickness = value; }
}
public int Thickness {get;set;}

public DashStyle DashStyle {
get { return dashStyle; }
set { dashStyle = value; }
}
public DashStyle DashStyle {get;set;}

}
}
Expand Up @@ -10,7 +10,6 @@ public class LineDecorator : GraphicStyleDecorator, ILineDecorator
{
public LineDecorator(BaseShape shape) : base(shape)
{

}

public Point From { get; set; }
Expand Down
Expand Up @@ -11,65 +11,24 @@ namespace ICSharpCode.Reports.Core.Exporter
/// </summary>
public class TextStyleDecorator:BaseStyleDecorator
{
private Font font;
private StringFormat stringFormat;
private StringTrimming stringTrimming;
private ContentAlignment contentAlignment;
private string dataType;
private string formatString;



public TextStyleDecorator():base()
{
}

public Font Font {get;set;}

public Font Font {
get {
return font;
}
set {
font = value;
}
}
public StringFormat StringFormat {get;set;}

public StringTrimming StringTrimming {get;set;}

public ContentAlignment ContentAlignment {get;set;}


public StringFormat StringFormat {
get {
return stringFormat;
}
set {
stringFormat = value;
}
}

public StringTrimming StringTrimming {
get {
return stringTrimming;
}
set {
stringTrimming = value;
}
}

public ContentAlignment ContentAlignment {
get {
return contentAlignment;
}
set {
contentAlignment = value;
}
}

public string DataType {
get { return dataType; }
set { dataType = value; }
}

public string FormatString {
get { return formatString; }
set { formatString = value; }
}
public string DataType {get;set;}

public string FormatString {get;set;}

public System.Windows.Forms.RightToLeft RightToLeft {get;set;}
}
}
Expand Up @@ -45,6 +45,11 @@ public ExportText (BaseStyleDecorator itemStyle,bool isContainer):base(itemStyle
CalculatePdfFormat pdfFormat = new CalculatePdfFormat(this.StyleDecorator,font);

ColumnText columnText = new ColumnText(contentByte);

if (StyleDecorator.RightToLeft.ToString() == "Yes") {
columnText.RunDirection = PdfWriter.RUN_DIRECTION_RTL;
}

iTextSharp.text.Rectangle r = base.ConvertToPdfRectangle();
columnText.SetSimpleColumn(r.Left, r.Top , r.Left + r.Width,r.Top - r.Height,pdfFormat.Leading,pdfFormat.Alignment);

Expand Down

0 comments on commit bdc54cb

Please sign in to comment.