示例#1
0
 public void Frame(IContainer container)
 {
     container
     .Background("#FFF")
     .Padding(25)
     .Stack(stack =>
     {
         for (var i = 1; i <= 4; i++)
         {
             stack.Element().Row(row =>
             {
                 row.RelativeColumn(2).LabelCell().Text(TextPlaceholder.Label());
                 row.RelativeColumn(3).ValueCell().Text(TextPlaceholder.Paragraph());
             });
         }
     });
 }
示例#2
0
        public static ReportModel GetReport()
        {
            return(new ReportModel
            {
                Title = "Sample Report Document",
                HeaderFields = HeaderFields(),

                LogoData = Helpers.GetImage("logo.png"),
                Sections = Enumerable.Range(0, 10).Select(x => GenerateSection()).ToList(),
                Photos = Enumerable.Range(0, 10).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")
                    }
                });
            }

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

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

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

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

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

                return(GetPhotosElement());
            }

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

            ReportSectionMap GetMapElement()
            {
                var rnd = Helpers.Random.Next(0, 64);

                return(new ReportSectionMap
                {
                    Label = "Location",
                    ImageSource = x => Helpers.GetDocumentMap($"{rnd}.jpg"),
                    Location = Helpers.RandomLocation()
                });
            }

            ReportSectionPhotos GetPhotosElement()
            {
                return(new ReportSectionPhotos
                {
                    Label = "Photos",
                    Photos = Enumerable
                             .Range(0, Helpers.Random.Next(1, 10))
                             .Select(x => Helpers.Random.Next(0, 128))
                             .Select(x => Helpers.GetPhoto($"{x}.jpg"))
                             .ToList()
                });
            }

            ReportPhoto GetReportPhotos()
            {
                var photoId = Helpers.Random.Next(0, 128);
                var mapId   = Helpers.Random.Next(0, 64);

                return(new ReportPhoto()
                {
                    PhotoData = Helpers.GetPhoto($"{photoId}.jpg"),

                    Comments = TextPlaceholder.Paragraph(),
                    Date = DateTime.Now - TimeSpan.FromDays(Helpers.Random.NextDouble() * 100),
                    Location = Helpers.RandomLocation(),

                    MapContextSource = x => Helpers.GetContextMap($"{mapId}.jpg"),
                    MapDetailsSource = x => Helpers.GetDetailsMap($"{mapId}.jpg")
                });
            }
        }