66 lines
2.5 KiB
C#
66 lines
2.5 KiB
C#
using System.Diagnostics;
|
|||
|
|
|
||
|
|
namespace CadSearchGui;
|
||
|
|
|
||
|
|
/// <summary>Mostra, per ogni componente della distinta base, se lo STEP corrispondente
|
||
|
|
/// è già stato esportato (file .stp presente in "step") o manca ancora.</summary>
|
||
|
|
public class ReportStepForm : Form
|
||
|
|
{
|
||
|
|
public ReportStepForm(List<(string Componente, string Descrizione, bool Realizzato)> righe, string cartellaStep)
|
||
|
|
{
|
||
|
|
int realizzati = righe.Count(r => r.Realizzato);
|
||
|
|
|
||
|
|
Text = "Report STEP realizzati";
|
||
|
|
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 = $"{realizzati} componenti realizzati su {righe.Count} ({righe.Count - realizzati} mancanti), "
|
||
|
|
+ $"confrontati con \"{cartellaStep}\".",
|
||
|
|
};
|
||
|
|
|
||
|
|
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, realizzato) in righe.OrderBy(r => r.Realizzato).ThenBy(r => r.Componente))
|
||
|
|
{
|
||
|
|
int i = grid.Rows.Add(componente, descrizione, realizzato ? "Realizzato" : "Mancante");
|
||
|
|
grid.Rows[i].DefaultCellStyle.ForeColor = realizzato ? Color.DarkGreen : Color.DarkRed;
|
||
|
|
}
|
||
|
|
|
||
|
|
var btnApriCartella = new Button { Text = "Apri cartella step", Dock = DockStyle.Bottom, Height = 34 };
|
||
|
|
btnApriCartella.Click += (_, _) =>
|
||
|
|
{
|
||
|
|
try { Process.Start("explorer.exe", cartellaStep); }
|
||
|
|
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);
|
||
|
|
}
|
||
|
|
}
|