Helpers.cs 1.3 KB

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