|
|
@ -6,12 +6,10 @@ using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Globalization; |
|
|
|
|
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.Reporting.BaseClasses; |
|
|
|
using ICSharpCode.Reporting.BaseClasses; |
|
|
|
using ICSharpCode.Reporting.DataSource; |
|
|
|
using ICSharpCode.Reporting.DataSource; |
|
|
|
using ICSharpCode.Reporting.DataSource.Comparer; |
|
|
|
|
|
|
|
using ICSharpCode.Reporting.Interfaces; |
|
|
|
using ICSharpCode.Reporting.Interfaces; |
|
|
|
using ICSharpCode.Reporting.Interfaces.Data; |
|
|
|
using ICSharpCode.Reporting.Interfaces.Data; |
|
|
|
using ICSharpCode.Reporting.Items; |
|
|
|
using ICSharpCode.Reporting.Items; |
|
|
@ -21,11 +19,12 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling |
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Description of DataSource.
|
|
|
|
/// Description of DataSource.
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
enum OrderGroup { |
|
|
|
public enum OrderGroup { |
|
|
|
AsIs, |
|
|
|
AsIs, |
|
|
|
Sorted, |
|
|
|
Sorted, |
|
|
|
Grouped |
|
|
|
Grouped |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class CollectionDataSource:IDataSource |
|
|
|
public class CollectionDataSource:IDataSource |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
@ -34,7 +33,7 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling |
|
|
|
readonly ReportSettings reportSettings; |
|
|
|
readonly ReportSettings reportSettings; |
|
|
|
readonly Type elementType; |
|
|
|
readonly Type elementType; |
|
|
|
readonly PropertyDescriptorCollection listProperties; |
|
|
|
readonly PropertyDescriptorCollection listProperties; |
|
|
|
OrderGroup orderGroup; |
|
|
|
// OrderGroup orderGroup;
|
|
|
|
|
|
|
|
|
|
|
|
public CollectionDataSource(IEnumerable list, ReportSettings reportSettings) |
|
|
|
public CollectionDataSource(IEnumerable list, ReportSettings reportSettings) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -47,7 +46,7 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling |
|
|
|
|
|
|
|
|
|
|
|
this.reportSettings = reportSettings; |
|
|
|
this.reportSettings = reportSettings; |
|
|
|
this.listProperties = this.baseList.GetItemProperties(null); |
|
|
|
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.reportSettings = reportSettings; |
|
|
|
|
|
|
|
|
|
|
|
this.listProperties = this.baseList.GetItemProperties(null); |
|
|
|
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 object Current {get; private set;} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public OrderGroup OrderGroup {get; private set;} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IGrouping<object, object> CurrentKey {get; private set; } |
|
|
|
|
|
|
|
|
|
|
|
#region Sort
|
|
|
|
#region Sort
|
|
|
|
|
|
|
|
|
|
|
@ -101,10 +104,10 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (reportSettings.SortColumnsCollection.Count > 0) { |
|
|
|
if (reportSettings.SortColumnsCollection.Count > 0) { |
|
|
|
var sorted = SortInternal(); |
|
|
|
var sorted = SortInternal(); |
|
|
|
orderGroup = OrderGroup.Sorted; |
|
|
|
OrderGroup = OrderGroup.Sorted; |
|
|
|
listEnumerator = sorted.GetEnumerator(); |
|
|
|
listEnumerator = sorted.GetEnumerator(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
orderGroup = OrderGroup.AsIs; |
|
|
|
OrderGroup = OrderGroup.AsIs; |
|
|
|
listEnumerator = baseList.GetEnumerator(); |
|
|
|
listEnumerator = baseList.GetEnumerator(); |
|
|
|
} |
|
|
|
} |
|
|
|
listEnumerator.MoveNext(); |
|
|
|
listEnumerator.MoveNext(); |
|
|
@ -129,10 +132,11 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling |
|
|
|
|
|
|
|
|
|
|
|
void Group() |
|
|
|
void Group() |
|
|
|
{ |
|
|
|
{ |
|
|
|
orderGroup = OrderGroup.Grouped; |
|
|
|
OrderGroup = OrderGroup.Grouped; |
|
|
|
groupedList = GroupInternal(); |
|
|
|
groupedList = GroupInternal(); |
|
|
|
groupEnumerator = groupedList.GetEnumerator(); |
|
|
|
groupEnumerator = groupedList.GetEnumerator(); |
|
|
|
groupEnumerator.MoveNext(); |
|
|
|
groupEnumerator.MoveNext(); |
|
|
|
|
|
|
|
CurrentKey = groupEnumerator.Current; |
|
|
|
listEnumerator = groupEnumerator.Current.GetEnumerator(); |
|
|
|
listEnumerator = groupEnumerator.Current.GetEnumerator(); |
|
|
|
listEnumerator.MoveNext(); |
|
|
|
listEnumerator.MoveNext(); |
|
|
|
Current = listEnumerator.Current; |
|
|
|
Current = listEnumerator.Current; |
|
|
@ -140,7 +144,7 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IEnumerable<IGrouping<object, object>> GroupInternal () { |
|
|
|
IEnumerable<IGrouping<object, object>> 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 sortProperty = listProperties.Find("Randomint",true); |
|
|
|
|
|
|
|
|
|
|
|
var groupedList = baseList.OrderBy(o => o.GetType().GetProperty(sortProperty.Name).GetValue(o, null) ) |
|
|
|
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() |
|
|
|
public void Bind() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (reportSettings.GroupColumnCollection.Any()) { |
|
|
|
if (reportSettings.GroupColumnsCollection.Any()) { |
|
|
|
Group(); |
|
|
|
Group(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Sort(); |
|
|
|
Sort(); |
|
|
@ -173,8 +177,6 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling |
|
|
|
if (container != null) { |
|
|
|
if (container != null) { |
|
|
|
FillFromList(container.Items); |
|
|
|
FillFromList(container.Items); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
//FillFromList(collection);
|
|
|
|
|
|
|
|
FillInternal(element); |
|
|
|
FillInternal(element); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -218,9 +220,10 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling |
|
|
|
{ |
|
|
|
{ |
|
|
|
var canMove = listEnumerator.MoveNext(); |
|
|
|
var canMove = listEnumerator.MoveNext(); |
|
|
|
|
|
|
|
|
|
|
|
if (orderGroup == OrderGroup.Grouped) { |
|
|
|
if (OrderGroup == OrderGroup.Grouped) { |
|
|
|
if (! canMove) { |
|
|
|
if (! canMove) { |
|
|
|
var groupCanMove = groupEnumerator.MoveNext(); |
|
|
|
var groupCanMove = groupEnumerator.MoveNext(); |
|
|
|
|
|
|
|
CurrentKey = groupEnumerator.Current; |
|
|
|
if (groupCanMove) { |
|
|
|
if (groupCanMove) { |
|
|
|
listEnumerator = groupEnumerator.Current.GetEnumerator(); |
|
|
|
listEnumerator = groupEnumerator.Current.GetEnumerator(); |
|
|
|
canMove = listEnumerator.MoveNext(); |
|
|
|
canMove = listEnumerator.MoveNext(); |
|
|
|