Files
prep-step/PrepStep/ProgressoComponentiForm.cs
T

37 lines
1.1 KiB
C#
Raw Normal View History

namespace PrepStep;
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}%)";
}
}