Browse Source

Grouping + Fill()

reports
Peter Forstmeier 13 years ago
parent
commit
f50a7c31a0
  1. 39
      SharpDevelop.Tests.sln
  2. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj
  3. 33
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs
  4. 6
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/AbstractColumn.cs
  5. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/GroupColumn.cs
  6. 6
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs
  7. 19
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs
  8. 355
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs
  9. 14
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/BaseComparer.cs
  10. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/GroupComparer.cs
  11. 3
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs
  12. 22
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs
  13. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs
  14. 8
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ExportRenderer/FixedDocumentCreator.cs
  15. 6
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs
  16. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataViewHandling.cs
  17. 26
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IDataItem.cs
  18. 30
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseDataItem.cs
  19. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs
  20. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/PreviewViewModel.cs
  21. 162
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs
  22. 40
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs

39
SharpDevelop.Tests.sln

@ -1,7 +1,10 @@ @@ -1,7 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.3
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker35", "src\Main\ICSharpCode.SharpDevelop.BuildWorker35\ICSharpCode.SharpDevelop.BuildWorker35.csproj", "{B5F54272-49F0-40DB-845A-8D837875D3BA}"
EndProject
@ -24,6 +27,8 @@ EndProject @@ -24,6 +27,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDevelop", "src\Main\SharpDevelop\SharpDevelop.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{2A232EF1-EB95-41C6-B63A-C106E0C95D3C}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mono.Cecil", "src\Libraries\cecil\Mono.Cecil.csproj", "{D68133BD-1E63-496E-9EDE-4FBDBF77B486}"
EndProject
@ -53,14 +58,20 @@ EndProject @@ -53,14 +58,20 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Decompiler", "src\Libraries\ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj", "{984CC812-9470-4A13-AFF9-CC44068D666C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{39327899-ED91-4F7F-988C-4FE4E17C014D}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Version Control", "Version Control", "{F208FF4F-E5D8-41D5-A7C7-B463976F156E}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitAddIn", "src\AddIns\VersionControl\GitAddIn\GitAddIn.csproj", "{83F15BA7-8478-4664-81BB-A82F146D88B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubversionAddIn", "src\AddIns\VersionControl\SubversionAddIn\SubversionAddIn.csproj", "{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Language Bindings", "Language Bindings", "{E0646C25-36F2-4524-969F-FA621353AB94}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding", "src\AddIns\BackendBindings\CSharpBinding\Project\CSharpBinding.csproj", "{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A}"
EndProject
@ -85,6 +96,8 @@ EndProject @@ -85,6 +96,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Scripting.Tests", "src\AddIns\BackendBindings\Scripting\Test\ICSharpCode.Scripting.Tests.csproj", "{85C09AD8-183B-403A-869A-7226646218A9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelpViewer", "src\AddIns\Misc\HelpViewer\HelpViewer.csproj", "{80F76D10-0B44-4D55-B4BD-DAEB5464090C}"
EndProject
@ -101,6 +114,8 @@ EndProject @@ -101,6 +114,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegExpTk", "src\AddIns\Misc\RegExpTk\Project\RegExpTk.csproj", "{64A3E5E6-90BF-47F6-94DF-68C94B62C817}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UsageDataCollector", "UsageDataCollector", "{DEFC8584-BEC3-4921-BD0F-40482E450B7B}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector\UsageDataCollector.csproj", "{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0}"
EndProject
@ -113,6 +128,8 @@ EndProject @@ -113,6 +128,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextTemplating", "src\AddIns\Misc\TextTemplating\Project\TextTemplating.csproj", "{B5D8C3E6-42EC-4D4B-AD05-3644B32563EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PackageManagement", "PackageManagement", "{485A4CCF-55CF-49F4-BD6D-A22B788C67DA}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement", "src\AddIns\Misc\PackageManagement\Project\PackageManagement.csproj", "{AE4AB0FA-6087-4480-AF37-0FA1452B3DA1}"
EndProject
@ -120,8 +137,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement.Tests", " @@ -120,8 +137,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement.Tests", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PackageManagement.PowerShell", "src\AddIns\Misc\PackageManagement\PowerShell\Project\PackageManagement.PowerShell.csproj", "{A406803B-C584-43A3-BCEE-A0BB3132CB5F}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SharpDevelop.EnvDTE", "src\AddIns\Misc\PackageManagement\SharpDevelop.EnvDTE\SharpDevelop.EnvDTE.vbproj", "{1B753D7F-7C77-4D5E-B928-02982690879C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reports.Core", "src\AddIns\Misc\Reports\ICSharpCode.Reports.Core\ICSharpCode.Reports.Core.csproj", "{4B2239FF-8FD6-431D-9D22-1B8049BA6917}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reports.Core.Test", "src\AddIns\Misc\Reports\ICSharpCode.Reports.Core\Test\ICSharpCode.Reports.Core.Test\ICSharpCode.Reports.Core.Test.csproj", "{E16B73CA-3603-47EE-915E-6F8B2A07304B}"
@ -135,6 +150,8 @@ EndProject @@ -135,6 +150,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Reporting.Test", "src\AddIns\Misc\Reporting\ICSharpCode.Reporting\Test\ICSharpCode.Reporting.Test\ICSharpCode.Reporting.Test.csproj", "{97CA9CE5-B966-48DF-BB59-F00FFC534B1F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\AddIns\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}"
EndProject
@ -149,6 +166,8 @@ EndProject @@ -149,6 +166,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpyAddIn", "src\AddIns\DisplayBindings\ILSpyAddIn\ILSpyAddIn.csproj", "{8AA421C8-D7AF-4957-9F43-5135328ACB24}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{0F5192F2-0744-4BA9-A074-6BE82D111B8D}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Addin", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Addin\ICSharpCode.Data.Addin.csproj", "{A9F12710-24E4-46D4-832C-6ECB395B9EAD}"
EndProject
@ -163,6 +182,8 @@ EndProject @@ -163,6 +182,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.SQLServer\ICSharpCode.Data.SQLServer.csproj", "{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
@ -175,6 +196,8 @@ EndProject @@ -175,6 +196,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{AF5E0DC1-1FA0-4346-A436-0C817C68F7C1}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}"
EndProject
@ -183,6 +206,8 @@ EndProject @@ -183,6 +206,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Tests", "src\AddIns\Debugger\Debugger.Tests\Debugger.Tests.csproj", "{A4C858C8-51B6-4265-A695-A20FCEBA1D19}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analysis", "Analysis", "{B3352C08-3CB4-4DD9-996F-B9DCE4356BB9}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}"
EndProject
@ -190,14 +215,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "src\Ad @@ -190,14 +215,16 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "src\Ad
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\Analysis\CodeAnalysis\CodeAnalysis.csproj", "{3EAA45A9-735C-4AC7-A799-947B93EA449D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceAnalysis", "src\AddIns\Analysis\SourceAnalysis\SourceAnalysis.csproj", "{C16BEA37-FEE8-4792-B860-48F5BFBD39A9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "src\AddIns\Analysis\CodeCoverage\Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "src\AddIns\Analysis\CodeCoverage\Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortSD4AddInToSD5", "samples\PortSD4AddInToSD5\PortSD4AddInToSD5.csproj", "{E2FD63DA-8478-4066-934C-DA82A852C83A}"
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SharpDevelop.EnvDTE", "src\AddIns\Misc\PackageManagement\SharpDevelop.EnvDTE\SharpDevelop.EnvDTE.vbproj", "{1B753D7F-7C77-4D5E-B928-02982690879C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceAnalysis", "src\AddIns\Analysis\SourceAnalysis\SourceAnalysis.csproj", "{C16BEA37-FEE8-4792-B860-48F5BFBD39A9}"
EndProject
Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}"
EndProject
Global

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj

@ -107,9 +107,11 @@ @@ -107,9 +107,11 @@
<Compile Include="Src\Interfaces\Export\IExportContainer.cs" />
<Compile Include="Src\Interfaces\Export\IPage.cs" />
<Compile Include="Src\Interfaces\Export\IPageInfo.cs" />
<Compile Include="Src\Interfaces\IDataItem.cs" />
<Compile Include="Src\Interfaces\IPrintableObject.cs" />
<Compile Include="Src\Interfaces\IReportContainer.cs" />
<Compile Include="Src\Interfaces\IReportCreator.cs" />
<Compile Include="Src\Items\BaseDataItem.cs" />
<Compile Include="Src\Items\BaseSection.cs" />
<Compile Include="Src\Globals\GlobalEnums.cs" />
<Compile Include="Src\Globals\GlobalValues.cs" />

33
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Arrange/ArrangeStrategy.cs

@ -54,17 +54,30 @@ namespace ICSharpCode.Reporting.Arrange @@ -54,17 +54,30 @@ namespace ICSharpCode.Reporting.Arrange
}
}
private void FindBiggestRectangle (IExportContainer container) {
BiggestRectangle = Rectangle.Empty;
foreach (var item in container.ExportedItems) {
if (item.DesiredSize.Height > BiggestRectangle.Size.Height) {
BiggestRectangle = new Rectangle(new Point(container.Location.X + item.Location.X,
container.Location.Y + item.Location.Y)
,item.DesiredSize);
}
}
private void FindBiggestRectangle (IExportContainer container)
{
BiggestRectangle = Rectangle.Empty;
/*
foreach (var item in container.ExportedItems)
{
if (item.DesiredSize.Height > BiggestRectangle.Size.Height)
{
BiggestRectangle = new Rectangle(new Point(container.Location.X + item.Location.X,
container.Location.Y + item.Location.Y)
, item.DesiredSize);
}
}
*/
foreach (var item in container.ExportedItems
.Where(item => item.DesiredSize.Height > BiggestRectangle.Size.Height))
{
BiggestRectangle = new Rectangle(new Point(container.Location.X + item.Location.X,
container.Location.Y + item.Location.Y)
,item.DesiredSize);
}
}
public Rectangle BiggestRectangle {get; private set;}
public Rectangle BiggestRectangle {get; private set;}
}
}

6
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/AbstractColumn.cs

@ -16,19 +16,13 @@ namespace ICSharpCode.Reporting.BaseClasses @@ -16,19 +16,13 @@ namespace ICSharpCode.Reporting.BaseClasses
/// </summary>
public class AbstractColumn
{
private string columnName;
private Type dataType;
private string dataTypeName;
public AbstractColumn() {
this.dataType = typeof(System.String);
this.columnName = string.Empty;
}
// public AbstractColumn(string columnName){
// this.columnName = columnName;
// this.dataType = typeof(System.String);
// }
public AbstractColumn(string columnName, Type dataType){
this.ColumnName = columnName;

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/GroupColumn.cs

@ -31,8 +31,8 @@ namespace ICSharpCode.Reporting.BaseClasses @@ -31,8 +31,8 @@ namespace ICSharpCode.Reporting.BaseClasses
}
public int GroupLevel {get;private set;
public int GroupLevel {get;private set;}
}
}
}

6
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/SortColumn.cs

@ -24,11 +24,7 @@ namespace ICSharpCode.Reporting.BaseClasses @@ -24,11 +24,7 @@ namespace ICSharpCode.Reporting.BaseClasses
{
}
public SortColumn(string columnName,Type type ):this(columnName,ListSortDirection.Ascending,type,false)
{
}
public SortColumn(string columnName,ListSortDirection sortDirection)
:this(columnName,sortDirection,typeof(System.String),false){
}

19
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs

@ -13,6 +13,7 @@ using System.Globalization; @@ -13,6 +13,7 @@ using System.Globalization;
using System.Linq;
using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.Items;
namespace ICSharpCode.Reporting
{
@ -96,4 +97,22 @@ namespace ICSharpCode.Reporting @@ -96,4 +97,22 @@ namespace ICSharpCode.Reporting
return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture));
}
}
/*
public class ReportItemCollection : Collection<PrintableItem>
{
// Trick to get the inner list as List<T> (InnerList always has that type because we only use
// the parameterless constructor on Collection<T>)
private List<PrintableItem> InnerList {
get { return (List<PrintableItem>)base.Items; }
}
private void Sort(IComparer<PrintableItem> comparer)
{
InnerList.Sort(comparer);
}
}
*/
}

355
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionSource.cs

@ -13,10 +13,13 @@ using System.Collections.ObjectModel; @@ -13,10 +13,13 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Reflection;
using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.DataManager.Listhandling;
using ICSharpCode.Reporting.DataSource;
using ICSharpCode.Reporting.DataSource.Comparer;
using ICSharpCode.Reporting.Interfaces;
using ICSharpCode.Reporting.Interfaces.Data;
using ICSharpCode.Reporting.Items;
@ -31,13 +34,13 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -31,13 +34,13 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
private PropertyDescriptorCollection listProperties;
private DataCollection<object> baseList;
private ReportSettings reportSettings;
private object current;
private Type itemType;
public CollectionSource(IList list,ReportSettings reportSettings)
{
if (list.Count > 0) {
var itemType = list[0].GetType();
itemType = list[0].GetType();
this.baseList = new DataCollection <object>(itemType);
this.baseList.AddRange(list);
}
@ -65,10 +68,47 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -65,10 +68,47 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
public object Current {
get {
throw new NotImplementedException();
return baseList[((BaseComparer)IndexList[CurrentPosition]).ListIndex];
}
}
// public object CurrentFromPosition(int pos)
// {
// BaseComparer bc = GetComparer(value);
// Current = baseList[bc.ListIndex];
// return baseList[((BaseComparer)IndexList[CurrentPosition]).ListIndex];
// }
public int CurrentPosition {
get {
return IndexList.CurrentPosition;
}
set {
if ((value > -1)|| (value > this.IndexList.Count)){
this.IndexList.CurrentPosition = value;
}
// BaseComparer bc = GetComparer(value);
// Current = baseList[bc.ListIndex];
// current = this.baseList[((BaseComparer)IndexList[value]).ListIndex];
}
}
public bool MoveNext()
{
this.IndexList.CurrentPosition ++;
return this.IndexList.CurrentPosition<this.IndexList.Count;
}
public IndexList IndexList {get; private set;}
public void Bind()
{
if (reportSettings.GroupColumnCollection.Any()) {
@ -76,64 +116,104 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -76,64 +116,104 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
} else {
this.Sort ();
}
Reset();
}
#region Fill
public void Fill(IDataItem item)
{
// PropertyInfo pi = itemType.GetProperty(item.ColumnName);
// var pi1 = pi.GetValue(Current);
var p = listProperties.Find(item.ColumnName,true);
item.DBValue = p.GetValue(Current).ToString();
if (String.IsNullOrEmpty(item.DataType)) {
item.DataType = p.PropertyType.ToString();
}
}
#endregion
#region Grouping
public void Group()
{
var sortedList = this.BuildSortIndex (reportSettings.GroupColumnCollection);
IndexList = BuildGroup(sortedList);
var unsortedList = this.BuildIndexInternal(reportSettings.GroupColumnCollection);
// IndexList = BuildGroup(unsortedList,reportSettings.GroupColumnCollection);
var sorted = unsortedList.OrderBy(a => a.ObjectArray[0]);
var x = sorted.GroupBy(a => a.ObjectArray[0]);
Console.WriteLine("GroupBy()");
foreach (var element in x) {
Console.WriteLine("{0} - {1} ",element.Key.ToString(),element is BaseComparer);
foreach (var xx in element) {
Console.WriteLine("...{0}",((BaseComparer)xx).ObjectArray[0].ToString());
}
}
Console.WriteLine("--------------- ");
// ShowIndexList(gl);
var aa = BuildGroup_1(unsortedList,reportSettings.GroupColumnCollection);
// ShowIndexList(IndexList);
}
/*
private Dictionary<string,IndexList> BuildGroup (IndexList list) {
private Dictionary<string,IndexList> BuildGroup_1 (IndexList list,GroupColumnCollection groups) {
var dictionary = new Dictionary<string,IndexList>();
PropertyDescriptor[] groupProperties = BuildSortProperties (groups);
foreach (var element in list) {
string groupValue = ExtractValue (element);
string groupValue = ExtractValue (element,groupProperties);
if (!dictionary.ContainsKey(groupValue)) {
dictionary[groupValue] = new IndexList();
}
dictionary[groupValue].Add(element);
}
foreach (var el in dictionary) {
Console.WriteLine (el.Key.ToString());
Console.WriteLine("Dictonary ");
foreach (var el in dictionary.Values) {
Console.WriteLine(el.Count.ToString());
foreach (var element in el) {
Console.WriteLine("-- {0}",element.ToString());
}
}
return dictionary;
return dictionary;
}
*/
private IndexList BuildGroup (IndexList list)
private IndexList BuildGroup (IndexList source,GroupColumnCollection groups)
{
string compareValue = String.Empty;
var idlist = new IndexList();
// GroupComparer groupComparer = null;
/*
foreach (BaseComparer element in list)
{
var groupValue = ExtractValue (element);
PropertyDescriptor[] groupProperties = BuildSortProperties (groups);
GroupComparer groupComparer = null;
foreach (BaseComparer element in source) {
var groupValue = ExtractValue(element,groupProperties);
// var query2 = idlist.FirstOrDefault( s => ((GroupComparer)s).ObjectArray[0] == groupValue) as GroupComparer;
// if (query2 == null) {
// groupComparer = CreateGroupHeader(element);
// idlist.Add(groupComparer);
// } else {
// Console.WriteLine("xx");
// }
if (compareValue != groupValue) {
groupComparer = CreateGroupHeader(element);
idlist.Add(groupComparer);
}
groupComparer.IndexList.Add(element);
compareValue = groupValue;
}
*/
GroupInternal(compareValue, ref idlist, list);
ShowGrouping(ref idlist);
// ShowIndexList(IndexList);
return idlist;
}
void ShowGrouping(ref IndexList idlist)
{
Console.WriteLine("----ShowGrouping---");
@ -146,36 +226,18 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -146,36 +226,18 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
}
}
}
void GroupInternal(string compareValue, ref IndexList idlist, IndexList list)
{
GroupComparer groupComparer = null;
foreach (BaseComparer element in list) {
var groupValue = ExtractValue(element);
if (compareValue != groupValue) {
groupComparer = CreateGroupHeader(element);
idlist.Add(groupComparer);
}
groupComparer.IndexList.Add(element);
compareValue = groupValue;
}
}
static string ExtractValue(BaseComparer element)
string ExtractValue(BaseComparer element,PropertyDescriptor[] groupProperties)
{
// string val = String.Empty;
// GroupColumn gc = element.ColumnCollection[0] as GroupColumn;
// if (gc != null) {
// val = element.ObjectArray[0].ToString();
// }
// return val;
return element.ObjectArray[0].ToString();
var rowItem = baseList[element.ListIndex];
var values = FillComparer(groupProperties, rowItem);
// return element.ObjectArray[0].ToString();
return values[0].ToString();
}
protected GroupComparer CreateGroupHeader (BaseComparer sc)
static GroupComparer CreateGroupHeader (BaseComparer sc)
{
var gc = new GroupComparer(sc.ColumnCollection,sc.ListIndex,sc.ObjectArray);
gc.IndexList = new IndexList();
@ -184,63 +246,16 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -184,63 +246,16 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
#endregion
public void Sort()
{
if ((this.reportSettings.SortColumnsCollection != null)) {
if (this.reportSettings.SortColumnsCollection.Count > 0) {
IndexList = this.BuildSortIndex (reportSettings.SortColumnsCollection);
} else {
IndexList = this.UnsortedIndexList(reportSettings.SortColumnsCollection);
}
}
}
public bool MoveNext()
{
throw new NotImplementedException();
}
public void Reset()
{
this.CurrentPosition = 0;
this.IndexList.CurrentPosition = -1;
}
#region BuildIndexList
public IndexList IndexList {get; private set;}
IndexList BuildSortIndex(SortColumnCollection sortColumnsCollection)
IndexList BuildSortIndex(Collection<AbstractColumn> sortColumnsCollection)
{
var indexList = new IndexList();
PropertyDescriptor[] sortProperties = BuildSortProperties (sortColumnsCollection);
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object rowItem = this.baseList[rowIndex];
object[] values = new object[sortColumnsCollection.Count];
// Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen.
for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){
object value = sortProperties[criteriaIndex].GetValue(rowItem);
// Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen.
// Muss IComparable und gleicher Typ sein.
if (value != null && value != DBNull.Value)
{
if (!(value is IComparable)){
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
}
}
indexList.Add(new SortComparer(sortColumnsCollection, rowIndex, values));
}
IndexList indexList = BuildIndexInternal(sortColumnsCollection);
if (indexList[0].ObjectArray.GetLength(0) == 1) {
List<BaseComparer> sortedList = GenericSorter (indexList);
IEnumerable<BaseComparer> sortedList = GenericSorter (indexList);
indexList.Clear();
indexList.AddRange(sortedList);
}
@ -249,42 +264,78 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -249,42 +264,78 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
}
return indexList;
}
IndexList BuildIndexInternal(Collection<AbstractColumn> sortColumnsCollection)
{
var indexList = new IndexList();
PropertyDescriptor[] sortProperties = BuildSortProperties(sortColumnsCollection);
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++) {
var rowItem = this.baseList[rowIndex];
var values = FillComparer(sortProperties, rowItem);
indexList.Add(new SortComparer(sortColumnsCollection, rowIndex, values));
}
return indexList;
}
#endregion
#region Sorting delegates
static List<BaseComparer> GenericSorter (List<BaseComparer> list)
public void Sort()
{
if ((this.reportSettings.SortColumnsCollection != null)) {
if (this.reportSettings.SortColumnsCollection.Count > 0) {
IndexList = this.BuildSortIndex (reportSettings.SortColumnsCollection);
} else {
IndexList = this.BuildIndexInternal(reportSettings.SortColumnsCollection);
}
}
}
static IEnumerable<BaseComparer> GenericSorter (List<BaseComparer> list)
{
List<BaseComparer> sortedList = null;
ListSortDirection sortDirection = GetSortDirection(list);
if (sortDirection == ListSortDirection.Ascending) {
sortedList = list.AsQueryable().AscendingOrder().ToList();
} else {
sortedList = list.AsQueryable().DescendingOrder().ToList();
}
sortedList = sortDirection == ListSortDirection.Ascending ? list.AsQueryable().AscendingOrder().ToList() : list.AsQueryable().DescendingOrder().ToList();
return sortedList;
}
static ListSortDirection GetSortDirection(List<BaseComparer> list)
{
BaseComparer bc = list[0];
SortColumn sortColumn = bc.ColumnCollection[0] as SortColumn;
var sortColumn = bc.ColumnCollection[0] as SortColumn;
ListSortDirection sd = sortColumn.SortDirection;
return sd;
}
#endregion
Object[] FillComparer(PropertyDescriptor[] sortProperties, object rowItem)
{
object[] values = new object[sortProperties.Length];
for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++) {
object value = sortProperties[criteriaIndex].GetValue(rowItem);
if (value != null && value != DBNull.Value) {
if (!(value is IComparable)) {
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
}
}
return values;
}
private PropertyDescriptor[] BuildSortProperties (SortColumnCollection sortColumnCollection)
private PropertyDescriptor[] BuildSortProperties (Collection<AbstractColumn> sortColumnCollection)
{
PropertyDescriptor[] sortProperties = new PropertyDescriptor[sortColumnCollection.Count];
PropertyDescriptorCollection descriptorCollection = this.baseList.GetItemProperties(null);
var sortProperties = new PropertyDescriptor[sortColumnCollection.Count];
var descriptorCollection = this.baseList.GetItemProperties(null);
for (int criteriaIndex = 0; criteriaIndex < sortColumnCollection.Count; criteriaIndex++){
PropertyDescriptor descriptor = descriptorCollection.Find (sortColumnCollection[criteriaIndex].ColumnName,true);
for (var criteriaIndex = 0; criteriaIndex < sortColumnCollection.Count; criteriaIndex++){
var descriptor = descriptorCollection.Find (sortColumnCollection[criteriaIndex].ColumnName,true);
if (descriptor == null){
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
@ -297,70 +348,42 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -297,70 +348,42 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
}
IndexList UnsortedIndexList(SortColumnCollection sortColumnsCollection)
BaseComparer GetComparer(int position)
{
IndexList arrayList = new IndexList();
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object[] values = new object[1];
arrayList.Add(new SortComparer(sortColumnsCollection, rowIndex, values));
}
return arrayList;
}
public int CurrentPosition {
get {
return IndexList.CurrentPosition;
}
set {
if ((value > -1)|| (value > this.IndexList.Count)){
this.IndexList.CurrentPosition = value;
}
// var a = this.baseList[((BaseComparer)IndexList[value])];
BaseComparer bc = GetComparer(value);
// var bc = (BaseComparer)IndexList[value];
// var i = bc.ListIndex;
var myCurrent = baseList[bc.ListIndex];
current = baseList[bc.ListIndex];
// current = this.baseList[((BaseComparer)IndexList[value]).ListIndex];
}
}
BaseComparer GetComparer(int value)
{
var bc = (BaseComparer)IndexList[value];
// var i = bc.ListIndex;
var bc = (BaseComparer)IndexList[position];
return bc;
}
#endregion
#region Debug Code
protected static void ShowIndexList (IndexList list)
private static void ShowIndexList (IndexList list)
{
foreach (BaseComparer element in list) {
string s = String.Format("{0} ",element.ObjectArray[0]);
GroupComparer gc = element as GroupComparer;
if ( gc != null) {
s = s + "GroupHeader";
if (gc.IndexList != null) {
s = s + String.Format(" <{0}> Childs",gc.IndexList.Count);
}
System.Console.WriteLine(s);
foreach (BaseComparer c in gc.IndexList) {
var groupComparer = element as GroupComparer;
if (groupComparer == null) continue;
if (groupComparer.IndexList.Any()) {
var ss = String.Format("{0} with {1} Children",element.ObjectArray[0],groupComparer.IndexList.Count);
System.Console.WriteLine(ss);
foreach (BaseComparer c in groupComparer.IndexList) {
Console.WriteLine("---- {0}",c.ObjectArray[0]);
}
}
}
}
static string WrongColumnName(string propertyName)
{
return String.Format(CultureInfo.InvariantCulture, "Error : <{0}> missing!", propertyName);
}
#endregion
public void Reset()
{
throw new NotImplementedException();
}
}
}

14
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/BaseComparer.cs

@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.ObjectModel;
using ICSharpCode.Reporting.BaseClasses;
namespace ICSharpCode.Reporting.DataSource.Comparer
{
@ -18,13 +20,12 @@ namespace ICSharpCode.Reporting.DataSource.Comparer @@ -18,13 +20,12 @@ namespace ICSharpCode.Reporting.DataSource.Comparer
private int listIndex;
private object[] objectArray;
ColumnCollection columnCollection;
/// <summary>
/// Default constructor - initializes all fields to default values
/// </summary>
public BaseComparer(ColumnCollection columnCollection , int listIndex, object[] values) {
this.columnCollection = columnCollection;
public BaseComparer(Collection<AbstractColumn> columnCollection , int listIndex, object[] values) {
this.ColumnCollection = columnCollection;
this.listIndex = listIndex;
this.objectArray = values;
}
@ -85,10 +86,7 @@ namespace ICSharpCode.Reporting.DataSource.Comparer @@ -85,10 +86,7 @@ namespace ICSharpCode.Reporting.DataSource.Comparer
}
public ColumnCollection ColumnCollection {
get {
return columnCollection;
}
}
public Collection<AbstractColumn> ColumnCollection {get;private set;}
}
}

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/GroupComparer.cs

@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.ObjectModel;
using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.DataManager.Listhandling;
namespace ICSharpCode.Reporting.DataSource.Comparer
@ -17,7 +19,7 @@ namespace ICSharpCode.Reporting.DataSource.Comparer @@ -17,7 +19,7 @@ namespace ICSharpCode.Reporting.DataSource.Comparer
public class GroupComparer :SortComparer
{
public GroupComparer (ColumnCollection owner, int listIndex, object[] values):base(owner,listIndex,values)
public GroupComparer (Collection<AbstractColumn> owner, int listIndex, object[] values):base(owner,listIndex,values)
{
IndexList = new IndexList();
}

3
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/Comparer/SortComparer.cs

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Globalization;
@ -19,7 +20,7 @@ namespace ICSharpCode.Reporting.DataSource.Comparer @@ -19,7 +20,7 @@ namespace ICSharpCode.Reporting.DataSource.Comparer
/// </summary>
public class SortComparer : BaseComparer {
public SortComparer(ColumnCollection owner, int listIndex, object[] values):base(owner,listIndex,values)
public SortComparer(Collection<AbstractColumn> owner, int listIndex, object[] values):base(owner,listIndex,values)
{
}

22
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/DataCollection.cs

@ -12,6 +12,7 @@ using System.Collections.Generic; @@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
namespace ICSharpCode.Reporting.DataSource
@ -112,13 +113,12 @@ namespace ICSharpCode.Reporting.DataSource @@ -112,13 +113,12 @@ namespace ICSharpCode.Reporting.DataSource
public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors){
if (listAccessors != null && listAccessors.Length > 0){
Type t = this.elementType;
for(int i = 0; i < listAccessors.Length; i++){
PropertyDescriptor pd = listAccessors[i];
t = (Type) PropertyTypeHash.Instance[t, pd.Name];
}
// if t is null an empty list will be generated
var t = this.elementType;
t = listAccessors.Aggregate(t,
(current, pd) => (Type) PropertyTypeHash.Instance[current, pd.Name]);
// if t is null an empty list will be generated
return ExtendedTypeDescriptor.GetProperties(t);
}
return ExtendedTypeDescriptor.GetProperties(elementType);
@ -143,7 +143,7 @@ namespace ICSharpCode.Reporting.DataSource @@ -143,7 +143,7 @@ namespace ICSharpCode.Reporting.DataSource
}
if (al == null && element == null)
{
PropertyInfo pi = parentType.GetProperty(propertyName);
var pi = parentType.GetProperty(propertyName);
if (pi != null)
{
object parentObject = null;
@ -172,18 +172,20 @@ namespace ICSharpCode.Reporting.DataSource @@ -172,18 +172,20 @@ namespace ICSharpCode.Reporting.DataSource
private static DataCollection<T> CheckForArrayList(object l)
{
IList list = l as IList;
var list = l as IList;
if (list == null)
return null;
if (list.GetType().FullName == "System.Collections.ArrayList+ReadOnlyArrayList")
{
FieldInfo fi = list.GetType().GetField("_list", BindingFlags.NonPublic | BindingFlags.Instance);
var fi = list.GetType().GetField("_list", BindingFlags.NonPublic | BindingFlags.Instance);
if (fi != null)
{
list = (IList) fi.GetValue(list);
}
}
// ReSharper disable SuspiciousTypeConversion.Global
return list as DataCollection<T>;
// ReSharper restore SuspiciousTypeConversion.Global
}
#endregion

1
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ExtendedPropertyDescriptor.cs

@ -33,6 +33,7 @@ namespace ICSharpCode.Reporting.DataSource @@ -33,6 +33,7 @@ namespace ICSharpCode.Reporting.DataSource
public override object GetValue (object component)
{
var x = component.GetType();
if (!componentType.IsAssignableFrom(component.GetType())){
return null;
}

8
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ExportRenderer/FixedDocumentCreator.cs

@ -63,7 +63,7 @@ namespace ICSharpCode.Reporting.ExportRenderer @@ -63,7 +63,7 @@ namespace ICSharpCode.Reporting.ExportRenderer
public TextBlock CreateTextBlock(ExportText exportText)
{
TextBlock textBlock = new TextBlock();
var textBlock = new TextBlock();
textBlock.Text = exportText.Text;
textBlock.Foreground = ConvertBrush(exportText.ForeColor);
SetFont(textBlock,exportText);
@ -135,7 +135,7 @@ namespace ICSharpCode.Reporting.ExportRenderer @@ -135,7 +135,7 @@ namespace ICSharpCode.Reporting.ExportRenderer
void CreateStrikeout (TextBlock textBlock,ExportColumn exportColumn )
{
TextDecoration strikeOut = new TextDecoration();
var strikeOut = new TextDecoration();
strikeOut.Location = TextDecorationLocation.Strikethrough;
Pen p = CreateWpfPen(exportColumn);
@ -147,7 +147,7 @@ namespace ICSharpCode.Reporting.ExportRenderer @@ -147,7 +147,7 @@ namespace ICSharpCode.Reporting.ExportRenderer
void CreateUnderline(TextBlock textBlock,ExportColumn exportColumn)
{
TextDecoration underLine = new TextDecoration();
var underLine = new TextDecoration();
Pen p = CreateWpfPen(exportColumn);
underLine.Pen = p ;
underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended;
@ -157,7 +157,7 @@ namespace ICSharpCode.Reporting.ExportRenderer @@ -157,7 +157,7 @@ namespace ICSharpCode.Reporting.ExportRenderer
Pen CreateWpfPen(ExportColumn exportColumn)
{
Pen myPen = new Pen();
var myPen = new Pen();
myPen.Brush = ConvertBrush(exportColumn.ForeColor);
myPen.Thickness = 1.5;
return myPen;

6
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs

@ -29,8 +29,8 @@ namespace ICSharpCode.Reporting.Exporter @@ -29,8 +29,8 @@ namespace ICSharpCode.Reporting.Exporter
public virtual void Run () {
}
public Collection<IPage> Pages {get; private set;}
protected Collection<IPage> Pages {get; set;}
}
}

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/Data/IDataViewHandling.cs

@ -29,7 +29,7 @@ namespace ICSharpCode.Reporting.Interfaces.Data @@ -29,7 +29,7 @@ namespace ICSharpCode.Reporting.Interfaces.Data
// void Fill (int position,ReportItemCollection collection);
//rausnehmen
// void Fill (IDataItem item);
void Fill (IDataItem item);
IndexList IndexList {get;}

26
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Interfaces/IDataItem.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 29.05.2013
* Time: 20:10
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
namespace ICSharpCode.Reporting.Interfaces
{
/// <summary>
/// Description of IDataItem.
/// </summary>
public interface IDataItem
{
string ColumnName { get; set; }
// string MappingName { get; }
// string BaseTableName { get; set; }
string DBValue {get;set;}
string Name {get;set;}
string DataType {get;set;}
}
}

30
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseDataItem.cs

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 29.05.2013
* Time: 20:08
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using ICSharpCode.Reporting.Interfaces;
namespace ICSharpCode.Reporting.Items
{
/// <summary>
/// Description of BaseDataItem.
/// </summary>
public class BaseDataItem:BaseTextItem,IDataItem
{
public BaseDataItem()
{
}
public virtual string DBValue {get;set;}
public virtual string ColumnName {get;set;}
public string DataType {get;set;}
}
}

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs

@ -65,8 +65,8 @@ namespace ICSharpCode.Reporting.PageBuilder @@ -65,8 +65,8 @@ namespace ICSharpCode.Reporting.PageBuilder
protected IReportModel ReportModel {get; private set;}
protected Point CurrentLocation {get; set;}
public IPage CurrentPage {get; protected set;}
protected IPage CurrentPage {get; set;}
public Collection<IPage> Pages {get; private set;}

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/PreviewViewModel.cs

@ -45,7 +45,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer @@ -45,7 +45,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer
static void AddPageToDocument(FixedDocument fixedDocument,FixedPage page)
{
PageContent pageContent = new PageContent();
var pageContent = new PageContent();
((IAddChild)pageContent).AddChild(page);
fixedDocument.Pages.Add(pageContent);
}

162
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Xml/MycroParser.cs

@ -39,8 +39,8 @@ namespace ICSharpCode.Reporting.Xml @@ -39,8 +39,8 @@ namespace ICSharpCode.Reporting.Xml
}
protected abstract Type GetTypeByName(string ns, string name);
protected object ProcessNode(XmlNode node, object parent)
private object ProcessNode(XmlNode node, object parent)
{
object ret=null;
if (node is XmlElement)
@ -99,92 +99,90 @@ namespace ICSharpCode.Reporting.Xml @@ -99,92 +99,90 @@ namespace ICSharpCode.Reporting.Xml
protected void ProcessChildProperties(XmlNode node, object parent)
{
Type t=parent.GetType();
var t=parent.GetType();
// children of a class must always be properties
foreach(XmlNode child in node.ChildNodes)
{
if (child is XmlElement)
{
string pname=child.LocalName;
PropertyInfo pi=t.GetProperty(pname);
if (pi==null)
{
// Special case--we're going to assume that the child is a class instance
// not associated with the parent object
if (!(child is XmlElement)) continue;
string pname=child.LocalName;
var pi=t.GetProperty(pname);
if (pi==null)
{
// Special case--we're going to assume that the child is a class instance
// not associated with the parent object
// Trace.Fail("Unsupported property: "+pname);
System.Console.WriteLine("Unsupported property: "+pname);
continue;
}
// a property can only have one child node unless it's a collection
foreach(XmlNode grandChild in child.ChildNodes)
{
if (grandChild is XmlText) {
SetPropertyToString(parent, pi, child.InnerText);
break;
}
else if (grandChild is XmlElement)
{
object propObject=pi.GetValue(parent, null);
object obj=ProcessNode(grandChild, propObject);
// A null return is valid in cases where a class implementing the IMicroXaml interface
// might want to take care of managing the instance it creates itself. See DataBinding
if (obj != null)
{
// support for ICollection objects
if (propObject is ICollection)
{
MethodInfo mi=t.GetMethod("Add", new Type[] {obj.GetType()});
if (mi != null)
{
try
{
mi.Invoke(obj, new object[] {obj});
}
catch(Exception e)
{
Trace.Fail("Adding to collection failed:\r\n"+e.Message);
}
}
else if (propObject is IList)
{
try
{
((IList)propObject).Add(obj);
}
catch(Exception e)
{
Trace.Fail("List/Collection add failed:\r\n"+e.Message);
}
}
}
else if (!pi.CanWrite) {
Trace.Fail("Unsupported read-only property: "+pname);
}
else
{
// direct assignment if not a collection
try
{
pi.SetValue(parent, obj, null);
}
catch(Exception e)
{
Trace.Fail("Property setter for "+pname+" failed:\r\n"+e.Message);
}
}
}
}
}
}
System.Console.WriteLine("Unsupported property: "+pname);
continue;
}
// a property can only have one child node unless it's a collection
foreach(XmlNode grandChild in child.ChildNodes)
{
if (grandChild is XmlText) {
SetPropertyToString(parent, pi, child.InnerText);
break;
}
else if (grandChild is XmlElement)
{
var propObject=pi.GetValue(parent, null);
var obj=ProcessNode(grandChild, propObject);
// A null return is valid in cases where a class implementing the IMicroXaml interface
// might want to take care of managing the instance it creates itself. See DataBinding
if (obj != null)
{
// support for ICollection objects
if (propObject is ICollection)
{
MethodInfo mi=t.GetMethod("Add", new Type[] {obj.GetType()});
if (mi != null)
{
try
{
mi.Invoke(obj, new object[] {obj});
}
catch(Exception e)
{
Trace.Fail("Adding to collection failed:\r\n"+e.Message);
}
}
else if (propObject is IList)
{
try
{
((IList)propObject).Add(obj);
}
catch(Exception e)
{
Trace.Fail("List/Collection add failed:\r\n"+e.Message);
}
}
}
else if (!pi.CanWrite) {
Trace.Fail("Unsupported read-only property: "+pname);
}
else
{
// direct assignment if not a collection
try
{
pi.SetValue(parent, obj, null);
}
catch(Exception e)
{
Trace.Fail("Property setter for "+pname+" failed:\r\n"+e.Message);
}
}
}
}
}
}
}
protected void ProcessAttributes(XmlNode node, object ret, Type type)
private void ProcessAttributes(XmlNode node, object ret, Type type)
{
// process attributes
foreach(XmlAttribute attr in node.Attributes)
@ -207,8 +205,8 @@ namespace ICSharpCode.Reporting.Xml @@ -207,8 +205,8 @@ namespace ICSharpCode.Reporting.Xml
}
}
}
void SetPropertyToString(object obj, PropertyInfo pi, string value)
static void SetPropertyToString(object obj, PropertyInfo pi, string value)
{
Console.WriteLine("MP - SetPropertyToString {0} - {1}",pi.Name,value.ToString());
// it's string, so use a type converter.

40
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.DataManager.Listhandling;
using ICSharpCode.Reporting.DataSource;
@ -31,6 +31,21 @@ namespace ICSharpCode.Reporting.Test.DataSource @@ -31,6 +31,21 @@ namespace ICSharpCode.Reporting.Test.DataSource
Assert.That(collectionSource,Is.Not.Null);
}
[Test]
public void CurrentpositionShouldZeroAfterBind () {
var collectionSource = new CollectionSource (list,new ReportSettings());
collectionSource.Bind();
Assert.That(collectionSource.CurrentPosition,Is.EqualTo(0));
}
[Test]
public void CurrentPositionIsTwo () {
var collectionSource = new CollectionSource (list,new ReportSettings());
collectionSource.Bind();
collectionSource.MoveNext();
collectionSource.MoveNext();
Assert.That(collectionSource.CurrentPosition,Is.EqualTo(2));
}
[Test]
public void CollectionCountIsEqualToListCount() {
@ -45,6 +60,21 @@ namespace ICSharpCode.Reporting.Test.DataSource @@ -45,6 +60,21 @@ namespace ICSharpCode.Reporting.Test.DataSource
Assert.That(collectionSource.AvailableFields.Count,Is.EqualTo(6));
}
#region Fill
[Test]
public void justFill() {
var collectionSource = new CollectionSource (list,new ReportSettings());
collectionSource.Bind();
var a = collectionSource.MoveNext();
collectionSource.Fill(new BaseDataItem() {
ColumnName = "Lastname"
});
}
#endregion
#region Grouping
[Test]
@ -55,6 +85,12 @@ namespace ICSharpCode.Reporting.Test.DataSource @@ -55,6 +85,12 @@ namespace ICSharpCode.Reporting.Test.DataSource
collectionSource.Bind();
}
[Test]
public void bla () {
var s = list.OrderBy(a => a.Lastname);
var x = s.GroupBy(y => y.GroupItem);
}
#endregion
#region Sort
@ -65,7 +101,7 @@ namespace ICSharpCode.Reporting.Test.DataSource @@ -65,7 +101,7 @@ namespace ICSharpCode.Reporting.Test.DataSource
var collectionSource = new CollectionSource (list,new ReportSettings());
collectionSource.Bind();
Assert.That(collectionSource.IndexList.Count,Is.EqualTo(collectionSource.Count));
Assert.That(collectionSource.IndexList.CurrentPosition,Is.EqualTo(-1));
Assert.That(collectionSource.IndexList.CurrentPosition,Is.EqualTo(0));
}

Loading…
Cancel
Save