From d2c4e4c562390d770aeac4ac46fffae4cea392eb Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Tue, 25 Apr 2006 21:01:03 +0000 Subject: [PATCH] Textbased Items now use the same code for ContentAlignment and drawing in the designer and in printing. Better handling of Row Items git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1354 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Designer/SectionControls/ReportSection.cs | 4 +- .../VisualControls/ReportTextControl.cs | 43 +++--- .../ReportItems/TextBased/ItemsHelper.cs | 14 +- .../ReportItems/TextBased/ReportDataItem.cs | 10 +- .../ReportItems/TextBased/ReportTextItem.cs | 31 ++-- .../SharpReport/Visitors/LoadReportVisitor.cs | 9 +- .../SharpReportCore/BaseItems/BaseDataItem.cs | 9 +- .../BaseItems/BaseReportItem.cs | 16 +- .../SharpReportCore/BaseItems/BaseTextItem.cs | 146 ++++++------------ .../SharpReportCore/BaseItems/RowItem.cs | 14 +- .../Printing/Text/TextDrawer.cs | 92 ++++++++++- .../SharpReportCore/ReportSettings.cs | 2 +- .../SharpReportCore/Xml/XmlHelper.cs | 4 +- 13 files changed, 220 insertions(+), 174 deletions(-) diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs index 901971dcbb..9ddf27fb44 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs @@ -248,7 +248,7 @@ namespace SharpReport{ } private void OnItemAddeded(object sender, CollectionItemEventArgs e){ - + SharpReport.Designer.IDesignable iDesignable = e.Item as SharpReport.Designer.IDesignable; if (iDesignable != null) { @@ -259,7 +259,7 @@ namespace SharpReport{ iDesignable.VisualControl.Focus(); iDesignable.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler (OnPropertyChanged); } - } + } } private void OnRemoveTopLevelItem(object sender, CollectionItemEventArgs e){ diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs index af19ca0363..c1b1ca503e 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs @@ -18,7 +18,11 @@ namespace SharpReport.Designer{ /// Description of ReportTextItem. /// internal class ReportTextControl : ReportControlBase{ - StringFormat stringFormat; + + private StringTrimming stringTrimming; + private ContentAlignment contentAlignment; + TextDrawer textDrawer = new TextDrawer(); + public ReportTextControl():base(){ InitializeComponent(); @@ -37,31 +41,31 @@ namespace SharpReport.Designer{ public override string Text{ get { return base.Text; } - set { - base.Text = value; - } + set { base.Text = value;} } - public StringFormat StringFormat{ + + public StringTrimming StringTrimming { set { - if (this.stringFormat != value) { - this.stringFormat = value; - this.Invalidate(); - } + stringTrimming = value; + this.Invalidate(); } } + + public System.Drawing.ContentAlignment ContentAlignment { + set { + this.contentAlignment = 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; - } - + string str; if (String.IsNullOrEmpty(this.Text)) { @@ -70,10 +74,9 @@ namespace SharpReport.Designer{ str = this.Text; } - pea.Graphics.DrawString(str,this.Font, - new SolidBrush(this.ForeColor), - (RectangleF)this.ClientRectangle, - this.stringFormat); + this.textDrawer.DrawString (pea.Graphics,this.Text,this.Font, + new SolidBrush(this.ForeColor),(RectangleF)this.ClientRectangle, + this.stringTrimming,this.contentAlignment); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs index b5e4aceaef..468da15ed0 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs @@ -20,10 +20,10 @@ namespace SharpReport { /// created by - Forstmeier Peter /// created on - 31.08.2005 13:49:47 /// - public class ItemsHelper : object { + internal class ItemsHelper : object { - public static void UpdateBaseFromTextControl (ReportObjectControlBase control, + internal static void UpdateBaseFromTextControl (ReportObjectControlBase control, BaseReportItem item) { item.Size = control.Size; @@ -32,9 +32,10 @@ namespace SharpReport { item.BackColor = control.BackColor; item.ForeColor = control.ForeColor; item.Font = control.Font; + } - public static void UpdateBaseFromGraphicControl (AbstractGraphicControl control, + internal static void UpdateBaseFromGraphicControl (AbstractGraphicControl control, BaseGraphicItem item) { ItemsHelper.UpdateBaseFromTextControl (control,item); @@ -43,7 +44,7 @@ namespace SharpReport { } - public static void UpdateControlFromTextBase (ReportObjectControlBase control, + internal static void UpdateControlFromTextBase (ReportObjectControlBase control, BaseReportItem item) { control.BackColor = item.BackColor; @@ -53,13 +54,10 @@ namespace SharpReport { control.Font = item.Font; control.Name = item.Name; BaseTextItem b = item as BaseTextItem; -// if (b != null) { -// control. = b.StringAlignment; -// } } - public static void UpdateControlFromGraphicBase (AbstractGraphicControl control, + internal static void UpdateControlFromGraphicBase (AbstractGraphicControl control, BaseGraphicItem item) { ItemsHelper.UpdateControlFromTextBase(control,item); control.Location = item.Location; diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs index 7a0ef28e1c..e7256275dc 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportDataItem.cs @@ -38,9 +38,12 @@ namespace SharpReport.ReportItems{ visualControl = new ReportDbTextControl(); this.visualControl.Text = base.ColumnName; - visualControl.StringFormat = base.StringFormat; + this.Text = base.ColumnName; + visualControl.ContentAlignment = base.ContentAlignment; + visualControl.StringTrimming = base.StringTrimming; + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); this.visualControl.Click += new EventHandler(OnControlSelect); @@ -65,7 +68,10 @@ namespace SharpReport.ReportItems{ private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); - this.visualControl.StringFormat = base.StringFormat; + + this.visualControl.ContentAlignment = base.ContentAlignment; + this.visualControl.StringTrimming = base.StringTrimming; + this.HandlePropertyChanged(e.PropertyName); } diff --git a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs index 414b6bca24..95a54029e1 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs @@ -32,16 +32,17 @@ namespace SharpReport.ReportItems { visualControl = new ReportTextControl(); this.Text = visualControl.Name; - visualControl.StringFormat = base.StringFormat; - ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + visualControl.ContentAlignment = base.ContentAlignment; + visualControl.StringTrimming = base.StringTrimming; + ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); + this.visualControl.Click += new EventHandler(OnControlSelect); this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); this.visualControl.BackColorChanged += new EventHandler (OnControlChanged); this.visualControl.FontChanged += new EventHandler (OnControlChanged); this.visualControl.ForeColorChanged += new EventHandler (OnControlChanged); - base.PropertyChanged += new PropertyChangedEventHandler (BasePropertyChange); } @@ -49,11 +50,14 @@ namespace SharpReport.ReportItems { #endregion - #region events + private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ ItemsHelper.UpdateControlFromTextBase(this.visualControl,this); - this.visualControl.StringFormat = base.StringFormat; + + this.visualControl.ContentAlignment = base.ContentAlignment; + this.visualControl.StringTrimming = base.StringTrimming; + this.HandlePropertyChanged(e.PropertyName); } @@ -86,20 +90,7 @@ namespace SharpReport.ReportItems { } #endregion - - public override Size Size { - get { - return base.Size; - } - set { - base.Size = value; - if (this.visualControl != null) { - this.visualControl.Size = value; - } - this.HandlePropertyChanged("Size"); - } - } - + public override Point Location { get { return base.Location; @@ -142,7 +133,7 @@ namespace SharpReport.ReportItems { this.HandlePropertyChanged("Text"); } } - + #region IDesignable [System.Xml.Serialization.XmlIgnoreAttribute] diff --git a/src/AddIns/Misc/SharpReport/SharpReport/Visitors/LoadReportVisitor.cs b/src/AddIns/Misc/SharpReport/SharpReport/Visitors/LoadReportVisitor.cs index a78dba8a06..05d19a65e7 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/Visitors/LoadReportVisitor.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/Visitors/LoadReportVisitor.cs @@ -115,7 +115,10 @@ namespace SharpReport.Visitors { itemRenderer = designableFactory.Create(ctrlElem.GetAttribute("type")); baseReportItem = (BaseReportItem)itemRenderer; - + + baseReportItem.SuspendLayout(); + XmlHelper.SetReportItemValues (base.XmlFormReader,ctrlElem,baseReportItem); + if (parentContainer == null) { baseReportItem.Parent = baseSection; baseSection.Items.Add (baseReportItem); @@ -124,9 +127,7 @@ namespace SharpReport.Visitors { parentContainer.Items.Add(baseReportItem); } - - XmlHelper.SetReportItemValues (base.XmlFormReader,ctrlElem,baseReportItem); - + baseReportItem.ResumeLayout(); IContainerItem iContainer = baseReportItem as IContainerItem; if (iContainer != null) { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs index 75f44f3372..c38f2a0983 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs @@ -66,11 +66,10 @@ namespace SharpReportCore { // this.DbValue is formatted in the BeforePrintEvent catched in AbstractRenderer string toPrint = CheckForNullValue(); - string formattedString = base.FireFormatOutput(toPrint,this.FormatString,""); - - RectangleF rect = base.PrepareRectangle (rpea,formattedString); - base.PrintTheStuff (rpea,formattedString,rect); - base.NotiyfyAfterPrint (rpea.LocationAfterDraw); + + base.Text = base.FireFormatOutput(toPrint,this.FormatString,""); + base.Render (rpea); + } public override string ToString() { diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs index e342b97d8a..fd9992fc38 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs @@ -60,14 +60,17 @@ namespace SharpReportCore { #endregion #region EventHandling + protected void NotiyfyAfterPrint (PointF afterPrintLocation) { +// System.Console.WriteLine("\tNotiyfyAfterPrint"); if (this.ItemPrinted != null) { AfterPrintEventArgs rea = new AfterPrintEventArgs (afterPrintLocation); ItemPrinted(this, rea); } } - protected void NotifyBeforePrint () { + private void NotifyBeforePrint () { +// System.Console.WriteLine("\tNotifyBeforePrint"); if (this.ItemPrinting != null) { BeforePrintEventArgs ea = new BeforePrintEventArgs (); ItemPrinting (this,ea); @@ -75,6 +78,15 @@ namespace SharpReportCore { } #endregion + + #region overrides + public override void Render(ReportPageEventArgs rpea){ + base.Render(rpea); + this.NotifyBeforePrint(); + } + + #endregion + #region virtual method's protected RectangleF DrawingRectangle (ReportPageEventArgs e,SizeF measureSize) { @@ -145,7 +157,7 @@ namespace SharpReportCore { NotifyPropertyChanged ("Font"); } } - + #endregion #region IDisposeable diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs index 0ff7465971..b800ff6343 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs @@ -32,6 +32,7 @@ namespace SharpReportCore { private ContentAlignment contentAlignment; #region Constructor + public BaseTextItem():base() { this.stringFormat = StringFormat.GenericTypographic; this.contentAlignment = ContentAlignment.MiddleLeft; @@ -40,85 +41,19 @@ namespace SharpReportCore { #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"); } + base.Render(rpea); RectangleF rect = PrepareRectangle (rpea,this.Text); + FillBackGround (rpea.PrintPageEventArgs.Graphics, + rect); + DrawFrame (rpea.PrintPageEventArgs.Graphics, + Rectangle.Ceiling (rect)); PrintTheStuff (rpea,this.Text,rect); base.NotiyfyAfterPrint (rpea.LocationAfterDraw); } @@ -127,22 +62,29 @@ namespace SharpReportCore { return "BaseTextItem"; } - private void Decorate (ReportPageEventArgs rpea,Rectangle border) { + protected void FillBackGround (Graphics graphics,RectangleF rectangle) { using (SolidBrush brush = new SolidBrush(base.BackColor)) { - rpea.PrintPageEventArgs.Graphics.FillRectangle(brush,border); + graphics.FillRectangle(brush,rectangle); } + } + + protected void DrawFrame (Graphics graphics,Rectangle border) { if (base.DrawBorder == true) { using (Pen pen = new Pen(Color.Black, 1)) { - rpea.PrintPageEventArgs.Graphics.DrawRectangle (pen,border); + graphics.DrawRectangle (pen,border); } + //TODO use this class to draw a border +// RectangleShape shape = new RectangleShape(); +// shape.DrawShape (graphics, +// new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1), +// border); } } - protected RectangleF PrepareRectangle (ReportPageEventArgs e,string text) { + protected RectangleF PrepareRectangle (ReportPageEventArgs rpea,string text) { SizeF measureSize = new SizeF (); - measureSize = MeasureReportItem (e,text); - RectangleF rect = base.DrawingRectangle (e,measureSize); - Decorate (e,System.Drawing.Rectangle.Ceiling (rect)); + measureSize = MeasureReportItem (rpea,text); + RectangleF rect = base.DrawingRectangle (rpea,measureSize); return rect; } @@ -172,20 +114,31 @@ namespace SharpReportCore { RectangleF rectangle ) { if (rpea == null) { - throw new ArgumentException (this.Name); + throw new ArgumentNullException("rpea"); } - StringFormat fmt = this.stringFormat; + textDrawer.DrawString(rpea.PrintPageEventArgs.Graphics, - toPrint, - this.Font, + toPrint,this.Font, new SolidBrush(this.ForeColor), rectangle, - fmt); - - rpea.LocationAfterDraw = new PointF (this.Location.X + this.Size.Width, + this.stringTrimming,this.contentAlignment); + + + rpea.LocationAfterDraw = new PointF (this.Location.X + this.Size.Width, this.Location.Y + this.Size.Height); } + + public virtual string Text { + get { + return text; + } + set { + text = value; + base.NotifyPropertyChanged("Text"); + } + } + /// /// Formatstring like in MSDN /// @@ -204,20 +157,8 @@ namespace SharpReportCore { } - public virtual string Text { - get { - return text; - } - set { - text = value; - base.NotifyPropertyChanged("Text"); - } - } - - - [Category("Appearance")] - public StringTrimming StringTrimming { + public StringTrimming StringTrimming { get { return stringTrimming; } @@ -237,12 +178,13 @@ namespace SharpReportCore { base.NotifyPropertyChanged("ContentAlignment"); } } - + [Browsable(false)] [XmlIgnoreAttribute] - public StringFormat StringFormat { + public virtual StringFormat StringFormat { get { - return this.BuildStringFormat(); + return this.textDrawer.BuildStringFormat (this.StringTrimming, + this.ContentAlignment); } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs index 7239901b55..859a45318a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs @@ -23,7 +23,7 @@ namespace SharpReportCore{ private ReportItemCollection items; private Padding padding; - private Color secondaryBackColor; + private Color alternateBackColor; private int changeBackColorEveryNRow; public RowItem():this (String.Empty){ @@ -64,7 +64,8 @@ namespace SharpReportCore{ if (rpea == null) { throw new ArgumentNullException("rpea"); } - + System.Console.WriteLine(""); + System.Console.WriteLine("--Start Row Item"); base.Render(rpea); RectangleF rect = PrepareRectangle (rpea); @@ -79,7 +80,8 @@ namespace SharpReportCore{ childItem.Render (rpea); childItem.Location = new Point(loc.X,loc.Y); } - + System.Console.WriteLine("--End of RowItem"); + System.Console.WriteLine(""); base.NotiyfyAfterPrint (rpea.LocationAfterDraw); } @@ -96,12 +98,12 @@ namespace SharpReportCore{ [Category("Appearance"), Description("Change the Backcolor on every 'N' Row")] - public Color SecondaryBackColor { + public Color AlternateBackColor { get { - return this.secondaryBackColor; + return this.alternateBackColor; } set { - this.secondaryBackColor = value; + this.alternateBackColor = value; base.NotifyPropertyChanged("SecondaryBackColor"); } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs index 56eab54358..11cfa921b4 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/TextDrawer.cs @@ -38,12 +38,102 @@ namespace SharpReportCore { } - public void DrawString(Graphics graphics,string text,Font font,Brush brush,RectangleF rectangle,StringFormat stringFormat) { + public void DrawString(Graphics graphics,string text, + Font font,Brush brush, + RectangleF rectangle, + StringFormat stringFormat) { + graphics.DrawString(text, font, brush, rectangle, stringFormat); } + + + public void DrawString(Graphics graphics,string text, + Font font,Brush brush, + RectangleF rectangle, + StringTrimming stringTrimming, + ContentAlignment alignment) { + + StringFormat s = BuildStringFormat(stringTrimming,alignment); + this.DrawString(graphics,text, + font,brush, + rectangle, + s); + } + + + public StringFormat BuildStringFormat(StringTrimming stringTrimming,ContentAlignment alignment){ + StringFormat format = StringFormat.GenericTypographic; + format.Trimming = stringTrimming; + format.FormatFlags = StringFormatFlags.LineLimit; + +// if (base.RightToLeft) +// { +// format1.FormatFlags |= StringFormatFlags.DirectionRightToLeft; +// } + + 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; + } } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs index 676762d638..4d35219e5a 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs @@ -48,7 +48,7 @@ namespace SharpReportCore{ private System.Data.CommandType commandType; private Font defaultFont = new Font("Microsoft Sans Serif", - 16, + 10, FontStyle.Regular, GraphicsUnit.Point); diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs index 751fbfa4e0..a1634f9aa2 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs @@ -121,6 +121,7 @@ namespace SharpReportCore { XmlElement ctrlElem, BaseReportItem item) { + item.SuspendLayout(); try { XmlNodeList nodeList = ctrlElem.ChildNodes; foreach (XmlNode node in nodeList) { @@ -130,7 +131,6 @@ namespace SharpReportCore { if (elem.Name == "Font") { item.Font = XmlFormReader.MakeFont (elem.GetAttribute("value")); } - reader.SetValue (item, elem.Name,elem.GetAttribute("value")); } @@ -138,6 +138,8 @@ namespace SharpReportCore { } } catch (Exception) { throw; + } finally { + item.ResumeLayout(); } } }