|
using System;
using System.Drawing;
using ReportPrinting;
namespace ReportDocumentTesting
{
/// <summary>
/// Sets up a basic report showing different formats of text.
/// </summary>
public class ReportTest1 : IReportMaker
{
public void MakeDocument(ReportDocument reportDocument)
{
// Always reset the text styles if you have multiple methods that
// set them
TextStyle.ResetStyles();
// Create a ReportBuilder object that assists with building a report
ReportBuilder builder = new ReportBuilder(reportDocument);
// Before adding sections, a layout must be started.
// We are using a linear layout - vertically, which means
// each new section starts below the last one.
builder.StartLinearLayout(Direction.Vertical);
// Add various text sections in different headings
builder.AddTextSection("Heading1", TextStyle.Heading1);
builder.AddTextSection("Heading2", TextStyle.Heading2);
builder.AddTextSection("Heading3", TextStyle.Heading3);
builder.AddTextSection("Normal text");
// Create new styles for underline and bold
// TextStyles must have a default style to inherit properties from
TextStyle underlined = new TextStyle(TextStyle.Normal);
underlined.Underline = true;
builder.AddTextSection("Underlined", underlined);
TextStyle bold = new TextStyle(TextStyle.Normal);
bold.Bold = true;
builder.AddTextSection("Bold", bold);
// Let's do color
TextStyle blue = new TextStyle(TextStyle.Normal);
blue.Brush = Brushes.Blue;
builder.AddTextSection("Blue", blue);
TextStyle red = new TextStyle(TextStyle.Normal);
red.Brush = Brushes.Red;
builder.AddTextSection("Red", red);
TextStyle chocolate = new TextStyle(TextStyle.Normal);
chocolate.Brush = Brushes.Chocolate;
builder.AddTextSection("This is chocolate if you were curious.", chocolate);
// Finish a layout that we started
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.