Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ffba35eff | ||
|
|
f1cf01ff88 | ||
|
|
3c74e3873a |
No files matched your search
@@ -173,6 +173,56 @@ public sealed class ClassTeacherViewModelsTests
|
|||||||
Assert.True(engeBox.ContentHeight <= 60 + 0.01f);
|
Assert.True(engeBox.ContentHeight <= 60 + 0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Samstage/Sonntage ohne Eintrag sind normalerweise keine Schultage - "keine Fehlzeit" dort ist
|
||||||
|
// keine Leistung und soll dezent ausgegraut statt gleichwertig mit echten Schultagen erscheinen.
|
||||||
|
// Ein tatsächlicher Eintrag an einem Wochenendtag bleibt dagegen unverändert farbig.
|
||||||
|
[Fact]
|
||||||
|
public void ElternbriefKalender_GrautWochenendtageOhneEintragAus()
|
||||||
|
{
|
||||||
|
var month = new DateOnly(2026, 9, 1);
|
||||||
|
var drawing = StudentAttendanceCalendarDrawingBuilder.Build("Ada Müller", month, [], []);
|
||||||
|
|
||||||
|
var dayCells = drawing.Commands
|
||||||
|
.Zip(drawing.Commands.Skip(1), (first, second) => (first, second))
|
||||||
|
.Where(pair => pair.first is DrawRoundedRectangle && pair.second is DrawStringEx text
|
||||||
|
&& int.TryParse(text.Text, out _))
|
||||||
|
.Select(pair => ((DrawRoundedRectangle)pair.first, int.Parse(((DrawStringEx)pair.second).Text)))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
Assert.NotEmpty(dayCells);
|
||||||
|
foreach (var (rectangle, day) in dayCells)
|
||||||
|
{
|
||||||
|
var isWeekend = new DateOnly(2026, 9, day).DayOfWeek is DayOfWeek.Saturday or DayOfWeek.Sunday;
|
||||||
|
Assert.Equal(isWeekend ? "#F3F4F6" : "#FFFFFF", rectangle.FillColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ein Eintrag (z.B. ein dokumentiertes Ereignis) an einem Wochenendtag trägt echte Information
|
||||||
|
// und darf deshalb nicht vom "ausgrauen" betroffen sein.
|
||||||
|
[Fact]
|
||||||
|
public void ElternbriefKalender_GrautWochenendtagMitEintragNichtAus()
|
||||||
|
{
|
||||||
|
var month = new DateOnly(2026, 9, 1);
|
||||||
|
var samstag = Enumerable.Range(1, 30)
|
||||||
|
.Select(day => new DateOnly(2026, 9, day))
|
||||||
|
.First(d => d.DayOfWeek == DayOfWeek.Saturday);
|
||||||
|
var absences = new[]
|
||||||
|
{
|
||||||
|
new ClassAbsenceDaySummaryRow(samstag, "Ada Müller", 1, 6, 270,
|
||||||
|
["Deu"], [1, 2, 3, 4, 5, 6], ["nicht entsch."], ["Absent"], null, null, true),
|
||||||
|
};
|
||||||
|
|
||||||
|
var drawing = StudentAttendanceCalendarDrawingBuilder.Build("Ada Müller", month, absences, []);
|
||||||
|
|
||||||
|
var samstagsZelle = drawing.Commands
|
||||||
|
.Zip(drawing.Commands.Skip(1), (first, second) => (first, second))
|
||||||
|
.Where(pair => pair.first is DrawRoundedRectangle && pair.second is DrawStringEx text
|
||||||
|
&& text.Text == "U")
|
||||||
|
.Select(pair => (DrawRoundedRectangle)pair.first)
|
||||||
|
.Single();
|
||||||
|
Assert.NotEqual("#F3F4F6", samstagsZelle.FillColor);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ElternbriefFehltage_ListetDatumUmfangUndEntschuldigungsstatus()
|
public void ElternbriefFehltage_ListetDatumUmfangUndEntschuldigungsstatus()
|
||||||
{
|
{
|
||||||
@@ -199,6 +249,85 @@ public sealed class ClassTeacherViewModelsTests
|
|||||||
Assert.DoesNotContain("09.09.2026", labels);
|
Assert.DoesNotContain("09.09.2026", labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regression: Die Spaltenpositionen wurden versehentlich zusätzlich mit millimeterScale
|
||||||
|
// multipliziert (analog zu echten mm-Maßen wie der Zeilenhöhe) - bei einer in "pt" statt "mm"
|
||||||
|
// deklarierten Vorlage (millimeterScale ≈ 2.83) lag die Status-Spalte dadurch weit außerhalb der
|
||||||
|
// tatsächlichen Box (x≈323 in einer nur 170 Einheiten breiten Box), statt nur ein Anteil von
|
||||||
|
// contentWidth zu sein.
|
||||||
|
[Fact]
|
||||||
|
public void ElternbriefFehltage_SpaltenBleibenInnerhalbDerBoxbreiteAuchBeiPunktBasierterVorlage()
|
||||||
|
{
|
||||||
|
var options = new AttendanceCalendarOptions(new DateOnly(2026, 9, 1), 1);
|
||||||
|
var absences = new[]
|
||||||
|
{
|
||||||
|
new ClassAbsenceDaySummaryRow(new DateOnly(2026, 9, 3), "Ada Müller", 1, 6, 270,
|
||||||
|
["Deu"], [1, 2, 3, 4, 5, 6], ["entsch."], ["Krank"], null, null, true),
|
||||||
|
};
|
||||||
|
const float contentWidth = 170f; const float millimeterScale = 2.8346f;
|
||||||
|
|
||||||
|
var drawing = StudentAbsenceDayListDrawingBuilder.Build("Ada Müller", options, absences,
|
||||||
|
contentWidth, millimeterScale);
|
||||||
|
var textBoxes = drawing.Commands.OfType<DrawStringEx>().ToList();
|
||||||
|
var rectangles = drawing.Commands.OfType<DrawRectangle>().ToList();
|
||||||
|
|
||||||
|
Assert.NotEmpty(textBoxes);
|
||||||
|
Assert.All(textBoxes, c => Assert.True(c.X + c.Width <= contentWidth + 0.01f,
|
||||||
|
$"'{c.Text}' reicht bis x={c.X + c.Width}, Box ist aber nur {contentWidth} breit."));
|
||||||
|
Assert.All(rectangles, c => Assert.True(c.X + c.Width <= contentWidth + 0.01f));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ClassAbsenceDaySummaryRow[] BuildFehltage(int count) =>
|
||||||
|
[.. Enumerable.Range(1, count).Select(day => new ClassAbsenceDaySummaryRow(
|
||||||
|
new DateOnly(2026, 9, day), "Ada Müller", 1, 0, 0,
|
||||||
|
["Deu"], [1], ["nicht entsch."], ["Absent"], null, null, true))];
|
||||||
|
|
||||||
|
// Regression: eine sehr lange einspaltige Fehlzeitenliste (FLOWDRAWBOX ohne automatischen
|
||||||
|
// Seitenumbruch-Schutz) konnte in der echten Vorlage zu einer unerklärlichen Leerseite führen.
|
||||||
|
// Ab ausreichend Zeilen UND ausreichend breiter Box wird deshalb zweispaltig (chronologisch:
|
||||||
|
// erste Hälfte links, Rest rechts) gerendert - das halbiert die benötigte Höhe ungefähr.
|
||||||
|
[Fact]
|
||||||
|
public void ElternbriefFehltage_RendertZweispaltigWennBoxBreitGenugIst()
|
||||||
|
{
|
||||||
|
var options = new AttendanceCalendarOptions(new DateOnly(2026, 9, 1), 1);
|
||||||
|
var absences = BuildFehltage(10);
|
||||||
|
|
||||||
|
var einspaltig = StudentAbsenceDayListDrawingBuilder.Build("Ada Müller", options, absences,
|
||||||
|
contentWidth: 170);
|
||||||
|
var zweispaltig = StudentAbsenceDayListDrawingBuilder.Build("Ada Müller", options, absences,
|
||||||
|
contentWidth: 400);
|
||||||
|
|
||||||
|
// Zweispaltig braucht ungefähr die Hälfte der Höhe der einspaltigen Variante für dieselben
|
||||||
|
// Daten (5 Zeilen je Spalte statt 10 Zeilen in einer Spalte, jeweils plus eine Kopfzeile).
|
||||||
|
Assert.True(zweispaltig.ContentHeight < einspaltig.ContentHeight * .7f,
|
||||||
|
$"Zweispaltig ({zweispaltig.ContentHeight}) sollte deutlich niedriger sein als einspaltig ({einspaltig.ContentHeight}).");
|
||||||
|
var texte = zweispaltig.Commands.OfType<DrawStringEx>().Select(c => c.Text).ToList();
|
||||||
|
Assert.Equal(2, texte.Count(t => t == "Datum")); // eine Kopfzeile je Spalte
|
||||||
|
Assert.Contains("01.09.2026", texte);
|
||||||
|
Assert.Contains("10.09.2026", texte);
|
||||||
|
var rechteckeUndTexte = zweispaltig.Commands.Select(c => c switch
|
||||||
|
{
|
||||||
|
DrawRectangle r => (float?)(r.X + r.Width), DrawStringEx s => s.X + s.Width, _ => null,
|
||||||
|
}).Where(x => x is not null);
|
||||||
|
Assert.All(rechteckeUndTexte, x => Assert.True(x <= 400.01f));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Regression: bei einer zu schmalen Box (wie der echten Vorlage dieses Nutzers, deren
|
||||||
|
// FLOWDRAWBOX für die Fehltagesliste aktuell nur 170 Einheiten breit ist) müssen zwei
|
||||||
|
// nebeneinanderliegende Spalten zu schmal für Datum/Umfang/Status werden - deshalb bleibt es
|
||||||
|
// dort bewusst einspaltig, auch bei vielen Zeilen.
|
||||||
|
[Fact]
|
||||||
|
public void ElternbriefFehltage_BleibtEinspaltigWennBoxZuSchmalFuerZweiSpaltenIst()
|
||||||
|
{
|
||||||
|
var options = new AttendanceCalendarOptions(new DateOnly(2026, 9, 1), 1);
|
||||||
|
var absences = BuildFehltage(10);
|
||||||
|
|
||||||
|
var drawing = StudentAbsenceDayListDrawingBuilder.Build("Ada Müller", options, absences,
|
||||||
|
contentWidth: 170);
|
||||||
|
var texte = drawing.Commands.OfType<DrawStringEx>().Select(c => c.Text).ToList();
|
||||||
|
|
||||||
|
Assert.Equal(1, texte.Count(t => t == "Datum"));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void GroupByStudentAndDay_FasstFehlstundenProSchuelerUndTagZusammen()
|
public void GroupByStudentAndDay_FasstFehlstundenProSchuelerUndTagZusammen()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -134,12 +134,18 @@ public static class StudentAttendanceCalendarDrawingBuilder
|
|||||||
var row = index / 7;
|
var row = index / 7;
|
||||||
var x = xOffset + column * cellWidth;
|
var x = xOffset + column * cellWidth;
|
||||||
var cellY = monthY + row * cellHeight;
|
var cellY = monthY + row * cellHeight;
|
||||||
|
// Sa/So (Spalten 5/6, siehe weekdays-Array oben) ohne Eintrag dezent ausgrauen - das
|
||||||
|
// sind normalerweise keine Schultage, "keine Fehlzeit" dort ist keine Leistung und
|
||||||
|
// soll nicht optisch gleichwertig neben echten schulfreien-Tage-Einträgen stehen. Ein
|
||||||
|
// tatsächlicher Eintrag an einem Wochenendtag (day.HasSignal) bleibt unverändert
|
||||||
|
// farbig, da er echte Information trägt.
|
||||||
|
var isMutedWeekend = column is 5 or 6 && !day.HasSignal;
|
||||||
commands.Add(new DrawRoundedRectangle(x + cellInset, cellY, cellWidth - 2 * cellInset,
|
commands.Add(new DrawRoundedRectangle(x + cellInset, cellY, cellWidth - 2 * cellInset,
|
||||||
cellHeight - cellInset, cellCornerRadius, "#D1D5DB", .35f,
|
cellHeight - cellInset, cellCornerRadius, isMutedWeekend ? "#E5E7EB" : "#D1D5DB", .35f,
|
||||||
day.HasSignal ? day.SignalColorHex : "#FFFFFF"));
|
day.HasSignal ? day.SignalColorHex : isMutedWeekend ? "#F3F4F6" : "#FFFFFF"));
|
||||||
commands.Add(new DrawStringEx(x, cellY + k, cellHeight - 2 * k, cellWidth,
|
commands.Add(new DrawStringEx(x, cellY + k, cellHeight - 2 * k, cellWidth,
|
||||||
day.HasSignal ? day.SignalCode : day.DayNumber, DrawingTextAlignment.AlignCenter, 7 * finalScale,
|
day.HasSignal ? day.SignalCode : day.DayNumber, DrawingTextAlignment.AlignCenter, 7 * finalScale,
|
||||||
Color: day.HasSignal ? "#FFFFFF" : "#374151", Bold: day.HasSignal));
|
Color: day.HasSignal ? "#FFFFFF" : isMutedWeekend ? "#B0B7C0" : "#374151", Bold: day.HasSignal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
y = gridStartY + 11 * k + 9 * k + maxWeeks * cellHeight + designTrailingGapY * k;
|
y = gridStartY + 11 * k + 9 * k + maxWeeks * cellHeight + designTrailingGapY * k;
|
||||||
@@ -166,9 +172,14 @@ public static class StudentAbsenceDayListDrawingBuilder
|
|||||||
AttendanceCalendarSize.Large => 1f,
|
AttendanceCalendarSize.Large => 1f,
|
||||||
_ => .88f,
|
_ => .88f,
|
||||||
};
|
};
|
||||||
// contentWidth/millimeterScale: siehe StudentAttendanceCalendarDrawingBuilder - contentWidth
|
// contentWidth ist die reale DRAWBOX/FLOWDRAWBOX-Breite (bereits in der Koordinaten-Einheit
|
||||||
// bleibt an die tatsächliche DRAWBOX/FLOWDRAWBOX-Deklaration im Layout-Skript gebunden,
|
// der Vorlage) und wird für die Spalten NICHT zusätzlich mit millimeterScale multipliziert -
|
||||||
// millimeterScale rechnet das mm-entworfene Raster in die Koordinaten-Einheit der Vorlage um.
|
// die Spaltenpositionen sind Anteile von contentWidth (proportional, unitless), nicht eigene
|
||||||
|
// mm-Maße. Nur echte mm-Maße wie Zeilenhöhe/Abstände (Y-Richtung) brauchen millimeterScale,
|
||||||
|
// um bei einer in "pt" deklarierten Vorlage die richtige physische Größe zu erreichen (siehe
|
||||||
|
// StudentAttendanceCalendarDrawingBuilder). Eine frühere Version multiplizierte auch die
|
||||||
|
// Spalten mit millimeterScale, wodurch sie bei "pt"-Vorlagen weit über contentWidth
|
||||||
|
// hinausliefen (z.B. Status-Spalte bei x≈323 in einer nur 170 Einheiten breiten Box).
|
||||||
var rowHeight = 12 * scale * millimeterScale;
|
var rowHeight = 12 * scale * millimeterScale;
|
||||||
var start = options.NormalizedStartMonth;
|
var start = options.NormalizedStartMonth;
|
||||||
var end = start.AddMonths(options.NormalizedMonthCount).AddDays(-1);
|
var end = start.AddMonths(options.NormalizedMonthCount).AddDays(-1);
|
||||||
@@ -179,64 +190,121 @@ public static class StudentAbsenceDayListDrawingBuilder
|
|||||||
.ToList();
|
.ToList();
|
||||||
var commands = new List<DrawingCommand>();
|
var commands = new List<DrawingCommand>();
|
||||||
var y = 0f;
|
var y = 0f;
|
||||||
commands.Add(new DrawStringEx(0, y, 14 * scale * millimeterScale, contentWidth, "Fehltage",
|
// Kein eigener "Fehltage"-Titel mehr - analog zum Anwesenheitskalender dient der (klein und
|
||||||
DrawingTextAlignment.AlignLeft, 11 * scale, Color: "#1F2937", Bold: true));
|
// hellgrau gehaltene) Name nur der Kontrolle, dass die Liste zum richtigen Kind gehört.
|
||||||
y += 14 * scale * millimeterScale;
|
commands.Add(new DrawStringEx(0, y, 5 * millimeterScale, contentWidth, studentName,
|
||||||
commands.Add(new DrawStringEx(0, y, 10 * scale * millimeterScale, contentWidth, studentName,
|
DrawingTextAlignment.AlignLeft, 6.5f * scale, Color: "#9CA3AF"));
|
||||||
DrawingTextAlignment.AlignLeft, 8 * scale, Color: "#6B7280"));
|
y += 5 * millimeterScale + .5f * millimeterScale;
|
||||||
y += 10 * scale * millimeterScale + 2 * scale * millimeterScale;
|
// Spaltenbreiten als Anteile von contentWidth (gegen eine 170-Einheiten-Referenz austariert),
|
||||||
// Spaltenbreiten so gewählt, dass auch die Datenzeilen (nicht nur die kurzen Kopfzeilen-
|
// damit auch die Datenzeilen (nicht nur die kurzen Kopfzeilen-Labels) hineinpassen - "Datum"
|
||||||
// Labels) hineinpassen - "Datum" als Kopfzeile ist kürzer als "dd.MM.yyyy" und wurde bei
|
// als Kopfzeile ist kürzer als "dd.MM.yyyy" und wurde bei 31 zu schmal bemessen, wodurch das
|
||||||
// 31 zu schmal bemessen, wodurch das Datum am rechten Rand abgeschnitten wurde.
|
// Datum am rechten Rand abgeschnitten wurde.
|
||||||
var dateColumnX = 2 * millimeterScale; var dateColumnWidth = 38 * millimeterScale;
|
const float referenceWidth = 170f;
|
||||||
var extentColumnX = 44 * millimeterScale; var extentColumnWidth = 66 * millimeterScale;
|
var dateColumnX = contentWidth * (2f / referenceWidth);
|
||||||
var statusColumnX = 114 * millimeterScale; var statusColumnWidth = 54 * millimeterScale;
|
var dateColumnWidth = contentWidth * (38f / referenceWidth);
|
||||||
commands.Add(new DrawRectangle(0, y, contentWidth, rowHeight, "#CBD5E1", .4f, "#F3F4F6"));
|
var extentColumnX = contentWidth * (44f / referenceWidth);
|
||||||
commands.Add(new DrawStringEx(dateColumnX, y + scale * millimeterScale, rowHeight - scale * millimeterScale,
|
var extentColumnWidth = contentWidth * (66f / referenceWidth);
|
||||||
dateColumnWidth, "Datum", DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
|
var statusColumnX = contentWidth * (114f / referenceWidth);
|
||||||
commands.Add(new DrawStringEx(extentColumnX, y + scale * millimeterScale, rowHeight - scale * millimeterScale,
|
var statusColumnWidth = contentWidth * (54f / referenceWidth);
|
||||||
extentColumnWidth, "Umfang", DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
|
|
||||||
commands.Add(new DrawStringEx(statusColumnX, y + scale * millimeterScale, rowHeight - scale * millimeterScale,
|
(string Extent, string Status, string StatusColor) Format(ClassAbsenceDaySummaryRow row)
|
||||||
statusColumnWidth, "Status", DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
|
{
|
||||||
y += rowHeight;
|
var extent = row.CountsAsFullDay
|
||||||
|
? "Ganzer Fehltag"
|
||||||
|
: row.TotalAbsentPeriods > 0
|
||||||
|
? $"Fehlzeit · {row.TotalAbsentPeriods} Std."
|
||||||
|
: $"Fehlzeit · {row.TotalAbsentMinutes} Min.";
|
||||||
|
var status = row.IsUnexcused
|
||||||
|
? "Unentschuldigt"
|
||||||
|
: row.FriendlyStatusLabel.Contains("Entschuldigt", StringComparison.OrdinalIgnoreCase)
|
||||||
|
? "Entschuldigt"
|
||||||
|
: row.FriendlyStatusLabel;
|
||||||
|
return (extent, status, row.IsUnexcused ? "#C62828" : "#2E7D32");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawRows(float columnX, float columnWidth, float dColumnX, float dColumnWidth, float eColumnX,
|
||||||
|
float eColumnWidth, float sColumnX, float sColumnWidth,
|
||||||
|
IReadOnlyList<ClassAbsenceDaySummaryRow> columnRows)
|
||||||
|
{
|
||||||
|
var rowY = y;
|
||||||
|
commands.Add(new DrawRectangle(columnX, rowY, columnWidth, rowHeight, "#CBD5E1", .4f, "#F3F4F6"));
|
||||||
|
commands.Add(new DrawStringEx(dColumnX, rowY + scale * millimeterScale, rowHeight - scale * millimeterScale,
|
||||||
|
dColumnWidth, "Datum", DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
|
||||||
|
commands.Add(new DrawStringEx(eColumnX, rowY + scale * millimeterScale, rowHeight - scale * millimeterScale,
|
||||||
|
eColumnWidth, "Umfang", DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
|
||||||
|
commands.Add(new DrawStringEx(sColumnX, rowY + scale * millimeterScale, rowHeight - scale * millimeterScale,
|
||||||
|
sColumnWidth, "Status", DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151", Bold: true));
|
||||||
|
rowY += rowHeight;
|
||||||
|
for (var index = 0; index < columnRows.Count; index++)
|
||||||
|
{
|
||||||
|
var row = columnRows[index];
|
||||||
|
var (extent, status, statusColor) = Format(row);
|
||||||
|
var fill = index % 2 == 0 ? "#FFFFFF" : "#F9FAFB";
|
||||||
|
commands.Add(new DrawRectangle(columnX, rowY, columnWidth, rowHeight, "#E5E7EB", .3f, fill));
|
||||||
|
commands.Add(new DrawStringEx(dColumnX, rowY + scale * millimeterScale,
|
||||||
|
rowHeight - scale * millimeterScale, dColumnWidth,
|
||||||
|
row.Date.ToString("dd.MM.yyyy"), DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151"));
|
||||||
|
commands.Add(new DrawStringEx(eColumnX, rowY + scale * millimeterScale,
|
||||||
|
rowHeight - scale * millimeterScale, eColumnWidth,
|
||||||
|
extent, DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151"));
|
||||||
|
commands.Add(new DrawStringEx(sColumnX, rowY + scale * millimeterScale,
|
||||||
|
rowHeight - scale * millimeterScale, sColumnWidth,
|
||||||
|
status, DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: statusColor, Bold: row.IsUnexcused));
|
||||||
|
rowY += rowHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rows.Count == 0)
|
if (rows.Count == 0)
|
||||||
{
|
{
|
||||||
commands.Add(new DrawStringEx(2 * millimeterScale, y + 2 * scale * millimeterScale, rowHeight,
|
DrawRows(0, contentWidth, dateColumnX, dateColumnWidth, extentColumnX, extentColumnWidth,
|
||||||
contentWidth - 4 * millimeterScale, "Keine Fehltage im gewählten Zeitraum",
|
statusColumnX, statusColumnWidth, []);
|
||||||
|
y += rowHeight;
|
||||||
|
commands.Add(new DrawStringEx(dateColumnX, y + 2 * scale * millimeterScale, rowHeight,
|
||||||
|
contentWidth - 2 * dateColumnX, "Keine Fehltage im gewählten Zeitraum",
|
||||||
DrawingTextAlignment.AlignLeft, 8 * scale, Color: "#6B7280", Italic: true));
|
DrawingTextAlignment.AlignLeft, 8 * scale, Color: "#6B7280", Italic: true));
|
||||||
y += rowHeight + 3 * scale * millimeterScale;
|
y += rowHeight + 3 * scale * millimeterScale;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (var index = 0; index < rows.Count; index++)
|
// Ab genug Zeilen zweispaltig (chronologisch: erste Hälfte links, Rest rechts) - spart bei
|
||||||
|
// längeren Listen spürbar Höhe. Nur wenn die Box auch wirklich breit genug für zwei volle
|
||||||
|
// Spalten ist (>= 2x die Einspalten-Referenzbreite + Zwischenraum) - sonst blieben Datum/
|
||||||
|
// Umfang/Status in jeder Hälfte zu schmal und würden abgeschnitten, siehe die reale
|
||||||
|
// Vorlage dieses Nutzers, deren FLOWDRAWBOX für diesen Platzhalter aktuell nur 170 statt
|
||||||
|
// z.B. 400+ Einheiten breit ist (dort bleibt es also bewusst einspaltig).
|
||||||
|
const float columnGapDesign = 8f;
|
||||||
|
var minTwoColumnWidth = 2 * referenceWidth + columnGapDesign;
|
||||||
|
if (rows.Count >= 4 && contentWidth >= minTwoColumnWidth)
|
||||||
{
|
{
|
||||||
var row = rows[index];
|
var columnGap = contentWidth * (columnGapDesign / referenceWidth);
|
||||||
var fill = index % 2 == 0 ? "#FFFFFF" : "#F9FAFB";
|
var columnWidth = (contentWidth - columnGap) / 2;
|
||||||
var extent = row.CountsAsFullDay
|
var leftCount = (rows.Count + 1) / 2;
|
||||||
? "Ganzer Fehltag"
|
var left = rows.Take(leftCount).ToList();
|
||||||
: row.TotalAbsentPeriods > 0
|
var right = rows.Skip(leftCount).ToList();
|
||||||
? $"Fehlzeit · {row.TotalAbsentPeriods} Std."
|
// Spaltenanteile innerhalb EINER Hälfte, gegen eine 81-Einheiten-Referenz austariert:
|
||||||
: $"Fehlzeit · {row.TotalAbsentMinutes} Min.";
|
// 81 + columnGapDesign(8) + 81 = 170 = referenceWidth, dieselbe Gesamtbreite wie das
|
||||||
var status = row.IsUnexcused
|
// einspaltige Layout, nur eben in zwei Hälften aufgeteilt.
|
||||||
? "Unentschuldigt"
|
const float halfReferenceWidth = 81f;
|
||||||
: row.FriendlyStatusLabel.Contains("Entschuldigt", StringComparison.OrdinalIgnoreCase)
|
(float X, float Width) Fraction(float leftEdge, float x, float width) =>
|
||||||
? "Entschuldigt"
|
(leftEdge + columnWidth * (x / halfReferenceWidth), columnWidth * (width / halfReferenceWidth));
|
||||||
: row.FriendlyStatusLabel;
|
var (leftDateX, leftDateWidth) = Fraction(0, 1, 19);
|
||||||
var statusColor = row.IsUnexcused ? "#C62828" : "#2E7D32";
|
var (leftExtentX, leftExtentWidth) = Fraction(0, 21, 32);
|
||||||
commands.Add(new DrawRectangle(0, y, contentWidth, rowHeight, "#E5E7EB", .3f, fill));
|
var (leftStatusX, leftStatusWidth) = Fraction(0, 54, 26);
|
||||||
commands.Add(new DrawStringEx(dateColumnX, y + scale * millimeterScale,
|
var rightEdge = columnWidth + columnGap;
|
||||||
rowHeight - scale * millimeterScale, dateColumnWidth,
|
var (rightDateX, rightDateWidth) = Fraction(rightEdge, 1, 19);
|
||||||
row.Date.ToString("dd.MM.yyyy"), DrawingTextAlignment.AlignLeft, 7.5f * scale,
|
var (rightExtentX, rightExtentWidth) = Fraction(rightEdge, 21, 32);
|
||||||
Color: "#374151"));
|
var (rightStatusX, rightStatusWidth) = Fraction(rightEdge, 54, 26);
|
||||||
commands.Add(new DrawStringEx(extentColumnX, y + scale * millimeterScale,
|
DrawRows(0, columnWidth, leftDateX, leftDateWidth, leftExtentX, leftExtentWidth, leftStatusX,
|
||||||
rowHeight - scale * millimeterScale, extentColumnWidth,
|
leftStatusWidth, left);
|
||||||
extent, DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: "#374151"));
|
DrawRows(rightEdge, columnWidth, rightDateX, rightDateWidth, rightExtentX, rightExtentWidth,
|
||||||
commands.Add(new DrawStringEx(statusColumnX, y + scale * millimeterScale,
|
rightStatusX, rightStatusWidth, right);
|
||||||
rowHeight - scale * millimeterScale, statusColumnWidth,
|
y += rowHeight * (1 + Math.Max(left.Count, right.Count));
|
||||||
status, DrawingTextAlignment.AlignLeft, 7.5f * scale, Color: statusColor,
|
}
|
||||||
Bold: row.IsUnexcused));
|
else
|
||||||
y += rowHeight;
|
{
|
||||||
|
DrawRows(0, contentWidth, dateColumnX, dateColumnWidth, extentColumnX, extentColumnWidth,
|
||||||
|
statusColumnX, statusColumnWidth, rows);
|
||||||
|
y += rowHeight * (1 + rows.Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new DrawingValue(commands, y);
|
return new DrawingValue(commands, y);
|
||||||
|
|||||||
Reference in new issue
Block a user