From 8d729889faa383e34acde06b86b689d20a55feb4 Mon Sep 17 00:00:00 2001 From: Claudio Schaad Date: Sat, 6 Sep 2025 14:38:34 +0200 Subject: [PATCH] pdf nicer --- Services/PdfExportService.cs | 60 +++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 8 deletions(-) diff --git a/Services/PdfExportService.cs b/Services/PdfExportService.cs index d3a9add..eb92261 100644 --- a/Services/PdfExportService.cs +++ b/Services/PdfExportService.cs @@ -123,8 +123,14 @@ namespace ShiftScheduler.Services foreach (var day in Enumerable.Range(0, dayInWeek)) { var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day)); - var morningTime = shiftWithTransport?.Shift.MorningTime.Length > 0 ? $"{shiftWithTransport?.Shift.MorningTime}" : ""; - table.Cell().Element(CellStyleMiddle).Text(morningTime); + if (!string.IsNullOrWhiteSpace(shiftWithTransport?.Shift.MorningTime)) + { + table.Cell().Element(CellStyleTimes).Text($" {shiftWithTransport.Shift.MorningTime}"); + } + else + { + table.Cell().Element(CellStyleMiddle).Text(""); + } } foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek)) { @@ -135,8 +141,14 @@ namespace ShiftScheduler.Services foreach (var day in Enumerable.Range(0, dayInWeek)) { var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day)); - var afternoonTime = shiftWithTransport?.Shift.AfternoonTime.Length > 0 ? $"{shiftWithTransport?.Shift.AfternoonTime}" : ""; - table.Cell().Element(CellStyleMiddle).Text(afternoonTime); + if (!string.IsNullOrWhiteSpace(shiftWithTransport?.Shift.AfternoonTime)) + { + table.Cell().Element(CellStyleTimes).Text($" {shiftWithTransport.Shift.AfternoonTime}"); + } + else + { + table.Cell().Element(CellStyleMiddle).Text(""); + } } foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek)) { @@ -147,8 +159,14 @@ namespace ShiftScheduler.Services foreach (var day in Enumerable.Range(0, dayInWeek)) { var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day)); - var transportInfo = GetTransportSummary(shiftWithTransport); - table.Cell().Element(CellStyleLast).Text(transportInfo); + var transportSummary = GetTransportSummary(shiftWithTransport); + if (!string.IsNullOrWhiteSpace(transportSummary)) + { + table.Cell().Element(CellStyleTransport).Text(transportSummary); + } + else { + table.Cell().Element(CellStyleLast).Text(""); + } } foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek)) { @@ -166,7 +184,7 @@ namespace ShiftScheduler.Services private static string GetTransportSummary(ShiftWithTransport? shiftWithTransport) { - if (shiftWithTransport == null) return "-"; + if (shiftWithTransport == null) return ""; var transportLines = new List(); @@ -189,7 +207,7 @@ namespace ShiftScheduler.Services { var departure = transport.DepartureTime.ToString("HH:mm"); var arrival = transport.ArrivalTime.ToString("HH:mm"); - return $"{transport.Platform}: {departure}→{arrival}"; + return $" {transport.Platform}: {departure} → {arrival}"; } private static void RenderEmptyCell(TableDescriptor table) @@ -220,6 +238,32 @@ namespace ShiftScheduler.Services .AlignMiddle(); } + private static IContainer CellStyleTimes(IContainer container) + { + return container + .Padding(0) + .BorderLeft(boarderWidth) + .BorderRight(boarderWidth) + .BorderColor(borderColor) + .AlignCenter() + .AlignMiddle() + .Width(37, Unit.Millimetre) + .Background(Color.FromHex("#c7ffd6")); + } + + private static IContainer CellStyleTransport(IContainer container) + { + return container + .Padding(0) + .BorderLeft(boarderWidth) + .BorderBottom(boarderWidth) + .BorderRight(boarderWidth) + .BorderColor(borderColor) + .AlignCenter() + .AlignMiddle().Width(37, Unit.Millimetre) + .Background(Color.FromHex("#bdccff")); + } + private static IContainer CellStyleLast(IContainer container) { return container