Permalink
Browse files

RightToLeft

  • Loading branch information...
1 parent a59bb8e commit bdc54cbf1155daf069ecc4ba7b1dcb0b5797f0db @PeterForstmeier PeterForstmeier committed Jun 29, 2011
@@ -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,
@@ -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;
@@ -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 {
@@ -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")]
@@ -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
}
@@ -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());
}
}
@@ -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;
@@ -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;
@@ -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;
}
@@ -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);
@@ -152,11 +150,6 @@ public string DataType
}
- ///<summary>
- /// Formatstring like in MSDN
- /// </summary>
-
-
public virtual string FormatString {
get {
@@ -194,6 +187,9 @@ public string DataType
}
}
+
+ public System.Windows.Forms.RightToLeft RightToLeft {get;set;}
+
#region IExpression
public string Expression {get;set;}
@@ -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] );
@@ -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
@@ -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;
@@ -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;
}
@@ -75,7 +75,6 @@ protected override void BuildReportHeader ()
base.ReportModel.ReportHeader.Size = Size.Empty;
}
base.SectionBounds.CalculatePageBounds(base.ReportModel);
- var p = base.SectionBounds.Offset;
}
@@ -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);
}
@@ -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;}
+
}
}
@@ -10,7 +10,6 @@ public class LineDecorator : GraphicStyleDecorator, ILineDecorator
{
public LineDecorator(BaseShape shape) : base(shape)
{
-
}
public Point From { get; set; }
@@ -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;}
}
}
@@ -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);

0 comments on commit bdc54cb

Please sign in to comment.