|
using System;
using System.Data;
using System.Drawing;
using ReportPrinting;
namespace ReportDocumentTesting
{
/// <summary>
/// Test the SectionBox
/// </summary>
public class ReportTest12 : IReportMaker
{
public void MakeDocument(ReportDocument reportDocument)
{
TextStyle.ResetStyles();
ReportBuilder builder = new ReportBuilder(reportDocument);
builder.StartLinearLayout (Direction.Vertical);
SectionBox box;
LinearSections contents;
// Box 1
box = new SectionBox();
box.Background = Brushes.LightPink;
box.Width = 4;
box.Height = 2.5f;
box.Padding = 0.5f;
box.Border = new Pen (Color.Red, 0.25f);
box.UseFullWidth = true;
box.HorizontalAlignment = HorizontalAlignment.Center;
contents = new LinearSections ();
contents.AddSection (new ReportSectionText ("A centered box, 4 by 2.5 inches", TextStyle.Normal));
contents.AddSection (new ReportSectionText ("0.5 inch padding", TextStyle.Normal));
contents.AddSection (new ReportSectionText ("0.25 inch borders", TextStyle.Normal));
box.Content = contents;
builder.AddSection (box);
// Box 2
box = new SectionBox();
box.Background = Brushes.LightBlue;
box.Width = 5;
box.Padding = 0.1f;
box.Border = reportDocument.NormalPen;
box.Margin = 0.3f;
contents = new LinearSections ();
contents.AddSection (new ReportSectionText ("A box, 4 by x inches (height should scale to fit contents)", TextStyle.Normal));
contents.AddSection (new ReportSectionText ("0.1 inch padding", TextStyle.Normal));
contents.AddSection (new ReportSectionText (MainForm.Text1, TextStyle.Normal));
box.Content = contents;
builder.AddSection (box);
builder.AddPageBreak();
// Box 3
box = new SectionBox();
box.Background = Brushes.LightBlue;
box.Padding = 0.1f;
box.Border = reportDocument.NormalPen;
box.Margin = 0.3f;
box.UseFullHeight = true;
box.VerticalAlignment = VerticalAlignment.Middle;
box.UseFullWidth = true;
box.HorizontalAlignment = HorizontalAlignment.Center;
contents = new LinearSections ();
contents.AddSection (new ReportSectionText ("A box, x by x inches ( width and height should scale to fit contents)", TextStyle.Normal));
contents.AddSection (new ReportSectionText ("0.1 inch padding", TextStyle.Normal));
contents.AddSection (new ReportSectionText ("0.3 inch margins", TextStyle.Normal));
contents.AddSection (new ReportSectionText ("centered vertically and horizontally", TextStyle.Normal));
box.Content = contents;
builder.AddSection (box);
builder.AddPageBreak();
// Box 4
box = new SectionBox();
box.WidthPercent = 50;
box.HeightPercent = 50;
box.Border = reportDocument.ThickPen;
contents = new LinearSections ();
contents.AddSection (new ReportSectionText ("A box, 50% by 50%", TextStyle.Normal));
box.Content = contents;
builder.AddSection (box);
// Box 5
box = new SectionBox();
box.WidthPercent = 100;
box.HeightPercent = 50; // uses half of the remaining area...
box.Border = reportDocument.ThickPen;
contents = new LinearSections ();
contents.AddSection (new ReportSectionText ("A box, 100% by half of what's left", TextStyle.Normal));
box.Content = contents;
builder.AddSection (box);
builder.AddPageBreak();
builder.StartLayeredLayout ();
builder.AddTextSection ("This page uses a layered approach");
box = new SectionBox();
box.Width = 2;
box.Height = 2;
box.OffsetLeft = 1;
box.OffsetTop = 2;
box.Border = reportDocument.ThickPen;
box.Background = Brushes.Ivory;
contents = new LinearSections ();
contents.AddSection (new ReportSectionText ("2x2 at 1,2", TextStyle.Normal));
box.Content = contents;
builder.AddSection (box);
box = new SectionBox();
box.Width = 2;
box.Height = 2;
box.OffsetLeft = 2;
box.OffsetTop = 3;
box.Border = reportDocument.ThickPen;
box.Background = Brushes.Ivory;
contents = new LinearSections ();
contents.AddSection (new ReportSectionText ("2x2 at 2,3", TextStyle.Normal));
box.Content = contents;
builder.AddSection (box);
box = new SectionBox();
box.Width = 3;
box.Height = 3;
box.HorizontalAlignment = HorizontalAlignment.Right;
box.VerticalAlignment = VerticalAlignment.Bottom;
box.Border = reportDocument.ThickPen;
box.Background = Brushes.Ivory;
contents = new LinearSections ();
contents.AddSection (new ReportSectionText ("3x3", TextStyle.Normal));
box.Content = contents;
builder.AddSection (box);
builder.FinishLayeredLayout();
builder.FinishLinearLayout ();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.