pdf nicer

This commit is contained in:
Claudio Schaad 2025-09-06 14:38:34 +02:00
parent 6dd909a05b
commit 8d729889fa

View file

@ -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<string>();
@ -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