Browse Source

Fixed a problem with Fonts, make some changes from FxCop

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1617 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 19 years ago
parent
commit
62be911f47
  1. 41
      src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs
  2. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs
  3. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs
  4. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs
  5. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs
  6. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs
  7. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs
  8. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs
  9. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  10. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/RectangleShape.cs
  11. 12
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs
  12. 25
      src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs
  13. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/AbstractModelVisitor.cs
  14. 28
      src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlFormReader.cs

41
src/AddIns/Misc/SharpReport/SharpReport/Designer/Report.cs

@ -138,7 +138,7 @@ namespace SharpReport.Designer{
visualFooter.ReportItemsHandling += new ItemDragDropEventHandler (OnAddReportItem); visualFooter.ReportItemsHandling += new ItemDragDropEventHandler (OnAddReportItem);
} }
private Rectangle SectionClientArea (SharpReport.Designer.ReportSectionControlBase ctrl) { private Rectangle SectionClientArea (SharpReport.Designer.ReportSectionControlBase ctrl) {
Rectangle rect = new Rectangle(); Rectangle rect = new Rectangle();
rect.X = ctrl.Location.X; rect.X = ctrl.Location.X;
rect.Y = ctrl.Location.Y + ctrl.Head.Height; rect.Y = ctrl.Location.Y + ctrl.Head.Height;
@ -188,25 +188,26 @@ namespace SharpReport.Designer{
baseReportItem.Name = nameService.CreateName(itemCollection, baseReportItem.Name = nameService.CreateName(itemCollection,
baseReportItem.Name); baseReportItem.Name);
System.Console.WriteLine("\t {0}",baseReportItem.Name); baseReportItem.Font = this.reportSettings.DefaultFont;
System.Console.WriteLine("\tFont in base {0}",baseReportItem.Font.ToString());
System.Console.WriteLine("\t{0}",this.reportSettings.DefaultFont.ToString()); // System.ComponentModel.TypeConverter converter =
// System.ComponentModel.TypeDescriptor.GetConverter( typeof(Font));
System.ComponentModel.TypeConverter converter =
System.ComponentModel.TypeDescriptor.GetConverter( typeof(Font)); // string s1 = (string)converter.ConvertTo((this.reportSettings.DefaultFont),typeof(string));
string s1 = (string)converter.ConvertTo((this.reportSettings.DefaultFont),typeof(string)); // string s2 = converter.ConvertToInvariantString(this.reportSettings.DefaultFont);
string s2 = converter.ConvertToInvariantString(this.reportSettings.DefaultFont); // System.Console.WriteLine("ConvertTo - {0}",s1);
System.Console.WriteLine("{0}",s1); // System.Console.WriteLine("ConvertToInvariantString {0}",s2);
System.Console.WriteLine("{0}",s2);
// Font f1 = (Font)converter.ConvertFromString(s1);
Font f1 = (Font)converter.ConvertFromString(s1); // Font f2 = (Font)converter.ConvertFromInvariantString(s2);
Font f2 = (Font)converter.ConvertFromInvariantString(s2); // Font f3 = new Font (f1, FontStyle.Bold |FontStyle.Underline);
Font f3 = new Font (f1, FontStyle.Bold |FontStyle.Underline); // string s3 = converter.ConvertToInvariantString(f3);
string s3 = converter.ConvertToInvariantString(f3); // System.Console.WriteLine("ConvertToInvariantString {0}",s3);
System.Console.WriteLine("{0}",s3);
System.Console.WriteLine("!!"); // System.Console.WriteLine("!!");
System.Console.WriteLine("{0} / {1}",f1.Name,f2.Size); // System.Console.WriteLine("{0} / {1}",f1.Name,f2.Size);
System.Console.WriteLine("{0} / {1}",f2.Name,f2.Size); // System.Console.WriteLine("{0} / {1}",f2.Name,f2.Size);
if (baseReportItem.Parent == this.selectedSection) { if (baseReportItem.Parent == this.selectedSection) {
baseReportItem.Location = new Point(iddea.ItemAtPoint.X,iddea.ItemAtPoint.Y); baseReportItem.Location = new Point(iddea.ItemAtPoint.X,iddea.ItemAtPoint.Y);
} else { } else {

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

@ -45,10 +45,10 @@ namespace SharpReportCore {
#endregion #endregion
protected string FormatOutput(string valueToFormat,string formatString, protected string FormatOutput(string valueToFormat,string format,
TypeCode typeCode, string nullValue ){ TypeCode typeCode, string nullValue ){
return standartFormatter.FormatItem(valueToFormat,formatString, return standartFormatter.FormatItem(valueToFormat,format,
typeCode,nullValue); typeCode,nullValue);
} }

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

@ -32,6 +32,9 @@ namespace SharpReportCore {
} }
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
base.Render(rpea); base.Render(rpea);
string formattedString = base.FormatOutput(rpea.PageNumber.ToString(CultureInfo.InvariantCulture), string formattedString = base.FormatOutput(rpea.PageNumber.ToString(CultureInfo.InvariantCulture),

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

@ -28,6 +28,9 @@ namespace SharpReportCore {
} }
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
base.Render(rpea); base.Render(rpea);
string f; string f;

3
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs

@ -26,6 +26,9 @@ namespace SharpReportCore {
} }
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
base.Render (rpea); base.Render (rpea);
RectangleF rect = base.DrawingRectangle (this.Size); RectangleF rect = base.DrawingRectangle (this.Size);

3
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs

@ -57,6 +57,9 @@ namespace SharpReportCore {
#region overrides #region overrides
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
base.Render(rpea); base.Render(rpea);
Graphics g = rpea.PrintPageEventArgs.Graphics; Graphics g = rpea.PrintPageEventArgs.Graphics;
if (this.image != null) { if (this.image != null) {

3
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs

@ -29,6 +29,9 @@ namespace SharpReportCore {
} }
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
base.Render (rpea); base.Render (rpea);
RectangleF rect = base.DrawingRectangle (this.Size); RectangleF rect = base.DrawingRectangle (this.Size);
shape.DrawShape (rpea.PrintPageEventArgs.Graphics, shape.DrawShape (rpea.PrintPageEventArgs.Graphics,

3
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs

@ -31,6 +31,9 @@ namespace SharpReportCore {
} }
public override void Render(ReportPageEventArgs rpea) { public override void Render(ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
base.Render(rpea); base.Render(rpea);
RectangleF rect = base.DrawingRectangle (this.Size); RectangleF rect = base.DrawingRectangle (this.Size);

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

@ -208,7 +208,7 @@ namespace SharpReportCore {
protected Rectangle MeasureReportHeader (PrintPageEventArgs ppea) { protected Rectangle MeasureReportHeader (PrintPageEventArgs ppea) {
if (ppea == null) { if (ppea == null) {
throw new ArgumentNullException("rpea"); throw new ArgumentNullException("ppea");
} }
Rectangle rect = new Rectangle(); Rectangle rect = new Rectangle();

4
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/RectangleShape.cs

@ -36,9 +36,9 @@ namespace SharpReportCore {
} }
public override GraphicsPath CreatePath(RectangleF rect){ public override GraphicsPath CreatePath(RectangleF rectangle){
GraphicsPath path1 = new GraphicsPath(); GraphicsPath path1 = new GraphicsPath();
path1.AddRectangle(rect); path1.AddRectangle(rectangle);
return path1; return path1;
} }

12
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Text/StandardFormatter.cs

@ -23,11 +23,11 @@ namespace SharpReportCore {
//TODO why not TypeCode tc = Type.GetTypeCode( Type.GetType(this.dataType)); //TODO why not TypeCode tc = Type.GetTypeCode( Type.GetType(this.dataType));
public string FormatItem (string valueToFormat,string formatString, public string FormatItem (string valueToFormat,string format,
TypeCode typeCode,string nullValue) { TypeCode typeCode,string nullValue) {
string retValue = String.Empty; string retValue = String.Empty;
if (String.IsNullOrEmpty(formatString)) { if (String.IsNullOrEmpty(format)) {
retValue = valueToFormat; retValue = valueToFormat;
return retValue; return retValue;
} }
@ -35,16 +35,16 @@ namespace SharpReportCore {
switch (typeCode) { switch (typeCode) {
case TypeCode.Int16: case TypeCode.Int16:
case TypeCode.Int32: case TypeCode.Int32:
retValue = IntegerValues (valueToFormat,formatString); retValue = IntegerValues (valueToFormat,format);
break; break;
case TypeCode.DateTime: case TypeCode.DateTime:
retValue = DateValues(valueToFormat,formatString); retValue = DateValues(valueToFormat,format);
break; break;
case TypeCode.Boolean: case TypeCode.Boolean:
retValue = BoolValue (valueToFormat,formatString); retValue = BoolValue (valueToFormat,format);
break; break;
case TypeCode.Decimal: case TypeCode.Decimal:
retValue = DecimalValues (valueToFormat,formatString); retValue = DecimalValues (valueToFormat,format);
break; break;
case TypeCode.Double: case TypeCode.Double:

25
src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs

@ -21,18 +21,13 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Drawing.Printing; using System.Drawing.Printing;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Windows.Forms;
using System.Xml; using System.Xml;
using System.Xml.Serialization; using System.Xml.Serialization;
using SharpReportCore;
namespace SharpReportCore{ namespace SharpReportCore{
/// <summary> /// <summary>
/// This class stores all the basic settings of an Report /// This class stores all the basic settings of an Report
@ -256,6 +251,17 @@ namespace SharpReportCore{
XmlIgnoreAttribute xmlIgnoreAttribute = (XmlIgnoreAttribute)attributes[typeof(XmlIgnoreAttribute)]; XmlIgnoreAttribute xmlIgnoreAttribute = (XmlIgnoreAttribute)attributes[typeof(XmlIgnoreAttribute)];
DefaultValueAttribute defaultValue = (DefaultValueAttribute)attributes[typeof(DefaultValueAttribute)]; DefaultValueAttribute defaultValue = (DefaultValueAttribute)attributes[typeof(DefaultValueAttribute)];
//CHeck for
// [XmlAttribute("titleFont")]
//public string TestName {
// XmlAttributeAttribute test = (XmlAttributeAttribute)attributes[typeof(XmlAttributeAttribute)];
// if (test != null) {
//
// System.Windows.Forms.MessageBox.Show (test.AttributeName + "found");
// }
if (xmlIgnoreAttribute == null){ if (xmlIgnoreAttribute == null){
if (p.CanWrite) { if (p.CanWrite) {
if (defaultValue == null) { if (defaultValue == null) {
@ -272,6 +278,7 @@ namespace SharpReportCore{
} }
} }
} }
// System.Windows.Forms.MessageBox.Show("fertig");
} }
@ -641,7 +648,15 @@ namespace SharpReportCore{
#endregion #endregion
#region OutPut Settings #region OutPut Settings
string bla;
[XmlAttributeAttribute("titleFont")]
public string TestName {
get {
return "Name = testName";
}
set { bla = value;}
}
[Category("Output Settings")] [Category("Output Settings")]
public Font DefaultFont { public Font DefaultFont {

3
src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/AbstractModelVisitor.cs

@ -62,6 +62,9 @@ namespace SharpReportCore {
} }
protected XmlNodeList BuildControlList(XmlElement section) { protected XmlNodeList BuildControlList(XmlElement section) {
if (section == null) {
throw new ArgumentNullException("section");
}
return section.SelectNodes (this.nodesQuery); return section.SelectNodes (this.nodesQuery);
} }

28
src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlFormReader.cs

@ -6,16 +6,12 @@
// </file> // </file>
using System; using System;
using System.Drawing.Printing;
using System.Xml;
using System.Collections;
using System.Drawing; using System.Drawing;
using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Windows.Forms;
using System.ComponentModel;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Globalization; using System.Windows.Forms;
using System.Xml;
namespace SharpReportCore { namespace SharpReportCore {
/// <summary> /// <summary>
@ -144,18 +140,22 @@ namespace SharpReportCore {
return Return; return Return;
} }
public static void BuildFontElement (Font font, XmlElement fontElement) { public static void BuildFontElement (Font font, XmlElement fontElement) {
System.ComponentModel.TypeConverter converter =
System.ComponentModel.TypeDescriptor.GetConverter( typeof(Font));
string fontString = converter.ConvertToInvariantString(font);
XmlAttribute att = fontElement.OwnerDocument.CreateAttribute ("value"); XmlAttribute att = fontElement.OwnerDocument.CreateAttribute ("value");
string str = XmlFormReader.TypedValueToString (font,CultureInfo.InvariantCulture).Replace (",",".");
string fontString = str.Replace (';',',');
att.InnerText = fontString; att.InnerText = fontString;
fontElement.Attributes.Append(att); fontElement.Attributes.Append(att);
} }
public static Font MakeFont(string font) { public static Font MakeFont(string font) {
string s = font.Replace(';',','); System.ComponentModel.TypeConverter converter =
return (Font)XmlFormReader.StringToTypedValue(s,typeof(Font),CultureInfo.InstalledUICulture); System.ComponentModel.TypeDescriptor.GetConverter( typeof(Font));
return (Font)converter.ConvertFromInvariantString(font);
} }
/// <summary> /// <summary>
/// Sets a property called propertyName in object <code>o</code> to <code>val</code>. This method performs /// Sets a property called propertyName in object <code>o</code> to <code>val</code>. This method performs
@ -202,8 +202,8 @@ namespace SharpReportCore {
propertyInfo.SetValue(o, Color.FromName(color), null); propertyInfo.SetValue(o, Color.FromName(color), null);
} }
} else if (propertyInfo.PropertyType == typeof(Font)) { } else if (propertyInfo.PropertyType == typeof(Font)) {
Font fnt = (Font)XmlFormReader.StringToTypedValue (value,typeof(Font), Font fnt = XmlFormReader.MakeFont(value);
CultureInfo.InvariantCulture);
if (fnt != null) { if (fnt != null) {
propertyInfo.SetValue(o,fnt,null); propertyInfo.SetValue(o,fnt,null);
} else { } else {

Loading…
Cancel
Save