void BtnOptimize_Click(object sender, EventArgs e)
{
if (isOptimizing)
{ // Cancel the asynchronous operation.
bgWorker.CancelAsync();
return;
}
if (Configs.OptimizerWritesReport)
InitReport();
// Counts the checked params
checkedParams = 0;
for (int i = 0; i < parameters; i++)
if (achbxParameterName[i].Checked)
checkedParams++;
// If there are no checked returns
if (checkedParams < 1 && Configs.PlaySounds)
{
System.Media.SystemSounds.Hand.Play();
return;
}
// Contains the checked params only
aiChecked = new int[checkedParams];
int indexChecked = 0;
for (int i = 0; i < parameters; i++)
if (achbxParameterName[i].Checked)
aiChecked[indexChecked++] = i;
SetNecessaryCycles();
Cursor = Cursors.WaitCursor;
progressBar.Value = 1;
progressPercent = 0;
computedCycles = 0;
chbOutOfSample.Enabled = false;
nudOutOfSample.Enabled = false;
isOptimizing = true;
btnCancel.Enabled = false;
btnAccept.Enabled = false;
btnOptimize.Text = Language.T("Stop");
foreach (Control control in pnlParams.Controls)
if(control.GetType() != typeof(Label))
control.Enabled = false;
foreach (Control control in pnlLimitations.Controls)
control.Enabled = false;
btnShowLimitations.Enabled = true;
btnShowSettings.Enabled = true;
// Start the bgWorker
bgWorker.RunWorkerAsync();
return;
}