From 0556e4763ec4cb7809a24a4cb90169648ed2b932 Mon Sep 17 00:00:00 2001 From: misya Date: Tue, 29 Apr 2025 16:23:08 +0800 Subject: [PATCH] comment --- Areas/MMS/Models/PDFGenerator/TarBallPDF.cs | 32 ++++++++++----------- PSTW_CentralSystem.csproj | 1 + 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs b/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs index 0fbcf1d..8b5e9bb 100644 --- a/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs +++ b/Areas/MMS/Models/PDFGenerator/TarBallPDF.cs @@ -27,19 +27,18 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator private readonly bool _isSand = isSand; private readonly bool _isNonSandy = isNonSandy; private readonly bool _isCoquina = isCoquina; - private readonly string? _photoPath1 = photoPath1; - private readonly string? _photoPath2 = photoPath2; - private readonly string? _photoPath3 = photoPath3; + private readonly string? _photoPath1 = photoPath1; //having '?' makes it nullable, ELSE the string must always have a value + private readonly string? _photoPath2 = photoPath2; //"but why keep '?' for photopath 1 to 4? + private readonly string? _photoPath3 = photoPath3; //A: to make private readonly string? _photoPath4 = photoPath4; private readonly string? _photoPath5 = photoPath5; private readonly string? _photoPath6 = photoPath6; private readonly string? _photoPath7 = photoPath7; private readonly string? _photoPath8 = photoPath8; - //INSERT LOADIMAGE() HERE private Image? LoadImage(string? imagePath) { - if (string.IsNullOrEmpty(imagePath)) // Fixed: Added closing ) + if (string.IsNullOrEmpty(imagePath)) { return null; } @@ -54,7 +53,6 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator } } - // Metadata for the PDF document public DocumentMetadata GetMetadata() => new() { Title = "TARBALL SAMPLING FORM", @@ -72,7 +70,8 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator page.Margin(1.1f, Unit.Centimetre); page.DefaultTextStyle(x => x.FontFamily("Arial").FontSize(10)); - // Header Section + //HEADER SECTION ========================================================================== + //will be included in each page page.Header().Row(row => { row.RelativeItem(1).Element(CellStyle).Column(column => @@ -122,8 +121,10 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator => container.Border(0.5f).Padding(5); }); + //HEADER SECTION END ========================================================================== - // Content Section + + // CONTENT SECTION ============================================================================ page.Content().Column(column => { // Observations Table @@ -164,7 +165,6 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator .Bold(); table.Cell().Element(CellStyle).Text($"{_longitude}, {_latitude}"); - // Display DateSample and TimeSample together in the table table.Cell() .Background(Colors.Grey.Lighten2).Element(CellStyle).Text("DATE / TIME") .Bold(); @@ -173,14 +173,13 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator column.Spacing(3); - // Survey Findings - ALWAYS shows all options + // Survey Findings ======================================================================================= column.Item() .PaddingTop(10) .PaddingBottom(10) .Text("SURVEY FINDING:") .Bold().FontSize(12); - // 1. Tar Ball YES/NO (always shown) column.Item() .PaddingBottom(10) .Text(text => @@ -189,7 +188,6 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator text.Span(_classifyID == "NO" ? " ☐ YES ☑ NO" : " ☑ YES ☐ NO").Style(TextStyle.Default.FontSize(10)); }); - // 2. Classification (always shown) column.Item() .PaddingBottom(10) .Text("If YES, Tar Ball falls under the Classification of:") @@ -228,16 +226,16 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator columns.RelativeColumn(1); }); - // Row 1: Photos + // Row 1: Photos ==================================== table.Cell().Element(CellStyle).Height(150) .Image(LoadImage(_photoPath1) ?? null) // Just pass null if no image .FitArea(); table.Cell().Element(CellStyle).Height(150) - .Image(LoadImage(_photoPath2) ?? null) // Just pass null if no image + .Image(LoadImage(_photoPath2) ?? null) .FitArea(); - // Row 1: Captions + // Row 2: Captions for figure 1 & 2 ================= table.Cell().Element(CellStyle) .Text("Figure 1: Left Side Coastal View") .FontSize(12).AlignLeft(); @@ -246,7 +244,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator .Text("Figure 2: Right Side Coastal View") .FontSize(12).AlignLeft(); - // Row 2: Photos + // Row 3 ============================================= table.Cell().Element(CellStyle).Height(150) .Image(LoadImage(_photoPath3) ?? null) // Just pass null if no image .FitArea(); @@ -255,7 +253,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator .Image(LoadImage(_photoPath4) ?? null) // Just pass null if no image .FitArea(); - // Row 2: Captions + // Row 4: Captions for figure 3 & 4 ================= table.Cell().Element(CellStyle) .Text("Figure 3: Drawing Vertical Lines") .FontSize(12).AlignLeft(); diff --git a/PSTW_CentralSystem.csproj b/PSTW_CentralSystem.csproj index 92012c8..7c50ffa 100644 --- a/PSTW_CentralSystem.csproj +++ b/PSTW_CentralSystem.csproj @@ -7,6 +7,7 @@ +