コード例 #1
0
ファイル: TableExamples.cs プロジェクト: lmingle/library
        public void PagingSupport()
        {
            RenderingTest
            .Create()
            .ProducePdf()
            .PageSize(420, 220)
            .ShowResults()
            .Render(container =>
            {
                container
                .Padding(10)
                .MinimalBox()
                .Border(1)
                .Table(table =>
                {
                    table.ColumnsDefinition(columns =>
                    {
                        columns.RelativeColumn();
                        columns.RelativeColumn();
                        columns.RelativeColumn();
                        columns.RelativeColumn();
                    });

                    // by using custom 'Element' method, we can reuse visual configuration
                    table.Cell().Element(Block).Text(Placeholders.Label());
                    table.Cell().Element(Block).Text(Placeholders.Label());
                    table.Cell().Element(Block).Text(Placeholders.Paragraph());
                    table.Cell().Element(Block).Text(Placeholders.Label());
                });
            });
        }
コード例 #2
0
ファイル: ShowOnceExample.cs プロジェクト: lmingle/library
        public void ShowOnce()
        {
            RenderingTest
            .Create()
            .ProduceImages()
            .ShowResults()
            .RenderDocument(container =>
            {
                container.Page(page =>
                {
                    page.Margin(20);
                    page.Size(PageSizes.A7.Landscape());
                    page.PageColor(Colors.White);

                    page.Header().Text("With show once").SemiBold();

                    page.Content().PaddingVertical(5).Row(row =>
                    {
                        row.RelativeItem()
                        .Background(Colors.Grey.Lighten2)
                        .Border(1)
                        .Padding(5)
                        .ShowOnce()
                        .Text(Placeholders.Label());

                        row.RelativeItem(2)
                        .Border(1)
                        .Padding(5)
                        .Text(Placeholders.Paragraph());
                    });

                    page.Footer().Text(text =>
                    {
                        text.Span("Page ");
                        text.CurrentPageNumber();
                        text.Span(" out of ");
                        text.TotalPages();
                    });
                });
            });
        }
コード例 #3
0
        public void DomainSpecificLanguage()
        {
            RenderingTest
            .Create()
            .PageSize(600, 310)
            .Render(container =>
            {
                container
                .Padding(25)
                .Grid(grid =>
                {
                    grid.Columns(10);

                    for (var i = 1; i <= 4; i++)
                    {
                        grid.Item(2).LabelCell(Placeholders.Label());
                        grid.Item(3).ValueCell().Image(Placeholders.Image(200, 150));
                    }
                });
            });
        }
コード例 #4
0
ファイル: FrameExample.cs プロジェクト: lmingle/library
 public void Frame()
 {
     RenderingTest
     .Create()
     .PageSize(550, 400)
     .ShowResults()
     .Render(container =>
     {
         container
         .Background("#FFF")
         .Padding(25)
         .Column(column =>
         {
             for (var i = 1; i <= 4; i++)
             {
                 column.Item().Row(row =>
                 {
                     row.RelativeItem(2).LabelCell(Placeholders.Label());
                     row.RelativeItem(3).ValueCell().Text(Placeholders.Paragraph());
                 });
             }
         });
     });
 }
コード例 #5
0
        public static ReportModel GetReport()
        {
            return(new ReportModel
            {
                Title = "Sample Report Document",
                HeaderFields = HeaderFields(),

                LogoData = Helpers.GetImage("Logo.png"),
                Sections = Enumerable.Range(0, 40).Select(x => GenerateSection()).ToList(),
                Photos = Enumerable.Range(0, 25).Select(x => GetReportPhotos()).ToList()
            });

            List <ReportHeaderField> HeaderFields()
            {
                return(new List <ReportHeaderField>
                {
                    new ReportHeaderField()
                    {
                        Label = "Scope",
                        Value = "Internal activities"
                    },
                    new ReportHeaderField()
                    {
                        Label = "Author",
                        Value = "Marcin Ziąbek"
                    },
                    new ReportHeaderField()
                    {
                        Label = "Date",
                        Value = DateTime.Now.ToString("g")
                    },
                    new ReportHeaderField()
                    {
                        Label = "Status",
                        Value = "Completed, found 2 issues"
                    }
                });
            }

            ReportSection GenerateSection()
            {
                var sectionLength = Helpers.Random.NextDouble() > 0.75
                    ? Helpers.Random.Next(20, 40)
                    : Helpers.Random.Next(5, 10);

                return(new ReportSection
                {
                    Title = Placeholders.Label(),
                    Parts = Enumerable.Range(0, sectionLength).Select(x => GetRandomElement()).ToList()
                });
            }

            ReportSectionElement GetRandomElement()
            {
                var random = Helpers.Random.NextDouble();

                if (random < 0.9f)
                {
                    return(GetTextElement());
                }

                if (random < 0.95f)
                {
                    return(GetMapElement());
                }

                return(GetPhotosElement());
            }

            ReportSectionText GetTextElement()
            {
                return(new ReportSectionText
                {
                    Label = Placeholders.Label(),
                    Text = Placeholders.Paragraph()
                });
            }

            ReportSectionMap GetMapElement()
            {
                return(new ReportSectionMap
                {
                    Label = "Location",
                    Location = Helpers.RandomLocation()
                });
            }

            ReportSectionPhotos GetPhotosElement()
            {
                return(new ReportSectionPhotos
                {
                    Label = "Photos",
                    PhotoCount = Helpers.Random.Next(1, 15)
                });
            }

            ReportPhoto GetReportPhotos()
            {
                return(new ReportPhoto()
                {
                    Comments = Placeholders.Sentence(),
                    Date = DateTime.Now - TimeSpan.FromDays(Helpers.Random.NextDouble() * 100),
                    Location = Helpers.RandomLocation()
                });
            }
        }