feat: redesign page1 header - centered title, info boxes row (Tipologia/Data/Bid/Ask)

This commit is contained in:
2026-03-20 16:47:08 +01:00
parent e76fdc1bb0
commit c8f7452e2b

View File

@@ -73,41 +73,74 @@ public class AnagraficaSectionRenderer : IPdfSectionRenderer
private float DrawTitle(PdfGraphics g, CertificateInfo info, float w, float y) private float DrawTitle(PdfGraphics g, CertificateInfo info, float w, float y)
{ {
// ISIN + titolo a sinistra // ── Titolo centrato ──────────────────────────────────────────
g.DrawString($"Scheda Prodotto {info.Isin}", g.DrawString($"Scheda Prodotto {info.Isin}",
PdfTheme.SectionTitleFont, PdfTheme.SectionTitleFont,
new PdfSolidBrush(PdfTheme.AccentBlue), new PdfSolidBrush(PdfTheme.AccentBlue),
new RectangleF(0, y, w * 0.65f, 20f)); new RectangleF(0, y, w, 20f),
new PdfStringFormat(PdfTextAlignment.Center));
// Bid/Ask a destra y += 24f;
if (!string.IsNullOrEmpty(info.Bid) && !string.IsNullOrEmpty(info.Ask))
{
string bidAsk = $"{info.Bid} BID {info.Ask} ASK";
g.DrawString(info.LastPriceDate, PdfTheme.Small,
new PdfSolidBrush(PdfTheme.TextSecondary),
new RectangleF(w * 0.65f, y, w * 0.35f, 10f),
new PdfStringFormat(PdfTextAlignment.Right));
g.DrawString(bidAsk, PdfTheme.Bold,
new PdfSolidBrush(PdfTheme.AccentBlue),
new RectangleF(w * 0.65f, y + 10f, w * 0.35f, 12f),
new PdfStringFormat(PdfTextAlignment.Right));
}
y += 22f;
// Tipologia sotto il titolo
if (!string.IsNullOrEmpty(info.Categoria))
{
g.DrawString($"Tipologia: {info.Categoria}", PdfTheme.Regular,
new PdfSolidBrush(PdfTheme.TextSecondary),
new RectangleF(0, y, w, 12f));
y += 13f;
}
// Linea separatrice blu // Linea separatrice blu
g.DrawLine(PdfTheme.AccentBluePen, 0, y + 2f, w, y + 2f); g.DrawLine(PdfTheme.AccentBluePen, 0, y, w, y);
y += 8f; y += 8f;
// ── Riga box: Tipologia | Data | Bid | Ask ───────────────────
const float boxH = 28f;
const float gap = 6f;
const float dataW = 84f;
const float bidW = 70f;
const float askW = 70f;
bool showTip = !string.IsNullOrEmpty(info.Categoria);
bool showData = !string.IsNullOrEmpty(info.LastPriceDate);
bool showBidAsk = !string.IsNullOrEmpty(info.Bid) && !string.IsNullOrEmpty(info.Ask);
// Calcolo dinamico larghezza Tipologia in base ai box presenti
int nBoxes = (showTip ? 1 : 0) + (showData ? 1 : 0) + (showBidAsk ? 2 : 0);
float totalGaps = Math.Max(0, nBoxes - 1) * gap;
float fixedW = (showData ? dataW : 0f) + (showBidAsk ? bidW + askW : 0f);
float tipW = showTip ? (w - totalGaps - fixedW) : 0f;
float xCursor = 0f;
if (showTip)
{
DrawInfoBox(g, xCursor, y, tipW, boxH,
"TIPOLOGIA", info.Categoria,
PdfTheme.BoxLightBlueBgBrush, PdfTheme.AccentBlueBrush,
PdfTheme.AccentBlueBrush, PdfTheme.AccentBlueDarkBrush,
PdfTheme.Bold);
xCursor += tipW + gap;
}
if (showData)
{
DrawInfoBox(g, xCursor, y, dataW, boxH,
"DATA", info.LastPriceDate,
PdfTheme.BoxGrayBgBrush, PdfTheme.BoxGrayAccentBrush,
PdfTheme.BoxGrayLabelBrush, PdfTheme.BoxGrayValueBrush,
PdfTheme.Bold);
xCursor += dataW + gap;
}
if (showBidAsk)
{
DrawInfoBox(g, xCursor, y, bidW, boxH,
"BID", info.Bid,
PdfTheme.BoxLightBlueBgBrush, PdfTheme.AccentBlueBrush,
PdfTheme.AccentBlueBrush, PdfTheme.AccentBlueDarkBrush,
PdfTheme.Bold);
xCursor += bidW + gap;
DrawInfoBox(g, xCursor, y, askW, boxH,
"ASK", info.Ask,
PdfTheme.BoxLightBlueBgBrush, PdfTheme.AccentBlueBrush,
PdfTheme.AccentBlueBrush, PdfTheme.AccentBlueDarkBrush,
PdfTheme.Bold);
}
y += boxH + 10f;
return y; return y;
} }
@@ -125,6 +158,28 @@ public class AnagraficaSectionRenderer : IPdfSectionRenderer
return y + 16f; return y + 16f;
} }
// ═══════════════════════════════════════════════════════════════
// INFO BOX (box colorato con accent line laterale)
// ═══════════════════════════════════════════════════════════════
private void DrawInfoBox(
PdfGraphics g,
float x, float y, float w, float boxH,
string label, string value,
PdfBrush bgBrush, PdfBrush accentBrush,
PdfBrush labelBrush, PdfBrush valueBrush,
PdfFont valueFont)
{
g.DrawRectangle(bgBrush, new RectangleF(x, y, w, boxH));
g.DrawRectangle(accentBrush, new RectangleF(x, y, 4f, boxH));
float innerX = x + 4f + 6f;
float innerW = w - 4f - 6f - 4f;
g.DrawString(label, PdfTheme.Small, labelBrush,
new RectangleF(innerX, y + 4f, innerW, 10f));
g.DrawString(value, valueFont, valueBrush,
new RectangleF(innerX, y + 14f, innerW, 14f));
}
// ═══════════════════════════════════════════════════════════════ // ═══════════════════════════════════════════════════════════════
// SEZIONE A: CARATTERISTICHE PRODOTTO // SEZIONE A: CARATTERISTICHE PRODOTTO
// Sinistra: tabella emittente | Destra: cedole + rendimento totale // Sinistra: tabella emittente | Destra: cedole + rendimento totale