2
0

Helpers.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System;
  2. using System.IO;
  3. using QuestPDF.ReportSample.Layouts;
  4. using SkiaSharp;
  5. namespace QuestPDF.ReportSample
  6. {
  7. public static class Helpers
  8. {
  9. public static Random Random { get; } = new Random();
  10. public static string GetTestItem(string path) => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources", path);
  11. public static byte[] GetDocumentMap(string name) => GetImage(Path.Combine("Maps", "Document", name));
  12. public static byte[] GetDetailsMap(string name) => GetImage(Path.Combine("Maps", "Details", name));
  13. public static byte[] GetContextMap(string name) => GetImage(Path.Combine("Maps", "Context", name));
  14. public static byte[] GetPhoto(string name) => GetImage(Path.Combine("Photos", name));
  15. public static byte[] GetImage(string name)
  16. {
  17. var photoPath = GetTestItem(name);
  18. return SKImage.FromEncodedData(photoPath).EncodedData.ToArray();
  19. }
  20. public static Location RandomLocation()
  21. {
  22. return new Location
  23. {
  24. Longitude = Helpers.Random.NextDouble() * 360f - 180f,
  25. Latitude = Helpers.Random.NextDouble() * 180f - 90f
  26. };
  27. }
  28. }
  29. }