Files
prep-step/CadSearchGui/ReportStepForm.cs
T
davideandClaude Sonnet 5 52d126372d Redesign the final STEP phase to build a step_finali folder
Previously it only compared the top-level BOM against step/ and reported
matches, without copying anything. Now it unions the BOM codes with the
sub-components resolved in phase 4, copies every matching .stp into a new
step_finali/ folder, and reports what got created vs what's still missing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 10:23:35 +02:00

67 lines
2.5 KiB
C#

using System.Diagnostics;
namespace CadSearchGui;
/// <summary>Mostra, per ogni componente (distinta base + sotto-componenti risolti in fase 4),
/// se lo STEP corrispondente è stato trovato in "step" e copiato in "step_finali", o se manca.</summary>
public class ReportStepForm : Form
{
public ReportStepForm(List<(string Componente, string Descrizione, bool Creato)> righe, string cartellaStepFinali)
{
int creati = righe.Count(r => r.Creato);
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 = false,
Height = 32,
Padding = new Padding(12, 8, 12, 8),
Text = $"{creati} componenti copiati su {righe.Count} ({righe.Count - creati} mancanti) "
+ $"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, creato) in righe.OrderBy(r => r.Creato).ThenBy(r => r.Componente))
{
int i = grid.Rows.Add(componente, descrizione, creato ? "Creato" : "Mancante");
grid.Rows[i].DefaultCellStyle.ForeColor = creato ? Color.DarkGreen : Color.DarkRed;
}
var btnApriCartella = new Button { Text = "Apri cartella step_finali", Dock = DockStyle.Bottom, Height = 34 };
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);
}
}