diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj index 1ce89393f1..54a2e871b9 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj @@ -85,9 +85,7 @@ - - @@ -151,10 +149,12 @@ + + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs index bbfaa03bc8..9e29c61bee 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs @@ -13,6 +13,7 @@ using System.Globalization; using System.Linq; using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.Items; namespace ICSharpCode.Reporting { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs index eafeae7519..62acc59581 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs @@ -6,12 +6,10 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.Globalization; using System.Linq; using ICSharpCode.Reporting.BaseClasses; using ICSharpCode.Reporting.DataSource; -using ICSharpCode.Reporting.DataSource.Comparer; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Data; using ICSharpCode.Reporting.Items; @@ -21,11 +19,12 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling /// /// Description of DataSource. /// - enum OrderGroup { + public enum OrderGroup { AsIs, Sorted, Grouped } + public class CollectionDataSource:IDataSource { @@ -34,8 +33,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling readonly ReportSettings reportSettings; readonly Type elementType; readonly PropertyDescriptorCollection listProperties; - OrderGroup orderGroup; - +// OrderGroup orderGroup; + public CollectionDataSource(IEnumerable list, ReportSettings reportSettings) { if (list == null) @@ -47,7 +46,7 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling this.reportSettings = reportSettings; this.listProperties = this.baseList.GetItemProperties(null); - orderGroup = OrderGroup.AsIs; + OrderGroup = OrderGroup.AsIs; } @@ -67,7 +66,7 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling this.reportSettings = reportSettings; this.listProperties = this.baseList.GetItemProperties(null); - orderGroup = OrderGroup.AsIs; + OrderGroup = OrderGroup.AsIs; } @@ -94,6 +93,10 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling public object Current {get; private set;} + public OrderGroup OrderGroup {get; private set;} + + + public IGrouping CurrentKey {get; private set; } #region Sort @@ -101,10 +104,10 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling { if (reportSettings.SortColumnsCollection.Count > 0) { var sorted = SortInternal(); - orderGroup = OrderGroup.Sorted; + OrderGroup = OrderGroup.Sorted; listEnumerator = sorted.GetEnumerator(); } else { - orderGroup = OrderGroup.AsIs; + OrderGroup = OrderGroup.AsIs; listEnumerator = baseList.GetEnumerator(); } listEnumerator.MoveNext(); @@ -129,10 +132,11 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling void Group() { - orderGroup = OrderGroup.Grouped; + OrderGroup = OrderGroup.Grouped; groupedList = GroupInternal(); groupEnumerator = groupedList.GetEnumerator(); groupEnumerator.MoveNext(); + CurrentKey = groupEnumerator.Current; listEnumerator = groupEnumerator.Current.GetEnumerator(); listEnumerator.MoveNext(); Current = listEnumerator.Current; @@ -140,7 +144,7 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling IEnumerable> GroupInternal () { - var property = listProperties.Find(reportSettings.GroupColumnCollection[0].ColumnName,true); + var property = listProperties.Find(reportSettings.GroupColumnsCollection[0].ColumnName,true); var sortProperty = listProperties.Find("Randomint",true); var groupedList = baseList.OrderBy(o => o.GetType().GetProperty(sortProperty.Name).GetValue(o, null) ) @@ -152,7 +156,7 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling public void Bind() { - if (reportSettings.GroupColumnCollection.Any()) { + if (reportSettings.GroupColumnsCollection.Any()) { Group(); } else { Sort(); @@ -173,8 +177,6 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling if (container != null) { FillFromList(container.Items); } else { - - //FillFromList(collection); FillInternal(element); } } @@ -218,9 +220,10 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling { var canMove = listEnumerator.MoveNext(); - if (orderGroup == OrderGroup.Grouped) { + if (OrderGroup == OrderGroup.Grouped) { if (! canMove) { var groupCanMove = groupEnumerator.MoveNext(); + CurrentKey = groupEnumerator.Current; if (groupCanMove) { listEnumerator = groupEnumerator.Current.GetEnumerator(); canMove = listEnumerator.MoveNext(); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs index d32cf61ac7..e589775a92 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs @@ -12,6 +12,7 @@ using System.ComponentModel; using System.Globalization; using ICSharpCode.Reporting.BaseClasses; +using ICSharpCode.Reporting.Items; namespace ICSharpCode.Reporting.DataSource.Comparer { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataSource.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataSource.cs index a8047dfb8b..db0b3c9211 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataSource.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataSource.cs @@ -10,6 +10,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; using ICSharpCode.Reporting.BaseClasses; using ICSharpCode.Reporting.DataManager.Listhandling; @@ -30,5 +31,8 @@ namespace ICSharpCode.Reporting.Interfaces.Data int Count {get;} object Current {get;} + OrderGroup OrderGroup {get;} + IGrouping CurrentKey {get;} + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs index 72e46962aa..33c45f5f5b 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseRowItem.cs @@ -13,4 +13,11 @@ namespace ICSharpCode.Reporting.Items { } } + + public class GroupHeader :BaseRowItem + { + public GroupHeader() { + Console.WriteLine("init groupHeader"); + } + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/GroupColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs similarity index 94% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/GroupColumn.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs index 708f69a922..faebba5d74 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/GroupColumn.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/GroupColumn.cs @@ -9,7 +9,7 @@ using System; using System.ComponentModel; -namespace ICSharpCode.Reporting.BaseClasses +namespace ICSharpCode.Reporting.Items { /// /// Description of GroupColumn. diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs index 43389cafe6..23d9a1491a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportSettings.cs @@ -51,7 +51,7 @@ namespace ICSharpCode.Reporting.Items // this.availableFields = new AvailableFieldsCollection(); // this.groupingsCollection = new GroupColumnCollection(); this.SortColumnsCollection = new SortColumnCollection(); - GroupColumnCollection = new GroupColumnCollection(); + this.GroupColumnsCollection = new GroupColumnCollection(); // this.sqlParameters = new SqlParameterCollection(); ParameterCollection = new ParameterCollection(); // this.NoDataMessage = "No Data for this Report"; @@ -141,10 +141,11 @@ namespace ICSharpCode.Reporting.Items // [Category("Parameters")] // [EditorAttribute ( typeof(ParameterCollectionEditor), // typeof(System.Drawing.Design.UITypeEditor) )] + public ParameterCollection ParameterCollection {get; private set;} public SortColumnCollection SortColumnsCollection {get;private set;} - public GroupColumnCollection GroupColumnCollection {get;private set;} + public GroupColumnCollection GroupColumnsCollection {get;private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/SortColumn.cs similarity index 92% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/SortColumn.cs index 5b8ebae577..cdb9fe3815 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/SortColumn.cs @@ -8,8 +8,9 @@ */ using System; using System.ComponentModel; +using ICSharpCode.Reporting.BaseClasses; -namespace ICSharpCode.Reporting.BaseClasses +namespace ICSharpCode.Reporting.Items { /// /// Description of SortColumn. diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs index 6db1975750..4bb3ee782a 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs @@ -51,43 +51,40 @@ namespace ICSharpCode.Reporting.PageBuilder void BuildDetail() { + Console.WriteLine("DatapageBuilder"); var exportRows = new List(); var converter = new ContainerConverter(base.Graphics, CurrentLocation); var position = DetailStart; - + CurrentSection = ReportModel.DetailSection; - +// Console.WriteLine("Report -grouping {0} ",DataSource.OrderGroup.ToString()); +// Console.WriteLine ("groupkey {0}",DataSource.CurrentKey); if(DataSourceContainsData()) { CurrentLocation = DetailStart; - + if (! IsGrouped()) { + Console.WriteLine("report is not grouped"); + } else { + Console.WriteLine("report is grouped"); + } do { var row = CreateContainerForSection(CurrentPage,position); - DataSource.Fill(CurrentSection.Items); var convertedItems = converter.CreateConvertedList(ReportModel.DetailSection.Items); converter.SetParent(row,convertedItems); - MeasureAndArrangeContainer(row); - if (PageFull(row)) { InsertExportRows(exportRows); - MeasureAndArrangeContainer(row); exportRows.Clear(); - CurrentPage.PageInfo.PageNumber = Pages.Count + 1; - Pages.Add(CurrentPage); - - position = ResetPosition(); - CurrentPage = CreateNewPage(); - WriteStandardSections(); - CurrentLocation = DetailStart; - + PerformPageBreak(); position = DetailStart; row.Location = position; } + MeasureAndArrangeContainer(row); + row.ExportedItems.AddRange(convertedItems); exportRows.Add(row); position = new Point(CurrentSection.Location.X,position.Y + row.DesiredSize.Height + 1); @@ -98,6 +95,23 @@ namespace ICSharpCode.Reporting.PageBuilder } } + void PerformPageBreak() + { + CurrentPage.PageInfo.PageNumber = Pages.Count + 1; + Pages.Add(CurrentPage); + CurrentPage = CreateNewPage(); + WriteStandardSections(); + CurrentLocation = DetailStart; + ResetPosition(); + } + + + + bool IsGrouped() + { + return DataSource.OrderGroup == OrderGroup.Grouped; + } + void CreateDataSource() { @@ -116,6 +130,7 @@ namespace ICSharpCode.Reporting.PageBuilder } + Point ResetPosition () { return new Point(DetailStart.X,1); } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/ModelLoader.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/ModelLoader.cs index 35308c8f1d..d0a7da21bc 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/ModelLoader.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/ModelLoader.cs @@ -16,22 +16,9 @@ namespace ICSharpCode.Reporting.Xml /// internal class ModelLoader: MycroParser { - protected override Type GetTypeByName(string ns, string name) { -// var b = typeof(BaseSection).Assembly.GetType("ICSharpCode.Reporting.Items" + "." + name); -// var s = typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name); -// Console.WriteLine("getTypeByname <{0}>",s.Name); - - var t = typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name); - - if (t == null) { - Console.WriteLine(); - Console.WriteLine("Can't find Item <{0}>",name); - Console.WriteLine(); - } - return t; + return typeof(BaseSection).Assembly.GetType(typeof(BaseSection).Namespace + "." + name); } - } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs index b8c0be48e3..fb53bcd695 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs @@ -48,15 +48,11 @@ namespace ICSharpCode.Reporting.Xml // instantiate the class string ns=node.Prefix; string cname=node.LocalName; - Console.WriteLine ("ProcessNode(XmlNode node, object parent) {0}",cname); - + Console.WriteLine ("ProcessNode(XmlNode node, object parent) {0}",cname); + Type t=GetTypeByName(ns, cname); - if (t == null) { - Console.WriteLine("\t Not found {0}",cname); -// t = GetTypeByName (ns,"ErrorItem"); - } - + // Trace.Assert(t != null, "Type "+cname+" could not be determined."); // Debug.WriteLine("Looking for " + cname + " and got " + t.FullName); // Console.WriteLine("Looking for " + cname + " and got " + t.FullName); @@ -64,9 +60,11 @@ namespace ICSharpCode.Reporting.Xml { ret=Activator.CreateInstance(t); } - catch(Exception e) + catch(Exception) { - Trace.Fail("Type "+cname+" could not be instantiated:\r\n"+e.Message); + Console.WriteLine("MycroParser:"); + Console.WriteLine("\t Not found {0}",cname); +// Trace.Fail("Type "+cname+" could not be instantiated:\r\n"+e.Message); } // support the ISupportInitialize interface @@ -212,7 +210,7 @@ namespace ICSharpCode.Reporting.Xml static void SetPropertyToString(object obj, PropertyInfo pi, string value) { -// Console.WriteLine("MP - SetPropertyToString {0} - {1}",pi.Name,value.ToString()); + Console.WriteLine("MP - SetPropertyToString {0} - {1}",pi.Name,value.ToString()); // it's string, so use a type converter. TypeConverter tc=TypeDescriptor.GetConverter(pi.PropertyType); try diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs index e13cdbb5f1..d26aca75c9 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/DataSourceFixture.cs @@ -33,7 +33,7 @@ namespace ICSharpCode.Reporting.Test.DataSource [Test] public void GroupbyOneColumn () { var rs = new ReportSettings(); - rs.GroupColumnCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); + rs.GroupColumnsCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); var collectionSource = new CollectionDataSource (list,rs); collectionSource.Bind(); } @@ -97,8 +97,8 @@ namespace ICSharpCode.Reporting.Test.DataSource public void GroupbyOneColumnAndFill () { var dataItemsCollection = CreateDataItems(); var repiortsettings = new ReportSettings(); - repiortsettings.GroupColumnCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); - repiortsettings.GroupColumnCollection.Add( new GroupColumn("RandomInt",1,ListSortDirection.Ascending)); + repiortsettings.GroupColumnsCollection.Add( new GroupColumn("GroupItem",1,ListSortDirection.Ascending)); + repiortsettings.GroupColumnsCollection.Add( new GroupColumn("RandomInt",1,ListSortDirection.Ascending)); var collectionSource = new CollectionDataSource (list,repiortsettings); collectionSource.Bind(); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GroupedPushModel.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GroupedPushModel.cs index 30059bfeb5..cd58c3f934 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GroupedPushModel.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Reportingfactory/GroupedPushModel.cs @@ -17,9 +17,12 @@ namespace ICSharpCode.Reporting.Test.Reportingfactory [Test] public void TestMethod() { - Assert.That("a",Is.EqualTo("b")); + reportCreator.BuildExportList(); + // Only a test value + Assert.That(reportCreator.Pages.Count,Is.EqualTo(3)); } + [SetUp] public void LoadFromStream() { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/GroupedList.srd b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/GroupedList.srd index 73a17b2c9d..757350cc95 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/GroupedList.srd +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestReports/GroupedList.srd @@ -14,7 +14,13 @@ 5, 5, 5, 5 - + + + Ascending + GroupItem + System.String + + @@ -100,7 +106,7 @@ False Black ControlText - GoupItem + GroupItem BaseDataItem3