29 changed files with 457 additions and 77 deletions
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 22.04.2013 |
||||
* Time: 19:11 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using ICSharpCode.Reporting.Interfaces; |
||||
using ICSharpCode.Reporting.Items; |
||||
using ICSharpCode.Reporting.PageBuilder.ExportColumns; |
||||
|
||||
namespace ICSharpCode.Reporting.Arrange |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ArrangeStrategy.
|
||||
/// </summary>
|
||||
public interface IArrangeStrategy |
||||
{ |
||||
void Arrange(IPrintableObject reportItem); |
||||
} |
||||
|
||||
|
||||
public class ContainerArrangeStrategy:IArrangeStrategy |
||||
{ |
||||
public ContainerArrangeStrategy() |
||||
{ |
||||
} |
||||
|
||||
public void Arrange(IPrintableObject reportItem) |
||||
{ |
||||
Console.WriteLine("Arrange {0}",reportItem.Name); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 18.04.2013 |
||||
* Time: 20:06 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
|
||||
using ICSharpCode.Reporting.Interfaces.Export; |
||||
|
||||
namespace ICSharpCode.Reporting.Exporter |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DebugExporter.
|
||||
/// </summary>
|
||||
public class DebugExporter |
||||
{ |
||||
|
||||
public DebugExporter(Collection<IPage> pages) |
||||
{ |
||||
if (pages == null) { |
||||
throw new ArgumentException("pages"); |
||||
} |
||||
|
||||
Pages = pages; |
||||
} |
||||
|
||||
|
||||
public void Run () { |
||||
foreach (var page in Pages) { |
||||
ShowDebug(page); |
||||
} |
||||
} |
||||
|
||||
static void ShowDebug(IExportContainer container) |
||||
{ |
||||
var visitor = new DebugVisitor(); |
||||
foreach (var item in container.ExportedItems) { |
||||
if (item is IExportContainer) { |
||||
var a = item as IAcceptor; |
||||
if (a != null) { |
||||
Console.WriteLine("----"); |
||||
a.Accept(visitor); |
||||
} |
||||
ShowDebug(item as IExportContainer); |
||||
} else { |
||||
var b = item as IAcceptor; |
||||
if (b != null) { |
||||
b.Accept(visitor); |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* |
||||
static void ShowDebug(IExportContainer container) |
||||
{ |
||||
var visitor = new DebugVisitor(); |
||||
foreach (var item in container.ExportedItems) { |
||||
if (item is IExportContainer) { |
||||
var a = item as IAcceptor; |
||||
if (a != null) { |
||||
Console.WriteLine("----"); |
||||
a.Accept(visitor); |
||||
} |
||||
ShowDebug(item as IExportContainer); |
||||
} else { |
||||
var b = item as IAcceptor; |
||||
if (b != null) { |
||||
b.Accept(visitor); |
||||
|
||||
} |
||||
} |
||||
} |
||||
} |
||||
*/ |
||||
public Collection<IPage> Pages {get; private set;} |
||||
} |
||||
} |
||||
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 20.04.2013 |
||||
* Time: 18:30 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
|
||||
namespace ICSharpCode.Reporting.Exporter |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IAcceptor.
|
||||
/// </summary>
|
||||
public interface IAcceptor |
||||
{ |
||||
void Accept(IVisitor visitor); |
||||
} |
||||
} |
||||
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 18.04.2013 |
||||
* Time: 20:09 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Reporting.PageBuilder.ExportColumns; |
||||
|
||||
namespace ICSharpCode.Reporting.Exporter |
||||
{ |
||||
public interface IVisitor |
||||
{ |
||||
void Visit(ExportColumn exportColumn); |
||||
void Visit(ExportContainer exportColumn); |
||||
void Visit(ExportText exportColumn); |
||||
} |
||||
} |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 18.04.2013 |
||||
* Time: 20:09 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Reporting.PageBuilder.ExportColumns; |
||||
|
||||
namespace ICSharpCode.Reporting.Exporter |
||||
{ |
||||
/// <summary>
|
||||
/// Description of Visitor.
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
public abstract class Visitor : IVisitor |
||||
{ |
||||
public abstract void Visit(ExportColumn exportColumn); |
||||
public abstract void Visit(ExportContainer exportColumn); |
||||
public abstract void Visit(ExportText exportColumn); |
||||
} |
||||
|
||||
|
||||
// http://www.remondo.net/visitor-pattern-example-csharp/
|
||||
// http://www.codeproject.com/Articles/42240/Visitor-Design-Pattern
|
||||
// http://www.remondo.net/strategy-pattern-example-csharp/
|
||||
|
||||
|
||||
public class DebugVisitor : Visitor |
||||
{ |
||||
public override void Visit(ExportColumn exportColumn) |
||||
{ |
||||
Console.WriteLine("Visit ExportColumn {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); |
||||
} |
||||
|
||||
|
||||
|
||||
public override void Visit(ExportContainer exportColumn) |
||||
{ |
||||
Console.WriteLine("Visit ExportContainer {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); |
||||
} |
||||
|
||||
public override void Visit(ExportText exportColumn) |
||||
{ |
||||
Console.WriteLine("Visit ExportText {0} - {1} - {2}", exportColumn.Name,exportColumn.Size,exportColumn.Location); |
||||
} |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.04.2013 |
||||
* Time: 18:18 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Drawing; |
||||
using System.Linq; |
||||
using System.Reflection; |
||||
|
||||
using ICSharpCode.Reporting.Exporter; |
||||
using ICSharpCode.Reporting.Interfaces; |
||||
using ICSharpCode.Reporting.Interfaces.Export; |
||||
using ICSharpCode.Reporting.PageBuilder.ExportColumns; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Reporting.Test.PageBuilder |
||||
{ |
||||
[TestFixture] |
||||
public class PageLayoutFixture |
||||
{ |
||||
private IReportCreator reportCreator; |
||||
|
||||
[Test] |
||||
public void PageContainsFourExportContainer() |
||||
{ |
||||
reportCreator.BuildExportList(); |
||||
var x = reportCreator.Pages[0].ExportedItems; |
||||
var y = from s in x |
||||
where s.GetType() == typeof(ExportContainer) |
||||
select s; |
||||
Assert.That(y.ToList().Count,Is.EqualTo(3)); |
||||
Console.WriteLine("-------ShowDebug---------"); |
||||
var ex = new DebugExporter(reportCreator.Pages); |
||||
ex.Run(); |
||||
} |
||||
|
||||
[Test] |
||||
public void SectionsInpageDoNotOverlap() |
||||
{ |
||||
Point p = Point.Empty; |
||||
reportCreator.BuildExportList(); |
||||
foreach (IPage element in reportCreator.Pages) { |
||||
var first = true; |
||||
foreach (var item in element.ExportedItems) { |
||||
if (! first) { |
||||
var p2 = new Point(item.Location.X,item.Location.Y); |
||||
Assert.That(p2.Y,Is.GreaterThan(p.Y)); |
||||
} else { |
||||
first = false; |
||||
} |
||||
p = new Point(item.Location.X,item.Location.Y + item.Size.Height); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
[SetUp] |
||||
public void LoadFromStream() |
||||
{ |
||||
System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); |
||||
var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); |
||||
var reportingFactory = new ReportingFactory(); |
||||
reportCreator = reportingFactory.ReportCreator(stream); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue