Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1576 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
82 changed files with 1894 additions and 781 deletions
Binary file not shown.
Binary file not shown.
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Forstmeier Helmut |
||||
* Date: 29.06.2006 |
||||
* Time: 13:02 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
|
||||
using System.Windows.Forms; |
||||
|
||||
using SharpReportCore; |
||||
|
||||
namespace ReportSamples{ |
||||
/// <summary>
|
||||
/// Description of MultipageUnboundPullModel.
|
||||
/// </summary>
|
||||
public class MultiPageUnboundPullModel{ |
||||
int rowNr; |
||||
int rowsPerPage; |
||||
System.DateTime startTime; |
||||
System.DateTime endTime; |
||||
|
||||
public MultiPageUnboundPullModel(){ |
||||
} |
||||
|
||||
public void Run() { |
||||
try{ |
||||
OpenFileDialog dg = new OpenFileDialog(); |
||||
dg.Filter = "SharpReport files|*.srd"; |
||||
dg.Title = "Select a report file: "; |
||||
if (dg.ShowDialog() == DialogResult.OK){ |
||||
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine(); |
||||
mn.SectionRendering += new EventHandler<SectionRenderEventArgs>(MultipagePrinting); |
||||
mn.SectionRendered += new EventHandler<SectionRenderEventArgs>(MultipagePrinted); |
||||
this.startTime = System.DateTime.Now; |
||||
|
||||
mn.PreviewStandartReport(dg.FileName.ToString()); |
||||
} |
||||
} |
||||
catch(Exception er){ |
||||
MessageBox.Show(er.ToString(),"MainForm"); |
||||
} |
||||
} |
||||
|
||||
|
||||
private void MultipagePrinting (object sender,SectionRenderEventArgs e) { |
||||
System.Console.WriteLine("UnboundPullPrinting"); |
||||
CheckItems(e.Section.Items); |
||||
switch (e.CurrentSection) { |
||||
case GlobalEnums.enmSection.ReportHeader: |
||||
System.Console.WriteLine("\tReportHeader"); |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportPageHeader: |
||||
|
||||
System.Console.WriteLine("\tPageheader"); |
||||
System.Console.WriteLine(""); |
||||
this.rowsPerPage = 0; |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportDetail: |
||||
|
||||
this.rowNr ++; |
||||
this.rowsPerPage ++; |
||||
System.Console.WriteLine("\tReportDetail"); |
||||
RowItem ri = e.Section.Items[0] as RowItem; |
||||
if (ri != null) { |
||||
if (this.rowNr %2 == 0) { |
||||
ri.DrawBorder = true; |
||||
} else { |
||||
ri.DrawBorder = false; |
||||
} |
||||
} |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportPageFooter: |
||||
System.Console.WriteLine("\tPageFooter"); |
||||
BaseDataItem bdi = e.Section.Items.Find("ItemsPerPage") as BaseDataItem; |
||||
if (bdi != null) { |
||||
bdi.DbValue = this.rowsPerPage.ToString(); |
||||
} |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportFooter: |
||||
System.Console.WriteLine("\tReportFooter"); |
||||
this.endTime = System.DateTime.Now; |
||||
|
||||
BaseDataItem b = e.Section.Items.Find("reportDbTextItem1")as BaseDataItem; |
||||
if (b != null) { |
||||
b.FormatString = "t"; |
||||
b.DbValue = (this.endTime - this.startTime).ToString(); |
||||
} |
||||
|
||||
break; |
||||
|
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
private void MultipagePrinted (object sender,SectionRenderEventArgs e) { |
||||
// System.Console.WriteLine("---Rendering done <{0}>-----",e.CurrentSection);
|
||||
} |
||||
|
||||
private void CheckItems (ReportItemCollection items) { |
||||
// System.Console.WriteLine("\t<{0}> Items",items.Count );
|
||||
foreach (BaseReportItem i in items) { |
||||
IContainerItem container = i as IContainerItem; |
||||
if (container != null) { |
||||
// System.Console.WriteLine("\t\tContainer found");
|
||||
CheckItems (container.Items); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,98 @@
@@ -0,0 +1,98 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Forstmeier Helmut |
||||
* Date: 29.06.2006 |
||||
* Time: 09:21 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
|
||||
using SharpReportCore; |
||||
namespace ReportSamples |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SimpleUnboundPullModel.
|
||||
/// </summary>
|
||||
public class SimpleUnboundPullModel{ |
||||
int rowNr; |
||||
|
||||
public SimpleUnboundPullModel(){ |
||||
|
||||
} |
||||
public void Run() { |
||||
try{ |
||||
OpenFileDialog dg = new OpenFileDialog(); |
||||
dg.Filter = "SharpReport files|*.srd"; |
||||
dg.Title = "Select a report file: "; |
||||
if (dg.ShowDialog() == DialogResult.OK){ |
||||
SharpReportCore.SharpReportEngine mn = new SharpReportCore.SharpReportEngine(); |
||||
mn.SectionRendering += new EventHandler<SectionRenderEventArgs>(SimplePullPrinting); |
||||
mn.SectionRendered += new EventHandler<SectionRenderEventArgs>(SimplePullPrinted); |
||||
mn.PreviewStandartReport(dg.FileName.ToString()); |
||||
|
||||
} |
||||
} |
||||
catch(Exception er){ |
||||
MessageBox.Show(er.ToString(),"MainForm"); |
||||
} |
||||
} |
||||
private void SimplePullPrinting (object sender,SectionRenderEventArgs e) { |
||||
System.Console.WriteLine("UnboundPullPrinting"); |
||||
CheckItems(e.Section.Items); |
||||
switch (e.CurrentSection) { |
||||
case GlobalEnums.enmSection.ReportHeader: |
||||
System.Console.WriteLine("\tI found the ReportHeader"); |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportPageHeader: |
||||
|
||||
System.Console.WriteLine("\tI found the Pageheader"); |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportDetail: |
||||
System.Console.WriteLine("\tI found the ReportDetail"); |
||||
this.rowNr ++; |
||||
RowItem ri = e.Section.Items[0] as RowItem; |
||||
if (ri != null) { |
||||
if (this.rowNr %2 == 0) { |
||||
ri.DrawBorder = true; |
||||
} else { |
||||
ri.DrawBorder = false; |
||||
} |
||||
} |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportPageFooter: |
||||
System.Console.WriteLine("\tI found the PageFooter"); |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportFooter: |
||||
System.Console.WriteLine("\tI found the ReportFooter"); |
||||
break; |
||||
|
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
private void SimplePullPrinted (object sender,SectionRenderEventArgs e) { |
||||
//// System.Console.WriteLine("MainForm:Rendering done for <{0}>",e.CurrentSection);
|
||||
// System.Console.WriteLine("----------");
|
||||
} |
||||
|
||||
private void CheckItems (ReportItemCollection items) { |
||||
// System.Console.WriteLine("\t<{0}> Items",items.Count );
|
||||
foreach (BaseReportItem i in items) { |
||||
IContainerItem container = i as IContainerItem; |
||||
if (container != null) { |
||||
// System.Console.WriteLine("\t\tContainer found");
|
||||
CheckItems (container.Items); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,129 @@
@@ -0,0 +1,129 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Forstmeier Helmut |
||||
* Date: 10.07.2006 |
||||
* Time: 13:15 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Data; |
||||
using System.Windows.Forms; |
||||
|
||||
using SharpReportCore; |
||||
|
||||
namespace ReportSamples |
||||
{ |
||||
/// <summary>
|
||||
/// Description of UnboundPushModel.
|
||||
/// </summary>
|
||||
public class UnboundPushModel |
||||
{ |
||||
int rowNr; |
||||
|
||||
public UnboundPushModel() |
||||
{ |
||||
} |
||||
|
||||
public void Run() { |
||||
string reportFileName; |
||||
try |
||||
{ |
||||
OpenFileDialog dg = new OpenFileDialog(); |
||||
dg.Filter = "SharpReport files|*.srd"; |
||||
dg.Title = "Select a report file: "; |
||||
if (dg.ShowDialog() == DialogResult.OK){ |
||||
SharpReportCore.SharpReportEngine engine = new SharpReportCore.SharpReportEngine(); |
||||
reportFileName = dg.FileName.ToString(); |
||||
DataTable table = SelectData(); |
||||
|
||||
if (table != null) { |
||||
engine.SectionRendering += new EventHandler<SectionRenderEventArgs>(PushPrinting); |
||||
engine.SectionRendered += new EventHandler<SectionRenderEventArgs>(PushPrinted); |
||||
engine.PreviewPushDataReport(reportFileName,table); |
||||
// engine.PrintPushDataReport(reportFileName,table);
|
||||
} |
||||
} |
||||
} |
||||
catch (Exception){ |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
private DataTable SelectData() |
||||
{ |
||||
OpenFileDialog dg = new OpenFileDialog(); |
||||
dg.Filter = "SharpReport files|*.xsd"; |
||||
dg.Title = "Select a '.xsdfile: "; |
||||
if (dg.ShowDialog() == DialogResult.OK){ |
||||
DataSet ds = new DataSet(); |
||||
ds.ReadXml(dg.FileName); |
||||
return ds.Tables[0]; |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private void PushPrinting (object sender,SectionRenderEventArgs e) { |
||||
System.Console.WriteLine("UnboundPushModel"); |
||||
CheckItems(e.Section.Items); |
||||
switch (e.CurrentSection) { |
||||
case GlobalEnums.enmSection.ReportHeader: |
||||
System.Console.WriteLine("\tReportHeader"); |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportPageHeader: |
||||
|
||||
System.Console.WriteLine("\tPageheader"); |
||||
System.Console.WriteLine(""); |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportDetail: |
||||
|
||||
this.rowNr ++; |
||||
System.Console.WriteLine("\tReportDetail"); |
||||
RowItem ri = e.Section.Items[0] as RowItem; |
||||
if (ri != null) { |
||||
if (this.rowNr %2 == 0) { |
||||
ri.DrawBorder = true; |
||||
} else { |
||||
ri.DrawBorder = false; |
||||
} |
||||
} |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportPageFooter: |
||||
System.Console.WriteLine("\tPageFooter"); |
||||
break; |
||||
|
||||
case GlobalEnums.enmSection.ReportFooter: |
||||
System.Console.WriteLine("\tReportFooter"); |
||||
BaseDataItem b = e.Section.Items.Find("ReportDbTextItem")as BaseDataItem; |
||||
if (b != null) { |
||||
b.DbValue = this.rowNr.ToString(); |
||||
} |
||||
|
||||
break; |
||||
|
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
private void PushPrinted (object sender,SectionRenderEventArgs e) { |
||||
// System.Console.WriteLine("---Rendering done <{0}>-----",e.CurrentSection);
|
||||
} |
||||
|
||||
private void CheckItems (ReportItemCollection items) { |
||||
foreach (BaseReportItem i in items) { |
||||
// System.Console.WriteLine("\tItem {0}",i.Name);
|
||||
IContainerItem container = i as IContainerItem; |
||||
if (container != null) { |
||||
// System.Console.WriteLine("\t\tContainer found");
|
||||
CheckItems (container.Items); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,118 @@
@@ -0,0 +1,118 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Forstmeier Helmut |
||||
* Date: 09.07.2006 |
||||
* Time: 15:39 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
|
||||
using SharpReportCore; |
||||
|
||||
namespace SharpReport.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ReportTableControl.
|
||||
/// </summary>
|
||||
public class ReportTableControl:ContainerControl |
||||
{ |
||||
private RectangleShape shape = new RectangleShape(); |
||||
private bool drawBorder; |
||||
public ReportTableControl() |
||||
{ |
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent(); |
||||
this.SetStyle(ControlStyles.DoubleBuffer | |
||||
ControlStyles.UserPaint | |
||||
ControlStyles.AllPaintingInWmPaint | |
||||
ControlStyles.ResizeRedraw, |
||||
true); |
||||
this.UpdateStyles(); |
||||
int h,w; |
||||
h = GlobalValues.PreferedSize.Height * 3 + 30; |
||||
w = (GlobalValues.PreferedSize.Width * 2) + 10; |
||||
|
||||
// this.Size = new Size(w,h);
|
||||
} |
||||
|
||||
#region overrides
|
||||
protected override void OnPaint(PaintEventArgs pea){ |
||||
|
||||
|
||||
base.OnPaint(pea); |
||||
base.DrawEdges (pea, |
||||
new Rectangle(0,5, |
||||
this.ClientSize.Width - 1,this.ClientSize.Height - 6) ); |
||||
|
||||
ControlHelper.DrawHeadLine(this,pea); |
||||
} |
||||
|
||||
|
||||
|
||||
public override string ToString() { |
||||
|
||||
return this.GetType().Name; |
||||
} |
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public bool DrawBorder { |
||||
set { |
||||
drawBorder = value; |
||||
this.Invalidate(); |
||||
} |
||||
} |
||||
#region FormsDesigner
|
||||
|
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null; |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the control.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent() |
||||
{ |
||||
|
||||
this.SuspendLayout(); |
||||
|
||||
//
|
||||
// ReportTableControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||
|
||||
this.Name = "Table"; |
||||
this.Size = new System.Drawing.Size(200,40); |
||||
this.ResumeLayout(false); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
@ -0,0 +1,158 @@
@@ -0,0 +1,158 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Forstmeier Helmut |
||||
* Date: 09.07.2006 |
||||
* Time: 15:51 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
|
||||
using SharpReport.Designer; |
||||
using SharpReportCore; |
||||
|
||||
namespace SharpReport.ReportItems{ |
||||
/// <summary>
|
||||
/// Description of ReportTableItem.
|
||||
/// </summary>
|
||||
public class ReportTableItem:TableItem ,IDesignable{ |
||||
private ReportTableControl visualControl; |
||||
|
||||
|
||||
#region Constructor
|
||||
public ReportTableItem():this (GlobalValues.UnboundName){ |
||||
|
||||
} |
||||
|
||||
public ReportTableItem (string tableName):base(tableName) { |
||||
Setup(); |
||||
} |
||||
|
||||
private void Setup (){ |
||||
visualControl = new ReportTableControl(); |
||||
// ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this);
|
||||
//
|
||||
this.visualControl.Click += new EventHandler(OnControlSelect); |
||||
this.visualControl.VisualControlChanged += new EventHandler (OnControlChanged); |
||||
this.visualControl.LocationChanged += new EventHandler (OnControlChanged); |
||||
|
||||
|
||||
// //Event from Tracker
|
||||
this.visualControl.PropertyChanged += new PropertyChangedEventHandler (ControlPropertyChange); |
||||
//
|
||||
base.PropertyChanged += new PropertyChangedEventHandler (BasePropertyChange); |
||||
//
|
||||
base.Items.Added += OnAdd; |
||||
base.Items.Removed += OnRemove; |
||||
System.Console.WriteLine("ReporttableItem ctrlName {0}",this.visualControl.Name); |
||||
} |
||||
#endregion
|
||||
|
||||
#region List Handling
|
||||
private void ChildSelected(object sender, EventArgs e){ |
||||
if (Selected != null) |
||||
Selected(sender,e); |
||||
} |
||||
|
||||
private void ChildPropertyChange (object sender, PropertyChangedEventArgs e){ |
||||
if (! base.Suspend) { |
||||
ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); |
||||
this.HandlePropertyChanged(e.PropertyName); |
||||
} |
||||
} |
||||
|
||||
private void OnAdd (object sender, CollectionItemEventArgs<IItemRenderer> e){ |
||||
IDesignable des = e.Item as IDesignable; |
||||
if (des != null) { |
||||
this.visualControl.Controls.Add (des.VisualControl); |
||||
des.Selected += ChildSelected; |
||||
des.PropertyChanged += ChildPropertyChange; |
||||
} |
||||
} |
||||
|
||||
private void OnRemove (object sender, CollectionItemEventArgs<IItemRenderer> e){ |
||||
|
||||
IDesignable des = e.Item as IDesignable; |
||||
if (des != null) { |
||||
this.visualControl.Controls.Remove(des.VisualControl); |
||||
des.Selected -= ChildSelected; |
||||
this.HandlePropertyChanged("OnChildControlRemoved"); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
public override string ToString() { |
||||
return this.GetType().Name; |
||||
} |
||||
#region Events from Control
|
||||
//Tracker
|
||||
|
||||
private void ControlPropertyChange (object sender, PropertyChangedEventArgs e){ |
||||
ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); |
||||
this.HandlePropertyChanged(e.PropertyName); |
||||
} |
||||
|
||||
private void BasePropertyChange (object sender, PropertyChangedEventArgs e){ |
||||
ItemsHelper.UpdateControlFromTextBase (this.visualControl,this); |
||||
this.visualControl.DrawBorder = base.DrawBorder; |
||||
this.HandlePropertyChanged(e.PropertyName); |
||||
} |
||||
|
||||
|
||||
private void OnControlChanged (object sender, EventArgs e) { |
||||
this.SuspendLayout(); |
||||
ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); |
||||
|
||||
this.ResumeLayout(); |
||||
this.HandlePropertyChanged("OnControlChanged"); |
||||
|
||||
} |
||||
|
||||
private void OnAppereanceChanged (object sender, EventArgs e) { |
||||
this.SuspendLayout(); |
||||
ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this); |
||||
this.ResumeLayout(); |
||||
// UpdateChilds();
|
||||
|
||||
this.HandlePropertyChanged("OnControlChanged"); |
||||
} |
||||
|
||||
private void OnControlSelect(object sender, EventArgs e){ |
||||
if (Selected != null) |
||||
System.Console.WriteLine("fire selected"); |
||||
Selected(this,e); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A Property in ReportItem has changed, inform the Designer
|
||||
/// to set the View's 'IsDirtyFlag' to true
|
||||
/// </summary>
|
||||
|
||||
protected void HandlePropertyChanged(string info) { |
||||
if ( !base.Suspend) { |
||||
if (PropertyChanged != null) { |
||||
PropertyChanged (this,new PropertyChangedEventArgs(info)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDesignable
|
||||
|
||||
[System.Xml.Serialization.XmlIgnoreAttribute] |
||||
[Browsable(false)] |
||||
public ReportObjectControlBase VisualControl { |
||||
get { |
||||
return visualControl; |
||||
} |
||||
} |
||||
|
||||
public new event PropertyChangedEventHandler PropertyChanged; |
||||
public event EventHandler <EventArgs> Selected; |
||||
#endregion
|
||||
} |
||||
} |
@ -0,0 +1,81 @@
@@ -0,0 +1,81 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Forstmeier Helmut |
||||
* Date: 27.06.2006 |
||||
* Time: 09:12 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
|
||||
namespace SharpReportCore |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DataType.
|
||||
/// </summary>
|
||||
internal class DataTypeHelper{ |
||||
|
||||
//TODO why not use
|
||||
// TypeCode tc = Type.GetTypeCode( Type.GetType("System.String"));
|
||||
|
||||
internal static TypeCode TypeCodeFromString (string type) { |
||||
TypeCode tc; |
||||
|
||||
if (type == null) { |
||||
type = "System.String"; |
||||
} |
||||
|
||||
if (type.StartsWith("System.")){ |
||||
type = type.Substring(7); |
||||
} |
||||
|
||||
switch (type){ |
||||
case "DateTime": |
||||
tc = TypeCode.DateTime; |
||||
break; |
||||
|
||||
case "Boolean": |
||||
tc = TypeCode.Boolean; |
||||
break; |
||||
|
||||
|
||||
case "String": |
||||
case "Char": |
||||
tc = TypeCode.String; |
||||
break; |
||||
|
||||
case "Decimal": |
||||
tc = TypeCode.Decimal; |
||||
break; |
||||
case "Integer": |
||||
case "Int16": |
||||
case "Int32": |
||||
tc = TypeCode.Int32; |
||||
break; |
||||
case "Float": |
||||
case "Single": |
||||
case "Double": |
||||
tc = TypeCode.Double; |
||||
break; |
||||
|
||||
default: |
||||
tc = TypeCode.Object; |
||||
break; |
||||
} |
||||
return tc; |
||||
} |
||||
|
||||
static internal bool IsNumber(TypeCode tc){ |
||||
|
||||
switch (tc){ |
||||
case TypeCode.Int32: |
||||
case TypeCode.Double: |
||||
case TypeCode.Decimal: |
||||
return true; |
||||
default: // user error
|
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,65 +0,0 @@
@@ -1,65 +0,0 @@
|
||||
|
||||
//
|
||||
/// <remarks>
|
||||
/// created by - Forstmeier Peter
|
||||
/// Peter Forstmeier (Peter.Forstmeier@t-online.de)
|
||||
/// created on - 12.06.2005 18:17:46
|
||||
/// </remarks>
|
||||
|
||||
using System; |
||||
/// <summary>
|
||||
/// This Delegate is used to format the output from TextBased Items
|
||||
/// </summary>
|
||||
namespace SharpReportCore { |
||||
|
||||
public class FormatOutputEventArgs : System.EventArgs { |
||||
|
||||
/// <summary>
|
||||
/// Default constructor - initializes all fields to default values
|
||||
/// </summary>
|
||||
private string format; |
||||
private string valueToFormat; |
||||
private string nullValue; |
||||
private string formatedValue; |
||||
|
||||
public FormatOutputEventArgs() { |
||||
} |
||||
|
||||
public FormatOutputEventArgs(string valueToFormat,string format, string nullValue ) |
||||
{ |
||||
this.format = format; |
||||
this.nullValue = nullValue; |
||||
this.valueToFormat = valueToFormat; |
||||
} |
||||
|
||||
#region Property's
|
||||
public string Format { |
||||
get { |
||||
return format; |
||||
} |
||||
} |
||||
public string NullValue { |
||||
get { |
||||
return nullValue; |
||||
} |
||||
} |
||||
public string ValueToFormat { |
||||
get { |
||||
return valueToFormat; |
||||
} |
||||
} |
||||
|
||||
public string FormatedValue { |
||||
get { |
||||
return formatedValue; |
||||
} |
||||
set { |
||||
formatedValue = value; |
||||
} |
||||
} |
||||
|
||||
|
||||
#endregion
|
||||
|
||||
} |
||||
} |
@ -1,55 +0,0 @@
@@ -1,55 +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; |
||||
|
||||
/// <summary>
|
||||
/// Base Class for all Formatters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// created by - Forstmeier Peter
|
||||
/// created on - 27.03.2005 18:09:29
|
||||
/// </remarks>
|
||||
namespace SharpReportCore { |
||||
public class AbstractFormatter : object { |
||||
|
||||
/// <summary>
|
||||
/// Default constructor - initializes all fields to default values
|
||||
/// </summary>
|
||||
public AbstractFormatter() { |
||||
} |
||||
|
||||
protected bool CheckFormat (string format) { |
||||
if (String.IsNullOrEmpty(format)) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
protected bool CheckValue (string toFormat) { |
||||
if (String.IsNullOrEmpty(toFormat)) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
} |
@ -1,183 +0,0 @@
@@ -1,183 +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.Globalization; |
||||
//using System.Windows.Forms;
|
||||
|
||||
/// <summary>
|
||||
/// This Class handles the formatting of Output Values depending on there
|
||||
/// Type and DbValue
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// created by - Forstmeier Peter
|
||||
/// created on - 30.03.2005 09:14:20
|
||||
/// </remarks>
|
||||
namespace SharpReportCore{ |
||||
public class DefaultFormatter : AbstractFormatter { |
||||
|
||||
|
||||
public DefaultFormatter() { |
||||
} |
||||
|
||||
///<summary>Looks witch formatting Class to use, call the approbiate formatter
|
||||
/// and update the DbValue with the formatted String value
|
||||
/// </summary>
|
||||
///<param name="item">A ReportDataItem</param>
|
||||
///
|
||||
public string FormatItem (BaseDataItem item) { |
||||
|
||||
if (item == null) { |
||||
throw new ArgumentNullException("item"); |
||||
} |
||||
string retValue = String.Empty; |
||||
|
||||
switch (item.DataType) { |
||||
|
||||
case "System.DateTime" : |
||||
retValue = DateValues(item.DbValue,item.FormatString); |
||||
break; |
||||
|
||||
case "System.Int16": |
||||
retValue = IntegerValues ("16",item.DbValue,item.FormatString); |
||||
break; |
||||
|
||||
case "System.Int32" : |
||||
retValue = IntegerValues ("32",item.DbValue,item.FormatString); |
||||
break; |
||||
case "System.Decimal": |
||||
retValue = DecimalValues (item.DbValue,item.FormatString); |
||||
break; |
||||
|
||||
case "System.Boolean": |
||||
retValue = BoolValue (item.DbValue,item.FormatString); |
||||
break; |
||||
default: |
||||
retValue = item.DbValue; |
||||
break; |
||||
} |
||||
return retValue; |
||||
} |
||||
|
||||
public string BoolValue (string toFormat, string format){ |
||||
string str = String.Empty; |
||||
if (base.CheckFormat(format) == true) { |
||||
|
||||
if (base.CheckValue (toFormat)) { |
||||
try { |
||||
bool b = bool.Parse (toFormat); |
||||
str = b.ToString (CultureInfo.CurrentCulture); |
||||
|
||||
} catch (System.FormatException) { |
||||
// string s = String.Format("\tBool Value < {0} > {1}",toFormat,e.Message);
|
||||
// System.Console.WriteLine("\t\t{0}",s);
|
||||
} |
||||
} |
||||
} else { |
||||
str = toFormat; |
||||
} |
||||
return str; |
||||
} |
||||
|
||||
public string IntegerValues(string valueType,string toFormat, string format) { |
||||
string str = String.Empty; |
||||
if (base.CheckFormat(format) == true) { |
||||
if (base.CheckValue (toFormat)) { |
||||
try { |
||||
int number; |
||||
switch (valueType) { |
||||
case "16": |
||||
number = Int16.Parse (toFormat, |
||||
System.Globalization.NumberStyles.Any, |
||||
CultureInfo.CurrentCulture.NumberFormat); |
||||
break; |
||||
case "32" : |
||||
number = Int32.Parse (toFormat, |
||||
System.Globalization.NumberStyles.Any, |
||||
CultureInfo.CurrentCulture.NumberFormat); |
||||
break; |
||||
default: |
||||
throw new ArgumentException("DefaultFormater:IntegerValues Unknown intType "); |
||||
|
||||
} |
||||
str = number.ToString (format,CultureInfo.CurrentCulture); |
||||
|
||||
} catch (System.FormatException) { |
||||
// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message);
|
||||
// System.Console.WriteLine("\t{0}",s);
|
||||
} |
||||
return str; |
||||
} else { |
||||
str = (0.0M).ToString(CultureInfo.CurrentCulture); |
||||
} |
||||
|
||||
} else { |
||||
str = toFormat; |
||||
} |
||||
return str; |
||||
} |
||||
|
||||
public string DecimalValues(string toFormat, string format) { |
||||
string str = String.Empty; |
||||
if (base.CheckFormat(format) == true) { |
||||
|
||||
if (base.CheckValue (toFormat)) { |
||||
try { |
||||
decimal dec = Decimal.Parse(toFormat, |
||||
System.Globalization.NumberStyles.Any, |
||||
CultureInfo.CurrentCulture.NumberFormat); |
||||
str = dec.ToString (format,CultureInfo.CurrentCulture); |
||||
|
||||
} catch (System.FormatException) { |
||||
// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message);
|
||||
// System.Console.WriteLine("\t{0}",s);
|
||||
} |
||||
return str; |
||||
} else { |
||||
str = (0.0M).ToString(CultureInfo.CurrentCulture); |
||||
} |
||||
|
||||
} else { |
||||
str = toFormat; |
||||
} |
||||
return str; |
||||
} |
||||
|
||||
public string DateValues(string toFormat, string format) { |
||||
|
||||
if (base.CheckFormat(format) == true) { |
||||
try { |
||||
DateTime date = DateTime.Parse (toFormat.Trim(), |
||||
CultureInfo.CurrentCulture.DateTimeFormat); |
||||
string str = date.ToString(format, |
||||
DateTimeFormatInfo.CurrentInfo); |
||||
|
||||
return str.Trim(); |
||||
} catch (System.FormatException) { |
||||
// string s = String.Format("< {0} > {1}",toFormat,e.Message);
|
||||
// System.Console.WriteLine("\t\tDateValue {0}",s);
|
||||
} |
||||
} else { |
||||
return toFormat.Trim(); |
||||
} |
||||
return toFormat.Trim(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,140 @@
@@ -0,0 +1,140 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Forstmeier Helmut |
||||
* Date: 30.06.2006 |
||||
* Time: 17:12 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Drawing; |
||||
|
||||
namespace SharpReportCore{ |
||||
/// <summary>
|
||||
/// Description of Page.
|
||||
/// </summary>
|
||||
public class Page{ |
||||
Rectangle reportHeaderRectangle; |
||||
Rectangle pageHeaderRectangle; |
||||
Rectangle detailRectangle; |
||||
Rectangle pageFooterRectangle; |
||||
Rectangle reportFooterRectangle; |
||||
|
||||
bool firstpage; |
||||
|
||||
public Page(bool firstPage){ |
||||
this.firstpage = firstPage; |
||||
} |
||||
|
||||
|
||||
public Rectangle ReportHeaderRectangle { |
||||
get { |
||||
return reportHeaderRectangle; |
||||
} |
||||
set { |
||||
reportHeaderRectangle = value; |
||||
} |
||||
} |
||||
|
||||
public Rectangle PageHeaderRectangle { |
||||
get { |
||||
return pageHeaderRectangle; |
||||
} |
||||
set { |
||||
pageHeaderRectangle = value; |
||||
} |
||||
} |
||||
|
||||
public Rectangle DetailRectangle { |
||||
get { |
||||
return detailRectangle; |
||||
} |
||||
set { |
||||
detailRectangle = value; |
||||
} |
||||
} |
||||
|
||||
|
||||
public Rectangle PageFooterRectangle { |
||||
get { |
||||
return pageFooterRectangle; |
||||
} |
||||
set { |
||||
pageFooterRectangle = value; |
||||
} |
||||
} |
||||
|
||||
public Rectangle ReportFooterRectangle { |
||||
get { |
||||
return reportFooterRectangle; |
||||
} |
||||
set { |
||||
reportFooterRectangle = value; |
||||
} |
||||
} |
||||
|
||||
public Point DetailStart{ |
||||
get { |
||||
return new Point(this.pageHeaderRectangle.Left, |
||||
this.pageHeaderRectangle.Bottom); |
||||
} |
||||
} |
||||
|
||||
public Point DetailEnds{ |
||||
get { |
||||
return new Point(this.pageFooterRectangle.Left,this.pageFooterRectangle.Top); |
||||
} |
||||
} |
||||
/* |
||||
/// <summary>
|
||||
/// Calculates the rectangle wich can be used by Detail
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
protected Rectangle old_DetailRectangle (ReportPageEventArgs rpea) { |
||||
if (rpea == null) { |
||||
throw new ArgumentNullException("rpea"); |
||||
} |
||||
|
||||
sectionInUse = Convert.ToInt16(GlobalEnums.enmSection.ReportDetail, |
||||
CultureInfo.InvariantCulture); |
||||
Rectangle rect = new Rectangle (rpea.PrintPageEventArgs.MarginBounds.Left, |
||||
this.page.DetailStart.Y , |
||||
rpea.PrintPageEventArgs.MarginBounds.Width, |
||||
page.DetailEnds.Y - this.page.DetailStart.Y - (3 * gap)); |
||||
System.Console.WriteLine("Page DetRec {0} base DetRec {1}",page.DetailArea,rect); |
||||
return rect; |
||||
} |
||||
*/ |
||||
/* |
||||
protected int CalculateDrawAreaHeight(ReportPageEventArgs rpea){ |
||||
if (rpea == null) { |
||||
throw new ArgumentNullException("rpea"); |
||||
} |
||||
int to = rpea.PrintPageEventArgs.MarginBounds.Height ; |
||||
if (this.reportDocument.PageNumber == 1){ |
||||
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportHeader,CultureInfo.InvariantCulture)].Size.Height; |
||||
} |
||||
|
||||
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageHeader,CultureInfo.InvariantCulture)].Size.Height; |
||||
|
||||
to -= sections[Convert.ToInt16(GlobalEnums.enmSection.ReportPageFooter,CultureInfo.InvariantCulture)].Size.Height; |
||||
return to; |
||||
} |
||||
*/ |
||||
/// <summary>
|
||||
/// This rectangle starts directly after PageHeader and ends bevore PageFooter
|
||||
/// </summary>
|
||||
public Rectangle DetailArea { |
||||
get { |
||||
return new Rectangle (this.DetailStart.X, |
||||
this.DetailStart.Y, |
||||
this.pageHeaderRectangle.Width, |
||||
(this.pageFooterRectangle.Top -1) - (this.pageHeaderRectangle.Bottom + 1)); |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,158 @@
@@ -0,0 +1,158 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Forstmeier Peter |
||||
* Date: 26.06.2006 |
||||
* Time: 09:42 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Globalization; |
||||
/// <summary>
|
||||
/// This Class handles the formatting of Output Values depending on there
|
||||
/// Type and DbValue
|
||||
/// </summary>
|
||||
namespace SharpReportCore { |
||||
|
||||
public class StandardFormatter : object { |
||||
|
||||
|
||||
public StandardFormatter() { |
||||
} |
||||
|
||||
//TODO why not TypeCode tc = Type.GetTypeCode( Type.GetType(this.dataType));
|
||||
|
||||
public string FormatItem (string valueToFormat,string formatString, |
||||
TypeCode typeCode,string nullValue) { |
||||
string retValue = String.Empty; |
||||
|
||||
if (String.IsNullOrEmpty(formatString)) { |
||||
retValue = valueToFormat; |
||||
return retValue; |
||||
} |
||||
|
||||
switch (typeCode) { |
||||
case TypeCode.Int16: |
||||
case TypeCode.Int32: |
||||
retValue = IntegerValues (valueToFormat,formatString); |
||||
break; |
||||
case TypeCode.DateTime: |
||||
retValue = DateValues(valueToFormat,formatString); |
||||
break; |
||||
case TypeCode.Boolean: |
||||
retValue = BoolValue (valueToFormat,formatString); |
||||
break; |
||||
case TypeCode.Decimal: |
||||
retValue = DecimalValues (valueToFormat,formatString); |
||||
break; |
||||
|
||||
case TypeCode.Double: |
||||
case TypeCode.Single: |
||||
break; |
||||
|
||||
case TypeCode.String: |
||||
case TypeCode.Char: |
||||
retValue = valueToFormat; |
||||
break; |
||||
default: |
||||
retValue = valueToFormat; |
||||
break; |
||||
} |
||||
|
||||
return retValue; |
||||
} |
||||
|
||||
|
||||
///<summary>Looks witch formatting Class to use, call the approbiate formatter
|
||||
/// and update the DbValue with the formatted String value
|
||||
/// </summary>
|
||||
///<param name="item">A ReportDataItem</param>
|
||||
///
|
||||
public string FormatItem (BaseDataItem item) { |
||||
|
||||
if (item == null) { |
||||
throw new ArgumentNullException("item"); |
||||
} |
||||
return FormatItem(item.DbValue,item.FormatString, |
||||
Type.GetTypeCode( Type.GetType(item.DataType)), |
||||
item.NullValue); |
||||
|
||||
} |
||||
|
||||
private string BoolValue (string toFormat, string format){ |
||||
string str = String.Empty; |
||||
try { |
||||
bool b = bool.Parse (toFormat); |
||||
str = b.ToString (CultureInfo.CurrentCulture); |
||||
} catch (System.FormatException) { |
||||
// string s = String.Format("\tBool Value < {0} > {1}",toFormat,e.Message);
|
||||
// System.Console.WriteLine("\t\t{0}",s);
|
||||
} |
||||
return str; |
||||
} |
||||
|
||||
private string IntegerValues(string toFormat, string format) { |
||||
string str = String.Empty; |
||||
if (StandardFormatter.CheckValue (toFormat)) { |
||||
try { |
||||
int number = Int32.Parse (toFormat, |
||||
System.Globalization.NumberStyles.Any, |
||||
CultureInfo.CurrentCulture.NumberFormat); |
||||
|
||||
str = number.ToString (format,CultureInfo.CurrentCulture); |
||||
} catch (System.FormatException) { |
||||
// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message);
|
||||
// System.Console.WriteLine("\t{0}",s);
|
||||
} |
||||
return str; |
||||
} else { |
||||
str = (0.0M).ToString(CultureInfo.CurrentCulture); |
||||
} |
||||
return str; |
||||
} |
||||
|
||||
private string DecimalValues(string toFormat, string format) { |
||||
string str = String.Empty; |
||||
if (StandardFormatter.CheckValue (toFormat)) { |
||||
try { |
||||
decimal dec = Decimal.Parse(toFormat, |
||||
System.Globalization.NumberStyles.Any, |
||||
CultureInfo.CurrentCulture.NumberFormat); |
||||
str = dec.ToString (format,CultureInfo.CurrentCulture); |
||||
|
||||
} catch (System.FormatException) { |
||||
// string s = String.Format("\tDecimalValue < {0} > {1}",toFormat,e.Message);
|
||||
// System.Console.WriteLine("\t{0}",s);
|
||||
} |
||||
return str; |
||||
} else { |
||||
str = (0.0M).ToString(CultureInfo.CurrentCulture); |
||||
} |
||||
return str; |
||||
} |
||||
|
||||
private string DateValues(string toFormat, string format) { |
||||
try { |
||||
DateTime date = DateTime.Parse (toFormat.Trim(), |
||||
CultureInfo.CurrentCulture.DateTimeFormat); |
||||
string str = date.ToString(format, |
||||
DateTimeFormatInfo.CurrentInfo); |
||||
|
||||
return str.Trim(); |
||||
} catch (System.FormatException) { |
||||
// string s = String.Format("< {0} > {1}",toFormat,e.Message);
|
||||
// System.Console.WriteLine("\t\tDateValue {0}",s);
|
||||
} |
||||
|
||||
return toFormat.Trim(); |
||||
} |
||||
|
||||
private static bool CheckValue (string toFormat) { |
||||
if (String.IsNullOrEmpty(toFormat)) { |
||||
return false; |
||||
} |
||||
return true; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue