"Trova componenti referenziati" ran the recursive BFS synchronously on the UI thread with no feedback. Runs it on a background task instead and shows a modal dialog with a percentage bar, updated as each .asm in the queue is processed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
namespace CadSearchGui;
|
|
|
|
public sealed class ProgressoComponentiForm : Form
|
|
{
|
|
private readonly Label _lbl = new();
|
|
private readonly ProgressBar _bar = new();
|
|
|
|
public ProgressoComponentiForm()
|
|
{
|
|
Text = "Ricerca componenti referenziati in corso...";
|
|
FormBorderStyle = FormBorderStyle.FixedDialog;
|
|
StartPosition = FormStartPosition.CenterParent;
|
|
MinimizeBox = false;
|
|
MaximizeBox = false;
|
|
ControlBox = false;
|
|
ClientSize = new Size(400, 88);
|
|
|
|
_lbl.Text = "Preparazione...";
|
|
_lbl.AutoSize = true;
|
|
_lbl.Location = new Point(16, 16);
|
|
|
|
_bar.Location = new Point(16, 44);
|
|
_bar.Size = new Size(368, 24);
|
|
_bar.Minimum = 0;
|
|
_bar.Maximum = 100;
|
|
|
|
Controls.Add(_lbl);
|
|
Controls.Add(_bar);
|
|
}
|
|
|
|
public void Aggiorna(int fatti, int totale)
|
|
{
|
|
int percento = totale > 0 ? (int)Math.Clamp(100.0 * fatti / totale, 0, 100) : 0;
|
|
_bar.Value = percento;
|
|
_lbl.Text = $"{fatti} / {totale} componenti analizzati ({percento}%)";
|
|
}
|
|
}
|