using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace QC.QTMApplication.Dialogs;

public class UpdatingTestCasesDialog : Form
{
	private int _total;

	private int _current;

	private string _name;

	private IContainer components;

	private ProgressBar updatingTestCasesProgressBar;

	private Label updatingTestCasesLabel;

	private BackgroundWorker backgroundWorkerUpdatingTestCases;

	public UpdatingTestCasesDialog()
	{
		InitializeComponent();
	}

	public UpdatingTestCasesDialog(int total)
	{
		InitializeComponent();
		_total = total;
		updatingTestCasesProgressBar.Maximum = total;
		backgroundWorkerUpdatingTestCases.RunWorkerAsync();
	}

	public void SetCurrent(int current, string name)
	{
		if (updatingTestCasesLabel.InvokeRequired)
		{
			updatingTestCasesLabel.BeginInvoke((MethodInvoker)delegate
			{
				SetCurrent(current, name);
			});
			return;
		}
		_current = current;
		_name = name;
		updatingTestCasesLabel.Text = _name;
		if (updatingTestCasesProgressBar.Maximum >= _current)
		{
			updatingTestCasesProgressBar.Value = _current;
		}
		Refresh();
	}

	private void backgroundWorkerUpdatingTestCases_DoWork(object sender, DoWorkEventArgs e)
	{
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.updatingTestCasesProgressBar = new System.Windows.Forms.ProgressBar();
		this.updatingTestCasesLabel = new System.Windows.Forms.Label();
		this.backgroundWorkerUpdatingTestCases = new System.ComponentModel.BackgroundWorker();
		base.SuspendLayout();
		this.updatingTestCasesProgressBar.Dock = System.Windows.Forms.DockStyle.Bottom;
		this.updatingTestCasesProgressBar.Location = new System.Drawing.Point(0, 21);
		this.updatingTestCasesProgressBar.Name = "updatingTestCasesProgressBar";
		this.updatingTestCasesProgressBar.Size = new System.Drawing.Size(284, 23);
		this.updatingTestCasesProgressBar.TabIndex = 0;
		this.updatingTestCasesLabel.AutoSize = true;
		this.updatingTestCasesLabel.Dock = System.Windows.Forms.DockStyle.Top;
		this.updatingTestCasesLabel.Location = new System.Drawing.Point(0, 0);
		this.updatingTestCasesLabel.Margin = new System.Windows.Forms.Padding(6, 6, 3, 0);
		this.updatingTestCasesLabel.Name = "updatingTestCasesLabel";
		this.updatingTestCasesLabel.Size = new System.Drawing.Size(53, 13);
		this.updatingTestCasesLabel.TabIndex = 1;
		this.updatingTestCasesLabel.Text = "Updating:";
		this.backgroundWorkerUpdatingTestCases.DoWork += new System.ComponentModel.DoWorkEventHandler(backgroundWorkerUpdatingTestCases_DoWork);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(284, 44);
		base.ControlBox = false;
		base.Controls.Add(this.updatingTestCasesLabel);
		base.Controls.Add(this.updatingTestCasesProgressBar);
		base.Name = "UpdatingTestCasesDialog";
		base.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
		this.Text = "Updating TestCases";
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
