コード例 #1
0
        private void GenerateStructure(IContainer container, int level)
        {
            if (level <= 0)
            {
                container.Background(Placeholders.BackgroundColor()).Height(10);
                return;
            }

            level--;

            if (level % 3 == 0)
            {
                container
                .Border(level / 4f)
                .BorderColor(Colors.Black)
                .Row(row =>
                {
                    row.RelativeItem().Element(x => GenerateStructure(x, level));
                    row.RelativeItem().Element(x => GenerateStructure(x, level));
                });
            }
            else
            {
                container
                .Border(level / 4f)
                .BorderColor(Colors.Black)
                .Column(column =>
                {
                    column.Item().Element(x => GenerateStructure(x, level));
                    column.Item().Element(x => GenerateStructure(x, level));
                });
            }
        }
コード例 #2
0
        public void Column()
        {
            RenderingTest
            .Create()
            .PageSize(PageSizes.A4)
            .ShowResults()
            .ProducePdf()
            .Render(container =>
            {
                container.Column(column =>
                {
                    foreach (var i in Enumerable.Range(0, 10))
                    {
                        column.Item().Element(Block);
                    }

                    static void Block(IContainer container)
                    {
                        container
                        .Width(72)
                        .Height(3.5f, Unit.Inch)
                        .Height(1.5f, Unit.Inch)
                        .Background(Placeholders.BackgroundColor());
                    }
                });
コード例 #3
0
        public void RandomColorMatrix()
        {
            RenderingTest
            .Create()
            .PageSize(300, 300)
            .Render(container =>
            {
                container
                .Padding(25)
                .Grid(grid =>
                {
                    grid.Columns(5);

                    Enumerable
                    .Range(0, 25)
                    .Select(x => Placeholders.BackgroundColor())
                    .ToList()
                    .ForEach(x => grid.Item().Height(50).Background(x));
                });
            });
        }
コード例 #4
0
        public void Inline_AlignLeft_BaselineBottom()
        {
            RenderingTest
            .Create()
            .PageSize(800, 600)
            .ProduceImages()
            .ShowResults()
            .Render(container =>
            {
                container
                .Padding(20)
                .MinimalBox()
                .Border(1)
                .Background(Colors.Grey.Lighten4)
                .Inlined(inlined =>
                {
                    inlined.VerticalSpacing(50);
                    inlined.HorizontalSpacing(25);
                    inlined.AlignRight();
                    inlined.BaselineMiddle();

                    foreach (var _ in Enumerable.Range(0, 100))
                    {
                        inlined.Item().Element(RandomBlock);
                    }
                });
            });

            void RandomBlock(IContainer container)
            {
                container
                .Width(Placeholders.Random.Next(1, 5) * 20)
                .Height(Placeholders.Random.Next(1, 5) * 20)
                .Border(1)
                .BorderColor(Colors.Grey.Darken2)
                .Background(Placeholders.BackgroundColor());
            }
        }
コード例 #5
0
        public void Inlined()
        {
            RenderingTest
            .Create()
            .PageSize(800, 650)
            .ProduceImages()
            .ShowResults()
            .Render(container =>
            {
                container
                .Padding(25)
                .Decoration(decoration =>
                {
                    decoration.Before().Text(text =>
                    {
                        text.DefaultTextStyle(TextStyle.Default.Size(20));

                        text.CurrentPageNumber();
                        text.Span(" / ");
                        text.TotalPages();
                    });

                    decoration
                    .Content()
                    .PaddingTop(25)
                    //.MinimalBox()
                    .Border(1)
                    .Background(Colors.Grey.Lighten2)
                    .Inlined(inlined =>
                    {
                        inlined.Spacing(25);

                        inlined.AlignSpaceAround();
                        inlined.BaselineMiddle();

                        var random = new Random(123);

                        foreach (var _ in Enumerable.Range(0, 50))
                        {
                            var width  = random.Next(2, 7);
                            var height = random.Next(2, 7);

                            var sizeText = $"{width}×{height}";

                            inlined
                            .Item()
                            .Border(1)
                            .Width(width * 25)
                            .Height(height * 25)
                            .Background(Placeholders.BackgroundColor())
                            .Layers(layers =>
                            {
                                layers.Layer().Grid(grid =>
                                {
                                    grid.Columns(width);
                                    Enumerable.Range(0, width * height).ToList().ForEach(x => grid.Item().Border(1).BorderColor(Colors.White).Width(25).Height(25));
                                });

                                layers
                                .PrimaryLayer()
                                .AlignCenter()
                                .AlignMiddle()
                                .Text(sizeText)
                                .FontSize(15);
                            });
                        }
                    });
                });
            });
        }