diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj index 5ac10351ce..37c8bcc3c8 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj @@ -59,12 +59,16 @@ + - - - + + + + + + @@ -92,6 +96,7 @@ + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs index ff18084857..87cac420b2 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/Page.cs @@ -20,7 +20,6 @@ namespace ICSharpCode.Reporting.BaseClasses /// /// - public class Page:IPage { public Page(IPageInfo pageInfo,Size pageSize) @@ -31,7 +30,7 @@ namespace ICSharpCode.Reporting.BaseClasses PageInfo = pageInfo; Name = "Page"; Size = pageSize; - ExportedItems = new List(); + exportedItems = new List(); } public bool IsFirstPage {get;set;} @@ -49,7 +48,11 @@ namespace ICSharpCode.Reporting.BaseClasses public System.Drawing.Point Location {get;set;} - public List ExportedItems {get;set;} + public List exportedItems; + + public List ExportedItems { + get { return exportedItems; } + } public IExportContainer CreateExportColumn() diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs new file mode 100644 index 0000000000..448fa6627c --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/BaseExporter.cs @@ -0,0 +1,36 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 28.04.2013 + * Time: 18:59 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.Interfaces.Export; + +namespace ICSharpCode.Reporting.Exporter +{ + /// + /// Description of Baseexport. + /// + public class BaseExporter + { + public BaseExporter(Collection pages) + { + if (pages == null) { + throw new ArgumentException("pages"); + } + + Pages = pages; + } + + public virtual void Run () { + + } + + + public Collection Pages {get; private set;} + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs index af27b9557d..9916b4f6e7 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/DebugExporter.cs @@ -10,6 +10,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using ICSharpCode.Reporting.Exporter.Visitors; using ICSharpCode.Reporting.Interfaces.Export; namespace ICSharpCode.Reporting.Exporter @@ -17,68 +18,43 @@ namespace ICSharpCode.Reporting.Exporter /// /// Description of DebugExporter. /// - public class DebugExporter + public class DebugExporter:BaseExporter { + private DebugVisitor visitor; - public DebugExporter(Collection pages) + public DebugExporter(Collection pages):base(pages) { - if (pages == null) { - throw new ArgumentException("pages"); - } - - Pages = pages; + visitor = new DebugVisitor(); } - - public void Run () { + + public override 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) + void ShowDebug(IExportContainer container) { - var visitor = new DebugVisitor(); +// 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); + var exportContainer = item as IExportContainer; + var acceptor = item as IAcceptor; + if (exportContainer != null) { + if (acceptor != null) { + Console.WriteLine("--container--"); + acceptor.Accept(visitor); } ShowDebug(item as IExportContainer); } else { - var b = item as IAcceptor; - if (b != null) { - b.Accept(visitor); - + if (acceptor != null) { + Console.WriteLine("..Item..."); + acceptor.Accept(visitor); } } } } - */ - public Collection Pages {get; private set;} + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/PrintExporter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/PrintExporter.cs new file mode 100644 index 0000000000..e689d1204b --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/PrintExporter.cs @@ -0,0 +1,57 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 28.04.2013 + * Time: 18:01 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.ObjectModel; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces.Export; + +namespace ICSharpCode.Reporting.Exporter +{ + /// + /// Description of PrintExporter. + /// + public class PrintExporter:BaseExporter + { + private DebugVisitor visitor; + + public PrintExporter(Collection pages):base(pages) + { + visitor = new DebugVisitor(); + } + + + public override void Run () { + foreach (var page in Pages) { + ShowDebug(page); + } + } + + + void ShowDebug(IExportContainer container) + { + var visitor = new DebugVisitor(); + foreach (var item in container.ExportedItems) { + var exportContainer = item as IExportContainer; + var acceptor = item as IAcceptor; + if (exportContainer != null) { + if (acceptor != null) { + Console.WriteLine("--container--"); + acceptor.Accept(visitor); + } + ShowDebug(item as IExportContainer); + } else { + if (acceptor != null) { + Console.WriteLine("..Item..."); + acceptor.Accept(visitor); + } + } + } + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs new file mode 100644 index 0000000000..6be4ce0ada --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs @@ -0,0 +1,24 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 28.04.2013 + * Time: 19:49 + * + * 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.Visitors +{ + /// + /// Description of AbstractVisitor. + /// + public abstract class AbstractVisitor : IVisitor + { + public abstract void Visit(ExportColumn exportColumn); + public abstract void Visit(ExportContainer exportColumn); + public abstract void Visit(ExportText exportColumn); + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs similarity index 74% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitor.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs index 1f6c95140c..34af5a218d 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/DebugVisitor.cs @@ -10,27 +10,15 @@ using System; using System.Collections.Generic; using ICSharpCode.Reporting.PageBuilder.ExportColumns; -namespace ICSharpCode.Reporting.Exporter +namespace ICSharpCode.Reporting.Exporter.Visitors { - /// - /// Description of Visitor. - /// - /// - - 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 class DebugVisitor : AbstractVisitor { public override void Visit(ExportColumn exportColumn) { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/IAcceptor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IAcceptor.cs similarity index 86% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/IAcceptor.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IAcceptor.cs index 2c519b93aa..03f227975f 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/IAcceptor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IAcceptor.cs @@ -8,7 +8,7 @@ */ using System; -namespace ICSharpCode.Reporting.Exporter +namespace ICSharpCode.Reporting.Exporter.Visitors { /// /// Description of IAcceptor. diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/IVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs similarity index 89% rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/IVisitor.cs rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs index cfd08d4297..d0c775add7 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/IVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs @@ -10,7 +10,7 @@ using System; using System.Collections.Generic; using ICSharpCode.Reporting.PageBuilder.ExportColumns; -namespace ICSharpCode.Reporting.Exporter +namespace ICSharpCode.Reporting.Exporter.Visitors { public interface IVisitor { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/CreateGraphics.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/CreateGraphics.cs new file mode 100644 index 0000000000..e6885fa247 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/CreateGraphics.cs @@ -0,0 +1,28 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 24.04.2013 + * Time: 19:53 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Drawing; + +namespace ICSharpCode.Reporting.Globals +{ + /// + /// Description of CreateGraphics. + /// + public class CreateGraphics + { + public static Graphics FromSize (Size size){ + if (size == null) { + throw new ArgumentNullException("size"); + } + Bitmap bitmap = new Bitmap(size.Width,size.Height); + var graphics = Graphics.FromImage(bitmap); + return graphics; + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalValues.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalValues.cs index 4b708593af..11b5a7bfdb 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalValues.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalValues.cs @@ -27,5 +27,16 @@ namespace ICSharpCode.Reporting.Globals return DefaultReportName + ReportExtension; } } + + + public static Font DefaultFont + { + get { + return new Font("Microsoft Sans Serif", + 10, + FontStyle.Regular, + GraphicsUnit.Point); + } + } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs index 13e13aa924..8d565e8dd7 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseSection.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.Reporting.Items public BaseSection() { - Items = new List(); +// Items = new List(); } public BaseSection (string name) { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs index 002882f7ea..b1aaacbced 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/BaseTextItem.cs @@ -8,6 +8,7 @@ */ using System; using System.Drawing; +using ICSharpCode.Reporting.Globals; using ICSharpCode.Reporting.Interfaces; using ICSharpCode.Reporting.Interfaces.Export; using ICSharpCode.Reporting.PageBuilder.ExportColumns; @@ -25,16 +26,21 @@ namespace ICSharpCode.Reporting.Items public class BaseTextItem:PrintableItem,ITextItem { public BaseTextItem(){ + Name = "BaseTextItem"; + Font = GlobalValues.DefaultFont; } + public Font Font {get;set;} - public override IExportColumn CreateExportColumn() + + public override IExportColumn CreateExportColumn() { var ex = new ExportText(); ex.Name = Name; ex.Location = Location; ex.Size = Size; + ex.Font = Font; return ex; } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs index c85e9de301..5186c3870e 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/ReportContainer.cs @@ -21,12 +21,18 @@ namespace ICSharpCode.Reporting.Items /// public class ReportContainer:PrintableItem,IReportContainer { + public ReportContainer() { + items = new List(); } + private List items; - public List Items {get;set;} + public List Items { + get { return items; } + } + public override IExportColumn CreateExportColumn() { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs index 7e2e710cc7..f501458827 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/ContainerConverter.cs @@ -23,13 +23,11 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter /// internal class ContainerConverter { -// private ExportColumnFactory factory; public ContainerConverter(IReportContainer reportContainer,Point currentLocation ) { Container = reportContainer; CurrentLocation = currentLocation; -// factory = new ExportColumnFactory(); } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportContainer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportContainer.cs index 6c8ebb678f..0f53a920b3 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportContainer.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportContainer.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Exporter.Visitors; using ICSharpCode.Reporting.Interfaces.Export; namespace ICSharpCode.Reporting.PageBuilder.ExportColumns @@ -20,12 +21,14 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns { public ExportContainer() { - ExportedItems = new List(); + exportedItems = new List(); } - public List ExportedItems {get;set;} - + List exportedItems; + public List ExportedItems { + get { return exportedItems; } + } public void Accept(IVisitor visitor) { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportText.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportText.cs index bd8186dbef..95e583efe0 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportText.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportText.cs @@ -7,14 +7,24 @@ * To change this template use Tools | Options | Coding | Edit Standard Headers. */ using System; +using System.Drawing; using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Exporter.Visitors; +using ICSharpCode.Reporting.Interfaces.Export; namespace ICSharpCode.Reporting.PageBuilder.ExportColumns { /// /// Description of ExportText. /// - public class ExportText:ExportColumn,IAcceptor + /// + public interface IExportText : IExportColumn + { + Font Font {get;set;} + } + + + public class ExportText:ExportColumn,IExportText,IAcceptor { public ExportText() { @@ -24,5 +34,8 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns { visitor.Visit(this); } + + public Font Font {get;set;} + } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj index 37b7b7ee18..f4d8956ae6 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj @@ -65,13 +65,16 @@ + + + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageBuilderFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageBuilderFixture.cs index 7fac7a11db..bd57c50c0c 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageBuilderFixture.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageBuilderFixture.cs @@ -62,51 +62,7 @@ namespace ICSharpCode.Reporting.Test.PageBuilder #endregion - #region PageInfo - [Test] - public void PageInfoPageNumberIsOne() { - reportCreator.BuildExportList(); - var pageInfo = reportCreator.Pages[0].PageInfo; - Assert.That(pageInfo.PageNumber,Is.EqualTo(1)); - } - - - [Test] - public void PageInfoReportName() { - reportCreator.BuildExportList(); - var pi = reportCreator.Pages[0].PageInfo; - Assert.That(pi.ReportName,Is.EqualTo("Report1")); -// Console.WriteLine("----------------"); -// foreach (var page in reportCreator.Pages) { -// TestHelper.ShowDebug(page); -// } - } - - /* - 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); - - } - } - } - } - */ - - #endregion [SetUp] public void LoadFromStream() diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageFixture.cs new file mode 100644 index 0000000000..b427fc2dd7 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/PageBuilder/PageFixture.cs @@ -0,0 +1,78 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 24.04.2013 + * Time: 19:55 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.IO; +using System.Reflection; +using System.Drawing; +using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Globals; +using ICSharpCode.Reporting.Interfaces; +using ICSharpCode.Reporting.Interfaces.Export; +using ICSharpCode.Reporting.PageBuilder; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.PageBuilder +{ + [TestFixture] + public class PageFixture + { + + private IReportCreator reportCreator; + + [Test] + public void CreateGraphicsFromPageSize () { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + Graphics g = CreateGraphics.FromSize(page.Size); + Assert.That(g,Is.Not.Null); + } +// http://www.dev102.com/2008/10/09/measure-string-size-in-pixels-c/ + //http://www.codeproject.com/Articles/2118/Bypass-Graphics-MeasureString-limitations + //http://codebetter.com/patricksmacchia/2009/08/31/reveal-hidden-api-usage-tricks-from-any-net-application/ + + + [Test] + public void GraphicsIsSameSizeAsPage() { + reportCreator.BuildExportList(); + var page = reportCreator.Pages[0]; + var graphics = CreateGraphics.FromSize(page.Size); + Assert.That(graphics.VisibleClipBounds.Width,Is.EqualTo(page.Size.Width)); + Assert.That(graphics.VisibleClipBounds.Height,Is.EqualTo(page.Size.Height)); + } + + #region PageInfo + + [Test] + public void PageInfoPageNumberIsOne() { + reportCreator.BuildExportList(); + var pageInfo = reportCreator.Pages[0].PageInfo; + Assert.That(pageInfo.PageNumber,Is.EqualTo(1)); + } + + + [Test] + public void PageInfoReportName() { + reportCreator.BuildExportList(); + var pi = reportCreator.Pages[0].PageInfo; + Assert.That(pi.ReportName,Is.EqualTo("Report1")); + } + + + #endregion + + [SetUp] + public void LoadFromStream() + { + System.Reflection.Assembly asm = Assembly.GetExecutingAssembly(); + var stream = asm.GetManifestResourceStream(TestHelper.RepWithTwoItems); + var reportingFactory = new ReportingFactory(); + reportCreator = reportingFactory.ReportCreator(stream); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/ReportItems/TextItemFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/ReportItems/TextItemFixture.cs new file mode 100644 index 0000000000..404e790edf --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/ReportItems/TextItemFixture.cs @@ -0,0 +1,53 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 25.04.2013 + * Time: 19:45 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using ICSharpCode.Reporting.Globals; +using ICSharpCode.Reporting.Items; +using ICSharpCode.Reporting.PageBuilder.ExportColumns; +using NUnit.Framework; + +namespace ICSharpCode.Reporting.Test.ReportItems +{ + [TestFixture] + public class TextItemFixture + { + [Test] + public void IsNameSetOnInitialize() { + var ti = new BaseTextItem(); + Assert.That (ti.Name,Is.EqualTo("BaseTextItem")); + } + + + [Test] + public void ChangeName() { + var newName = "changed"; + var ti = new BaseTextItem(); + ti.Name = newName; + Assert.That(ti.Name,Is.EqualTo(newName)); + } + + + [Test] + public void DefaultFontOnInitialize() { + var ti = new BaseTextItem(); + Assert.That(ti.Font,Is.EqualTo(GlobalValues.DefaultFont)); + } + + [Test] + public void CreateExportText() { + var ti = new BaseTextItem(); + var exportText = (ExportText)ti.CreateExportColumn(); + Assert.That(exportText.Name,Is.EqualTo(ti.Name)); + Assert.That(exportText.Location,Is.EqualTo(ti.Location)); + Assert.That(exportText.Size,Is.EqualTo(ti.Size)); + Assert.That(exportText.Font , Is.EqualTo(GlobalValues.DefaultFont)); + } + + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestHelper.cs index 5b2073dd80..d616732761 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestHelper.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/TestHelper.cs @@ -8,6 +8,7 @@ */ using System; using ICSharpCode.Reporting.Exporter; +using ICSharpCode.Reporting.Exporter.Visitors; using ICSharpCode.Reporting.Interfaces.Export; namespace ICSharpCode.Reporting.Test