Helpers.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using QuestPDF.Fluent;
  3. using QuestPDF.Infrastructure;
  4. namespace QuestPDF.ReportSample.Layouts
  5. {
  6. public static class Helpers
  7. {
  8. static IContainer Cell(this IContainer container, string color)
  9. {
  10. return container
  11. .Border(0.5f)
  12. .Background(color)
  13. .Padding(5);
  14. }
  15. public static IContainer LightCell(this IContainer container)
  16. {
  17. return container.Cell("#0000");
  18. }
  19. public static IContainer DarkCell(this IContainer container)
  20. {
  21. return container.Cell("#1000");
  22. }
  23. public static string Format(this Location location)
  24. {
  25. if (location == null)
  26. return string.Empty;
  27. var lon = location.Longitude;
  28. var lat = location.Latitude;
  29. var typeLon = lon > 0 ? "E" : "W";
  30. lon = Math.Abs(lon);
  31. var typeLat = lat > 0 ? "N" : "S";
  32. lat = Math.Abs(lat);
  33. return $"{lat:F5}° {typeLat} {lon:F5}° {typeLon}";
  34. }
  35. }
  36. }