77 * To change this template use Tools | Options | Coding | Edit Standard Headers.
88 */
99using System ;
10+ using System . Collections . Generic ;
1011using System . Drawing ;
1112using ICSharpCode . Reporting . Factories ;
1213using ICSharpCode . Reporting . Globals ;
@@ -24,7 +25,7 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard
2425 public class ReportGenerator
2526 {
2627 const int gap = 10 ;
27-
28+ const int startLocation = 5 ;
2829 public ReportGenerator ( )
2930 {
3031 ReportModel = ReportModelFactory . Create ( ) ;
@@ -53,6 +54,7 @@ void CreateDataReport(ReportWizardContext context)
5354 {
5455 GenerateBaseSettings ( context ) ;
5556 CreateReportHeader ( context ) ;
57+ CreatePageHeader ( context ) ;
5658 GeneratePushModel ( context ) ;
5759 }
5860
@@ -70,21 +72,16 @@ void GenerateBaseSettings (ReportWizardContext context) {
7072
7173 void GeneratePushModel ( ReportWizardContext context ) {
7274 var pushModelContext = ( PushModelContext ) context . PushModelContext ;
73- var xLocation = 5 ;
7475 foreach ( var element in pushModelContext . Items ) {
7576 var dataItem = new BaseDataItem ( ) {
7677 Name = element . ColumnName ,
7778 Text = element . ColumnName ,
7879 ColumnName = element . ColumnName ,
7980 DataType = element . DataTypeName
8081 } ;
81-
82- var location = new Point ( xLocation , 4 ) ;
83- dataItem . Location = location ;
84- dataItem . Size = GlobalValues . PreferedSize ;
85- xLocation = xLocation + GlobalValues . PreferedSize . Width + gap ;
8682 ReportModel . DetailSection . Items . Add ( dataItem ) ;
8783 }
84+ AdjustItems ( ReportModel . DetailSection . Items , startLocation ) ;
8885 }
8986
9087
@@ -105,10 +102,44 @@ void CreateReportHeader(ReportWizardContext context){
105102 Text = "= Today.Today" ,
106103 Location = new Point ( xLoc , 10 )
107104 } ;
105+
108106 ReportModel . ReportHeader . Items . Add ( dateText ) ;
109107 }
110108
111109
110+ void CreatePageHeader ( ReportWizardContext context )
111+ {
112+ var pushModelContext = ( PushModelContext ) context . PushModelContext ;
113+ foreach ( var element in pushModelContext . Items ) {
114+ var dataItem = new BaseTextItem ( ) {
115+ Name = element . ColumnName ,
116+ Text = element . ColumnName
117+ } ;
118+ ReportModel . PageHeader . Items . Add ( dataItem ) ;
119+ }
120+
121+ AdjustItems ( ReportModel . PageHeader . Items , startLocation ) ;
122+
123+ var line = new BaseLineItem ( ) {
124+ Location = new Point ( 2 , 35 ) ,
125+ FromPoint = new Point ( 1 , 1 ) ,
126+ ToPoint = new Point ( ReportModel . ReportSettings . PrintableWidth ( ) - 10 , 1 ) ,
127+ Size = new Size ( ReportModel . ReportSettings . PrintableWidth ( ) - 5 , 5 )
128+ } ;
129+
130+ ReportModel . PageHeader . Items . Add ( line ) ;
131+
132+ }
133+
134+ void AdjustItems ( List < IPrintableObject > list , int startValue ) {
135+
136+ var xLocation = startValue ;
137+ foreach ( var element in list ) {
138+ element . Location = new Point ( xLocation , 6 ) ;
139+ xLocation = xLocation + GlobalValues . PreferedSize . Width + gap ;
140+ }
141+ }
142+
112143 static bool IsDataReport ( ReportWizardContext context )
113144 {
114145 var poc = ( PageOneContext ) context . PageOneContext ;
0 commit comments