using System.Diagnostics; namespace CadSearchGui; /// 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. 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); } }