Files
prep-step/CadSearchGui/ReportStepForm.cs
T
davideandClaude Sonnet 5 ba18d682f3 Fix overflowing/clipped UI text and give buttons a consistent flat style
Instruction and status labels used AutoSize/fixed widths with no wrap
constraint, so long Italian paragraphs and network paths ran past the
window edge or got clipped instead of wrapping. Report dialogs had
fixed-height labels that clipped multi-line text. ProgressForm's folder
label could overflow its non-resizable dialog.

- Labels now wrap responsively (TableLayoutPanel column at 100% + Dock=Top)
  instead of a fixed pixel cap, so they reflow when the window is resized.
- Report dialog labels switched from fixed Height to AutoSize.
- ProgressForm's folder label truncates with ellipsis + tooltip, matching
  the existing pattern used by the import status label.
- Added ApplicationHighDpiMode=PerMonitorV2 to fix control proportions on
  scaled displays.
- Added UiStile.cs: shared flat button style (primary/secondary), rounded
  corners for the wizard nav buttons, and AutoSize+padding on all buttons
  so button size always matches its text (fixes text getting clipped when
  a hardcoded Size was too narrow for the label).
- Fase 5's drag&drop .asm list now fills available vertical space instead
  of a fixed 680x160 box.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-21 10:40:32 +02:00

86 lines
3.4 KiB
C#

using System.Diagnostics;
namespace CadSearchGui;
public enum EsitoStep
{
/// <summary>File .stp trovato in "step" e copiato in "step_finali".</summary>
Creato,
/// <summary>Il componente è nell'indice CAD (asm/prt trovato), ma nessuno STEP esportato.</summary>
StepMancante,
/// <summary>Il componente non è nemmeno nell'indice CAD.</summary>
ComponenteNonTrovato,
}
/// <summary>Mostra, per ogni componente della distinta base, se lo STEP corrispondente è stato
/// trovato in "step" e copiato in "step_finali", se manca solo lo STEP (il CAD sorgente c'è,
/// ma non è ancora stato esportato) o se manca anche il CAD sorgente nell'indice.</summary>
public class ReportStepForm : Form
{
public ReportStepForm(List<(string Componente, string Descrizione, EsitoStep Esito)> righe, string cartellaStepFinali)
{
int creati = righe.Count(r => r.Esito == EsitoStep.Creato);
int stepMancanti = righe.Count(r => r.Esito == EsitoStep.StepMancante);
int nonTrovati = righe.Count(r => r.Esito == EsitoStep.ComponenteNonTrovato);
Text = "Report STEP finali";
ClientSize = new Size(720, 440);
StartPosition = FormStartPosition.CenterParent;
Font = new Font("Segoe UI", 9.5f);
var lblInfo = new Label
{
Dock = DockStyle.Top,
AutoSize = true,
Padding = new Padding(12, 8, 12, 8),
Text = $"{creati} copiati, {stepMancanti} da esportare (CAD presente), "
+ $"{nonTrovati} non nell'indice, su {righe.Count} totali. In \"{cartellaStepFinali}\".",
};
var grid = new DataGridView
{
Dock = DockStyle.Fill,
ReadOnly = true,
AllowUserToAddRows = false,
AllowUserToDeleteRows = false,
RowHeadersVisible = false,
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
};
grid.Columns.Add("componente", "Componente");
grid.Columns.Add("descrizione", "Descrizione");
grid.Columns.Add("step", "STEP");
grid.Columns["componente"]!.FillWeight = 20;
grid.Columns["descrizione"]!.FillWeight = 55;
grid.Columns["step"]!.FillWeight = 25;
foreach (var (componente, descrizione, esito) in righe.OrderBy(r => r.Esito).ThenBy(r => r.Componente))
{
var (testo, colore) = esito switch
{
EsitoStep.Creato => ("Creato", Color.DarkGreen),
EsitoStep.StepMancante => ("Da esportare (CAD presente)", Color.DarkOrange),
_ => ("Componente non trovato nel server", Color.DarkRed),
};
int i = grid.Rows.Add(componente, descrizione, testo);
grid.Rows[i].DefaultCellStyle.ForeColor = colore;
}
var btnApriCartella = new Button { Text = "Apri cartella step_finali", Dock = DockStyle.Bottom, Height = 34 };
UiStile.Secondario(btnApriCartella);
btnApriCartella.Click += (_, _) =>
{
try { Process.Start("explorer.exe", cartellaStepFinali); }
catch (Exception ex)
{
MessageBox.Show(this, $"Impossibile aprire Esplora risorse:\n{ex.Message}", "Errore",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
};
Controls.Add(grid);
Controls.Add(lblInfo);
Controls.Add(btnApriCartella);
}
}