Browse Source

Small changes from FxCop, modifid ConnectionObject.cs

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1125 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 20 years ago
parent
commit
c247d4b9a4
  1. 74
      src/AddIns/Misc/SharpReport/SharpReport/Designer/Ruler/ctrlRuler.cs
  2. 4
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs
  3. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs
  4. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs
  5. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs
  6. 25
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BasePageNumber.cs
  7. 14
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Functions/BaseToday.cs
  8. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseCircleItem.cs
  9. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseLineItem.cs
  10. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs
  11. 17
      src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs
  12. 52
      src/AddIns/Misc/SharpReport/SharpReportCore/ConnectionObject.cs
  13. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupComparer.cs
  14. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/SortComparer.cs
  15. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/ExtendedPropertyDescriptor.cs
  16. 10
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/SharpArrayList.cs
  17. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/Factories/BaseItemFactory.cs
  18. 16
      src/AddIns/Misc/SharpReport/SharpReportCore/Factories/DisplayNameAttribute.cs
  19. 18
      src/AddIns/Misc/SharpReport/SharpReportCore/Factories/RendererFactory.cs
  20. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Factories/SectionFactory.cs
  21. 48
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  22. 10
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/EllipseShape.cs
  23. 7
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/LineShape.cs
  24. 14
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/RectangleShape.cs
  25. 66
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/PrintingUtilities.cs
  26. 14
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  27. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj
  28. 27
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs
  29. 16
      src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs

74
src/AddIns/Misc/SharpReport/SharpReport/Designer/Ruler/ctrlRuler.cs

@ -111,25 +111,20 @@ namespace Ruler @@ -111,25 +111,20 @@ namespace Ruler
endValue = paperSize.Height;
}
try {
int i = 0;
int drawPos = 0;
while (i < this.Height) {
drawPos = i * bigStep;
g.DrawString ((i + start).ToString(),this.Font,brush,3,drawPos);
Line (g,pen,0,drawPos,bLine,drawPos);
Line (g,pen,
0,drawPos - smallStep,
sLine,drawPos - smallStep);
i ++;
}
} catch (Exception e) {
MessageBox.Show (e.Message);
} finally {
pen.Dispose();
brush.Dispose();
int i = 0;
int drawPos = 0;
while (i < this.Height) {
drawPos = i * bigStep;
g.DrawString ((i + start).ToString(),this.Font,brush,3,drawPos);
Line (g,pen,0,drawPos,bLine,drawPos);
Line (g,pen,
0,drawPos - smallStep,
sLine,drawPos - smallStep);
i ++;
}
pen.Dispose();
brush.Dispose();
}
void PaintHorizontal (Graphics g){
@ -166,38 +161,29 @@ namespace Ruler @@ -166,38 +161,29 @@ namespace Ruler
g.DrawRectangle (pen,0,0,(this.Width - 1) * size.Width,(this.Height - 1) * size.Width);
}
try {
int i = 0;
int drawPos = 0;
while (i < (int)((endValue / 10) + 1)) {
drawPos = i * bigStep;
g.DrawString ((i + start).ToString(),this.Font,brush,drawPos,sLine);
Line (g,pen,drawPos,0,i * bigStep,bLine);
Line (g,pen,drawPos - smallStep,0,drawPos - smallStep,sLine);
i ++;
}
// MarginMarker
if (leftMargin > 0) {
int i = 0;
int drawPos = 0;
while (i < (int)((endValue / 10) + 1)) {
drawPos = i * bigStep;
g.DrawString ((i + start).ToString(),this.Font,brush,drawPos,sLine);
Line (g,pen,drawPos,0,i * bigStep,bLine);
Line (g,pen,drawPos - smallStep,0,drawPos - smallStep,sLine);
i ++;
}
// MarginMarker
if (leftMargin > 0) {
// g.DrawString ("L",this.Font,brush,leftMargin * size.Width,sLine);
// Line (g,
// (int)(leftMargin * size.Width),0,
// (int)(leftMargin * size.Width),bLine);
Line (g,
(int)(leftMargin),0,
(int)(leftMargin),bLine);
}
// if (rightMargin > 0) {
// g.DrawString ("R",font,brush,leftMargin * size.Width,sLine);
// }
} catch (Exception e) {
MessageBox.Show (e.Message);
} finally {
pen.Dispose();
brush.Dispose();
Line (g,
(int)(leftMargin),0,
(int)(leftMargin),bLine);
}
pen.Dispose();
brush.Dispose();
}
#endregion

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

@ -51,9 +51,7 @@ namespace SharpReport.ReportItems.Functions { @@ -51,9 +51,7 @@ namespace SharpReport.ReportItems.Functions {
GrapFromBase();
this.initDone = true;
}
private void tt (object sender, PropertyChangedEventArgs e) {
}
private void GrapFromBase() {
this.visualControl.SuspendLayout();
visualControl.StringFormat = base.StandartStringFormat;

8
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseDataItem.cs

@ -43,12 +43,12 @@ namespace SharpReportCore { @@ -43,12 +43,12 @@ namespace SharpReportCore {
this.columnName = columnName;
}
public override void Render(SharpReportCore.ReportPageEventArgs e) {
public override void Render(SharpReportCore.ReportPageEventArgs rpea) {
// this.DbValue is formatted in the BeforePrintEvent catched in AbstractRenderer
string formattedString = base.FireFormatOutput(this.dbValue,this.FormatString,"");
RectangleF rect = base.PrepareRectangle (e,formattedString);
base.PrintTheStuff (e,formattedString,rect);
base.NotiyfyAfterPrint (e.LocationAfterDraw);
RectangleF rect = base.PrepareRectangle (rpea,formattedString);
base.PrintTheStuff (rpea,formattedString,rect);
base.NotiyfyAfterPrint (rpea.LocationAfterDraw);
}
public override string ToString() {

8
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseFunction.cs

@ -31,9 +31,15 @@ namespace SharpReportCore { @@ -31,9 +31,15 @@ namespace SharpReportCore {
this.localisedName = friendlyName;
}
public override string ToString()
{
return "BaseFunction";
}
#region properties
public virtual string LocalisedName {
public string LocalisedName {
get {
return localisedName;
}

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

@ -34,7 +34,7 @@ namespace SharpReportCore { @@ -34,7 +34,7 @@ namespace SharpReportCore {
private bool canShrink ;
private bool pageBreakBefore;
private bool pageBreakAfter;
private bool suspend = true;
private bool suspend;
private Size size;
private Point location;
@ -51,7 +51,7 @@ namespace SharpReportCore { @@ -51,7 +51,7 @@ namespace SharpReportCore {
#endregion
public BaseReportObject() {
suspend = false;
}

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

@ -30,41 +30,32 @@ namespace SharpReportCore { @@ -30,41 +30,32 @@ namespace SharpReportCore {
}
public override void Render(ReportPageEventArgs e) {
base.Render(e);
public override void Render(ReportPageEventArgs rpea) {
base.Render(rpea);
string formattedString = base.FireFormatOutput(e.PageNumber.ToString(CultureInfo.InvariantCulture),
string formattedString = base.FireFormatOutput(rpea.PageNumber.ToString(CultureInfo.InvariantCulture),
base.FormatString,"");
RectangleF rect = base.PrepareRectangle (e,formattedString);
RectangleF rect = base.PrepareRectangle (rpea,formattedString);
//Printout the textpart
base.PrintTheStuff (e,this.Text,rect);
base.PrintTheStuff (rpea,this.Text,rect);
//here we print the functionpart
StringFormat fmt = StandartStringFormat;
fmt.Alignment = StringAlignment.Far;
fmt.LineAlignment = StringAlignment.Near;
e.PrintPageEventArgs.Graphics.DrawString(e.PageNumber.ToString(CultureInfo.InvariantCulture),
rpea.PrintPageEventArgs.Graphics.DrawString(rpea.PageNumber.ToString(CultureInfo.InvariantCulture),
this.Font,
Brushes.Black,
rect,
fmt);
base.NotiyfyAfterPrint (e.LocationAfterDraw);
base.NotiyfyAfterPrint (rpea.LocationAfterDraw);
}
public override string ToString() {
return "PageNumber";
return "BasePageNumber";
}
public override string LocalisedName {
get {
return base.LocalisedName;
}
}
}
}

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

@ -26,33 +26,33 @@ namespace SharpReportCore { @@ -26,33 +26,33 @@ namespace SharpReportCore {
}
public override void Render(ReportPageEventArgs e) {
base.Render(e);
public override void Render(ReportPageEventArgs rpea) {
base.Render(rpea);
string formattedString = FormatAsDate(System.DateTime.Now.ToString(),base.FormatString);
RectangleF rect = base.PrepareRectangle (e,formattedString);
RectangleF rect = base.PrepareRectangle (rpea,formattedString);
//Printout the textPart
base.PrintTheStuff (e,this.Text,rect);
base.PrintTheStuff (rpea,this.Text,rect);
//here we print the functionpart allway's with Stringalignment.Far
StringFormat fmt = StandartStringFormat;
fmt.Alignment = StringAlignment.Far;
fmt.LineAlignment = StringAlignment.Near;
e.PrintPageEventArgs.Graphics.DrawString(formattedString,
rpea.PrintPageEventArgs.Graphics.DrawString(formattedString,
this.Font,
Brushes.Black,
rect,
fmt);
// goon
base.NotiyfyAfterPrint (e.LocationAfterDraw);
base.NotiyfyAfterPrint (rpea.LocationAfterDraw);
}
public override string ToString() {
return "Today";
return "BaseToday";
}

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

@ -27,7 +27,6 @@ namespace SharpReportCore { @@ -27,7 +27,6 @@ namespace SharpReportCore {
public override void Render(ReportPageEventArgs rpea) {
base.Render (rpea);
SizeF measureSize = base.MeasureReportItem (rpea,this);
RectangleF rect = base.DrawingRectangle (rpea,this.Size);
shape.FillShape(rpea.PrintPageEventArgs.Graphics,

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

@ -30,7 +30,6 @@ namespace SharpReportCore { @@ -30,7 +30,6 @@ namespace SharpReportCore {
public override void Render(ReportPageEventArgs rpea) {
base.Render (rpea);
SizeF measureSize = base.MeasureReportItem (rpea,this);
RectangleF rect = base.DrawingRectangle (rpea,this.Size);
shape.DrawShape (rpea.PrintPageEventArgs.Graphics,
new BaseLine (this.ForeColor,base.DashStyle,base.Thickness),

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

@ -34,7 +34,6 @@ namespace SharpReportCore { @@ -34,7 +34,6 @@ namespace SharpReportCore {
public override void Render(ReportPageEventArgs rpea) {
base.Render(rpea);
SizeF measureSize = base.MeasureReportItem (rpea,this);
RectangleF rect = base.DrawingRectangle (rpea,this.Size);
shape.FillShape(rpea.PrintPageEventArgs.Graphics,

17
src/AddIns/Misc/SharpReport/SharpReportCore/Collections/Collections.cs

@ -36,21 +36,21 @@ namespace SharpReportCore{ @@ -36,21 +36,21 @@ namespace SharpReportCore{
/// (Line by Line)
/// </summary>
public class LocationSorter : IComparer<IItemRenderer> {
public int Compare(IItemRenderer left, IItemRenderer right){
if (left == null){
if (right == null){
public int Compare(IItemRenderer x, IItemRenderer y){
if (x == null){
if (y == null){
return 0;
}
return -1;
}
if (right == null){
if (y == null){
return 1;
}
if (left.Location.Y == right.Location.Y){
return left.Location.X - right.Location.X;
if (x.Location.Y == y.Location.Y){
return x.Location.X - y.Location.X;
}
return left.Location.Y - right.Location.Y;
return x.Location.Y - y.Location.Y;
}
}
@ -68,9 +68,6 @@ namespace SharpReportCore{ @@ -68,9 +68,6 @@ namespace SharpReportCore{
public void SortByLocation () {
if (this.Count > 1) {
this.Sort(new LocationSorter());
for (int i = 0;i < this.Count ; i ++) {
IItemRenderer col = this[i];
}
}
}

52
src/AddIns/Misc/SharpReport/SharpReportCore/ConnectionObject.cs

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
//------------------------------------------------------------------------------
using System;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
/// <summary>
@ -22,64 +23,39 @@ using System.Data.OleDb; @@ -22,64 +23,39 @@ using System.Data.OleDb;
namespace SharpReportCore {
public class ConnectionObject : object,IDisposable {
IDbConnection connection;
string password;
string username;
OleDbConnectionStringBuilder oleDbConnectionStringBuilder;
string connectionString;
public ConnectionObject(string connectionString):this(connectionString,"","") {
}
public ConnectionObject(string connectionString, string password, string username)
{
public ConnectionObject(string connectionString) {
if (String.IsNullOrEmpty(connectionString)) {
throw new ArgumentNullException("connectionString");
}
this.connectionString = connectionString;
this.password = password;
this.username = username;
this.connection = new OleDbConnection (this.connectionString);
}
public ConnectionObject(IDbConnection connection, string password, string username)
{
public ConnectionObject( OleDbConnectionStringBuilder oleDbConnectionStringBuilder){
this.oleDbConnectionStringBuilder = oleDbConnectionStringBuilder;
try {
this.connection = new OleDbConnection (this.oleDbConnectionStringBuilder.ConnectionString);
} catch (Exception ) {
throw;
}
}
public ConnectionObject(IDbConnection connection){
this.connection = connection;
this.password = password;
this.username = username;
this.connectionString = this.connection.ConnectionString;
}
public IDbConnection Connection {
get {
return connection;
}
set {
connection = value;
}
}
public string Password {
get {
return password;
}
set {
password = value;
}
}
public string Username {
get {
return username;
}
set {
username = value;
}
}
// public string ConnectionString {
// get {
// return connectionString;
// }
// }
public void Dispose(){
if (this.connection != null) {
if (this.connection.State == ConnectionState.Open) {

6
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupComparer.cs

@ -92,9 +92,9 @@ namespace SharpReportCore { @@ -92,9 +92,9 @@ namespace SharpReportCore {
public override int CompareTo(object value) {
base.CompareTo(value);
return this.CompareTo((GroupComparer)value);
public override int CompareTo(object obj) {
base.CompareTo(obj);
return this.CompareTo((GroupComparer)obj);
}

6
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/SortComparer.cs

@ -83,9 +83,9 @@ namespace SharpReportCore { @@ -83,9 +83,9 @@ namespace SharpReportCore {
// Gleich Werte, dann Index bercksichtigen
return this.ListIndex.CompareTo(value.ListIndex);
}
public override int CompareTo(object value) {
base.CompareTo(value);
return this.CompareTo((SortComparer)value);
public override int CompareTo(object obj) {
base.CompareTo(obj);
return this.CompareTo((SortComparer)obj);
}

3
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/ExtendedPropertyDescriptor.cs

@ -8,7 +8,7 @@ namespace SharpReportCore { @@ -8,7 +8,7 @@ namespace SharpReportCore {
/// This class supports data binding
/// </summary>
public class SharpPropertyDescriptor : PropertyDescriptor{
bool readOnly = false;
bool readOnly;
Type componentType;
Type propertyType;
PropertyInfo prop;
@ -18,6 +18,7 @@ namespace SharpReportCore { @@ -18,6 +18,7 @@ namespace SharpReportCore {
{
this.componentType = componentType;
this.propertyType = propertyType;
this.readOnly= false;
}

10
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/SharpArrayList.cs

@ -225,20 +225,20 @@ namespace SharpReportCore @@ -225,20 +225,20 @@ namespace SharpReportCore
#endregion
#region overrides
public override int Add(object val) {
if (this.elementType.GetType().IsAssignableFrom (val.GetType())) {
public override int Add(object value) {
if (this.elementType.GetType().IsAssignableFrom (value.GetType())) {
System.Console.WriteLine("type ok");
}
if ((val.GetType().IsSubclassOf(this.elementType))||( val.GetType() == this.elementType)){
if ((value.GetType().IsSubclassOf(this.elementType))||( value.GetType() == this.elementType)){
if (this.allowNew) {
int i = base.Add(val);
int i = base.Add(value);
this.OnListChange (new ListChangedEventArgs(ListChangedType.ItemAdded,i));
return i;
} else {
throw new NotSupportedException("SharpArrayList:Add(object)");
}
} else {
string str = String.Format("Add:Wrong Type {0} {1}",this.elementType,val.GetType());
string str = String.Format("Add:Wrong Type {0} {1}",this.elementType,value.GetType());
throw new ArgumentException(str);
}
}

3
src/AddIns/Misc/SharpReport/SharpReportCore/Factories/BaseItemFactory.cs

@ -33,7 +33,8 @@ namespace SharpReportCore { @@ -33,7 +33,8 @@ namespace SharpReportCore {
}
public new BaseReportItem Create (string name){
if (String.IsNullOrEmpty(name)) {
throw new ArgumentNullException("name");
String str = String.Format("<{0}>",name);
throw new UnkownItemException(str);
}
if (name.LastIndexOf('.') > 0) {
StringBuilder b = new StringBuilder (name);

16
src/AddIns/Misc/SharpReport/SharpReportCore/Factories/DisplayNameAttribute.cs

@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
using System;
namespace SharpReportCore
{
public class DisplayNameAttribute : Attribute
{
namespace SharpReportCore{
public sealed class DisplayNameAttribute : Attribute{
string name;
public string Name
{
public string Name{
get { return name; }
}
public DisplayNameAttribute(string name)
{
public DisplayNameAttribute(string name){
this.name = name;
}
}

18
src/AddIns/Misc/SharpReport/SharpReportCore/Factories/RendererFactory.cs

@ -32,15 +32,17 @@ namespace SharpReportCore { @@ -32,15 +32,17 @@ namespace SharpReportCore {
typeof (AbstractRenderer)){
}
public AbstractRenderer Create(ReportModel model,DataManager container) {
switch (model.ReportSettings.ReportType) {
case GlobalEnums.enmReportType.FormSheet :{
return new RenderFormSheetReport(model);
}
case GlobalEnums.enmReportType.DataReport:{
return new RenderDataReport(model,container);
}
if (model != null) {
switch (model.ReportSettings.ReportType) {
case GlobalEnums.enmReportType.FormSheet :{
return new RenderFormSheetReport(model);
}
case GlobalEnums.enmReportType.DataReport:{
return new RenderDataReport(model,container);
}
}
}
return null;
throw new MissingModelException();
}
}
}

4
src/AddIns/Misc/SharpReport/SharpReportCore/Factories/SectionFactory.cs

@ -27,6 +27,10 @@ namespace SharpReportCore { @@ -27,6 +27,10 @@ namespace SharpReportCore {
}
public new BaseSection Create(string name) {
if (String.IsNullOrEmpty(name)) {
String str = String.Format("<{0}>",name);
throw new UnkownItemException(str);
}
return new BaseSection(name);
}

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

@ -55,6 +55,9 @@ namespace SharpReportCore { @@ -55,6 +55,9 @@ namespace SharpReportCore {
protected AbstractRenderer(ReportModel model){
if (model == null) {
throw new MissingModelException();
}
this.reportSettings = model.ReportSettings;
this.sections = model.SectionCollection;
Init();
@ -86,16 +89,18 @@ namespace SharpReportCore { @@ -86,16 +89,18 @@ namespace SharpReportCore {
protected int CalculateDrawAreaHeight(ReportPageEventArgs rpea){
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
int to = rpea.PrintPageEventArgs.MarginBounds.Height ;
if (rpea.PageNumber ==1) {
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,CultureInfo.InvariantCulture)].Size.Height;
}
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader)].Size.Height;
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,CultureInfo.InvariantCulture)].Size.Height;
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter)].Size.Height;
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,CultureInfo.InvariantCulture)].Size.Height;
return to;
}
@ -103,7 +108,13 @@ namespace SharpReportCore { @@ -103,7 +108,13 @@ namespace SharpReportCore {
/// Use this function to draw controlling rectangles
/// </summary>
protected void DebugRectangle (ReportPageEventArgs e,Rectangle rect) {
protected void DebugRectangle (ReportPageEventArgs rpea,Rectangle rectangle) {
// if (rpea == null) {
// throw new ArgumentNullException("rpea");
// }
// if (rectangle == null) {
// throw new ArgumentNullException("rectangle");
// }
// e.PrintPageEventArgs.Graphics.DrawRectangle (Pens.Black,rect);
}
@ -203,25 +214,35 @@ namespace SharpReportCore { @@ -203,25 +214,35 @@ namespace SharpReportCore {
// Called by FormatOutPutEvent of the BaseReportItem
void FormatBaseReportItem (object sender, FormatOutputEventArgs e) {
if (sender is BaseDataItem) {
BaseDataItem i = (BaseDataItem)sender;
e.FormatedValue = defaultFormatter.FormatItem (i);
void FormatBaseReportItem (object sender, FormatOutputEventArgs rpea) {
BaseDataItem baseDataItem = sender as BaseDataItem;
if (baseDataItem != null) {
rpea.FormatedValue = defaultFormatter.FormatItem (baseDataItem);
}
// if (sender is BaseDataItem) {
// BaseDataItem i = (BaseDataItem)sender;
// e.FormatedValue = defaultFormatter.FormatItem (i);
// }
}
#region privates
protected void FitSectionToItems (BaseSection section,ReportPageEventArgs e){
Rectangle orgRect = new Rectangle (e.PrintPageEventArgs.MarginBounds.Left,
protected void FitSectionToItems (BaseSection section,ReportPageEventArgs rpea){
if (section == null) {
throw new ArgumentNullException("section");
}
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
Rectangle orgRect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left,
section.SectionOffset,
e.PrintPageEventArgs.MarginBounds.Width,
rpea.PrintPageEventArgs.MarginBounds.Width,
section.Size.Height);
if ((section.CanGrow == true)||(section.CanShrink == true)) {
AdjustSection (section,e);
AdjustSection (section,rpea);
} else {
AdjustItems (section,e);
AdjustItems (section,rpea);
}
}
@ -393,6 +414,7 @@ namespace SharpReportCore { @@ -393,6 +414,7 @@ namespace SharpReportCore {
}
}
#endregion
#region IDispoable
public void Dispose(){
if (this.reportDocument != null) {

10
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/EllipseShape.cs

@ -37,18 +37,18 @@ namespace SharpReportCore { @@ -37,18 +37,18 @@ namespace SharpReportCore {
}
public override void DrawShape(Graphics g, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(g,baseLine,rectangle);
public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle;
g.DrawEllipse(p,
graphics.DrawEllipse(p,
rectangle);
}
}
public override void FillShape(Graphics g, AbstractFillPattern fillPattern, RectangleF rectangle) {
g.FillEllipse(fillPattern.Brush,
public override void FillShape(Graphics graphics, AbstractFillPattern fillPattern, RectangleF rectangle) {
graphics.FillEllipse(fillPattern.Brush,
rectangle);
}

7
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/LineShape.cs

@ -38,13 +38,13 @@ namespace SharpReportCore { @@ -38,13 +38,13 @@ namespace SharpReportCore {
public LineShape() {
}
public override void DrawShape(Graphics g, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(g,baseLine,rectangle);
public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle;
float halfRect = rectangle.Top + (rectangle.Height / 2);
g.DrawLine (p,
graphics.DrawLine (p,
rectangle.X,
halfRect,
rectangle.X + rectangle.Width,
@ -52,5 +52,6 @@ namespace SharpReportCore { @@ -52,5 +52,6 @@ namespace SharpReportCore {
}
}
}
}

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

@ -35,24 +35,24 @@ namespace SharpReportCore { @@ -35,24 +35,24 @@ namespace SharpReportCore {
}
public override void DrawShape(Graphics g, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(g,baseLine,rectangle);
public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle;
g.DrawRectangle (p,rectangle.Left,
graphics.DrawRectangle (p,rectangle.Left,
rectangle.Top,
rectangle.Width,
rectangle.Height);
}
}
public override void FillShape(Graphics g, AbstractFillPattern fillPattern, RectangleF rectangle) {
g.FillRectangle(fillPattern.Brush,
public override void FillShape(Graphics graphics, AbstractFillPattern fillPattern, RectangleF rectangle) {
graphics.FillRectangle(fillPattern.Brush,
rectangle);
}
public override void FillShape(Graphics g, Brush brush, RectangleF rectangle) {
g.FillRectangle(brush, rectangle);
public override void FillShape(Graphics graphics, Brush brush, RectangleF rectangle) {
graphics.FillRectangle(brush, rectangle);
}

66
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/PrintingUtilities.cs

@ -1,66 +0,0 @@ @@ -1,66 +0,0 @@
//
// SharpDevelop ReportEditor
//
// Copyright (C) 2005 Peter Forstmeier
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Peter Forstmeier (Peter.Forstmeier@t-online.de)
using System;
using System.Drawing;
/// <summary>
/// Utility Class to help with printing
/// </summary>
/// <remarks>
/// created by - Forstmeier Peter
/// created on - 26.03.2005 10:08:23
/// </remarks>
namespace SharpReportCore {
public class a_PrintingUtilities : object {
/// <summary>
/// Measure the Size of the String
/// </summary>
/// <param name="item">ReportItem to Measure</param>
/// <param name="e">ReportPageEventArgs</param>
/// <returns>SizeF</returns>
public static System.Drawing.SizeF a_MeasureReportItem(IItemRenderer item,
ReportPageEventArgs e) {
SizeF sizeF = new SizeF ();
BaseTextItem myItem = item as BaseTextItem;
if (myItem != null) {
string str = String.Empty;
if (item is BaseTextItem) {
BaseTextItem it = item as BaseTextItem;
str = it.Text;
} else if(item is BaseDataItem) {
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());
} else {
sizeF = new SizeF (item.Size.Width,item.Size.Height);
}
return sizeF;
}
}
}

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

@ -68,19 +68,21 @@ namespace SharpReportCore { @@ -68,19 +68,21 @@ namespace SharpReportCore {
}
}
protected override void BeginPrintPage(object sender, ReportPageEventArgs e) {
base.BeginPrintPage (sender,e);
protected override void BeginPrintPage(object sender, ReportPageEventArgs rpea) {
if (rpea == null) {
throw new ArgumentNullException("rpea");
}
base.BeginPrintPage (sender,rpea);
//Draw ReportHeader
currentPoint = base.DrawReportHeader (e);
currentPoint = base.DrawReportHeader (rpea);
if (base.CurrentSection.PageBreakAfter) {
base.PageBreak(e,base.CurrentSection);
base.PageBreak(rpea,base.CurrentSection);
base.CurrentSection.PageBreakAfter = false;
return;
}
//Draw Pageheader
currentPoint = base.DrawPageheader (currentPoint,e);
currentPoint = base.DrawPageheader (currentPoint,rpea);
base.DetailStart = new Point ((int)currentPoint.X,(int)currentPoint.Y);
}

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

@ -102,7 +102,6 @@ @@ -102,7 +102,6 @@
<Compile Include="Printing\Text\TextDrawer.cs" />
<Compile Include="Printing\AbstractRenderer.cs" />
<Compile Include="Printing\FormatOutputEventArgs.cs" />
<Compile Include="Printing\PrintingUtilities.cs" />
<Compile Include="Printing\RenderDataReport.cs" />
<Compile Include="Printing\RenderFormSheetReport.cs" />
<Compile Include="Printing\ReportDocument.cs" />

27
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs

@ -59,7 +59,7 @@ namespace SharpReportCore { @@ -59,7 +59,7 @@ namespace SharpReportCore {
if (this.connectionObject == null) {
if (model.ReportSettings.ConnectionString != "") {
this.connectionObject = new ConnectionObject (model.ReportSettings.ConnectionString,"","");
this.connectionObject = new ConnectionObject (model.ReportSettings.ConnectionString);
}
if (reportParameters != null) {
@ -113,8 +113,11 @@ namespace SharpReportCore { @@ -113,8 +113,11 @@ namespace SharpReportCore {
private void ApplyReportParameters (ReportModel model,ReportParameters parameters){
if ((model == null)||(parameters == null )){
throw new ArgumentNullException("SharpReportEngine:ApplyReportParameters");
if (model == null) {
throw new MissingModelException();
}
if (parameters == null ){
throw new ArgumentNullException("parameters");
}
SetSqlParameters (model,parameters.SqlParameters);
@ -152,8 +155,8 @@ namespace SharpReportCore { @@ -152,8 +155,8 @@ namespace SharpReportCore {
}
}
catch (System.Data.OleDb.OleDbException e) {
throw e;
catch (System.Data.OleDb.OleDbException) {
throw ;
}
catch (Exception) {
throw;
@ -261,7 +264,7 @@ namespace SharpReportCore { @@ -261,7 +264,7 @@ namespace SharpReportCore {
protected AbstractRenderer AbstractRenderer (ReportModel model) {
if (model == null) {
throw new ArgumentNullException("PrintableDocument:ReportModel");
throw new MissingModelException();
}
AbstractRenderer abstr = SetupStandartRenderer(model);
return abstr;
@ -274,8 +277,8 @@ namespace SharpReportCore { @@ -274,8 +277,8 @@ namespace SharpReportCore {
/// this is an easy way to ask the report for desired paramaters</see></summary>
public ReportParameters LoadParameters (string fileName) {
if (fileName.Length == 0) {
throw new ArgumentNullException("PreviewPushDataReport FileName");
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
ReportModel model = null;
try {
@ -304,7 +307,7 @@ namespace SharpReportCore { @@ -304,7 +307,7 @@ namespace SharpReportCore {
public void PreviewStandartReport (string fileName) {
if (fileName.Length == 0) {
throw new ArgumentNullException("PreviewPushDataReport FileName");
throw new ArgumentNullException("fileName");
}
PreviewStandartReport (fileName,null);
}
@ -312,7 +315,7 @@ namespace SharpReportCore { @@ -312,7 +315,7 @@ namespace SharpReportCore {
public void PreviewStandartReport (string fileName,ReportParameters reportParameters) {
if (fileName.Length == 0) {
throw new ArgumentNullException("PreviewPushDataReport:FileName");
throw new ArgumentNullException("fileName");
}
ReportModel model = null;
@ -373,7 +376,7 @@ namespace SharpReportCore { @@ -373,7 +376,7 @@ namespace SharpReportCore {
doc = renderer.ReportDocument;
using (PrintDialog dlg = new PrintDialog()) {
dlg.Document = doc;
MessageBox.Show (model.ReportSettings.UseStandartPrinter.ToString());
// MessageBox.Show (model.ReportSettings.UseStandartPrinter.ToString());
if (model.ReportSettings.UseStandartPrinter == true) {
dlg.Document.Print();
} else {
@ -497,7 +500,7 @@ namespace SharpReportCore { @@ -497,7 +500,7 @@ namespace SharpReportCore {
/// <returns><see cref="ReportModel"></see></returns>
protected ReportModel ModelFromFile (string fileName) {
if (fileName.Length == 0) {
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}

16
src/AddIns/Misc/SharpReport/SharpReportCore/Visitors/LoadModelVisitor.cs

@ -38,21 +38,21 @@ namespace SharpReportCore { @@ -38,21 +38,21 @@ namespace SharpReportCore {
#region overrides
public override void Visit(ReportModel model) {
if (model != null) {
public override void Visit(ReportModel reportModel) {
if (reportModel == null) {
throw new MissingModelException();
} else {
XmlDocument xmlDoc;
try {
xmlDoc = XmlHelper.OpenSharpReport (fileName);
xmlFormReader = new XmlFormReader();
model.ReportSettings.SetSettings ((XmlElement)xmlDoc.DocumentElement.FirstChild);
reportModel.ReportSettings.SetSettings ((XmlElement)xmlDoc.DocumentElement.FirstChild);
SetSections (xmlDoc);
} catch (Exception ) {
throw;
}
} else {
System.ArgumentNullException e = new System.ArgumentNullException ("LoadModelVisitor:Visit -> No valid Model");
throw e;
}
}
#endregion
@ -87,8 +87,8 @@ namespace SharpReportCore { @@ -87,8 +87,8 @@ namespace SharpReportCore {
rpt.Visible = true;
rpt.ResumeLayout();
} else {
UnkownItemException e = new UnkownItemException();
throw e;
String str = String.Format("< {0}>",ctrlElem.GetAttribute("basetype"));
throw new UnkownItemException(str);
}
} catch (Exception ) {
throw;

Loading…
Cancel
Save