/// <summary> /// BtnGenerate_Click /// </summary> private void BtnGenerateClick(object sender, EventArgs e) { if (_isGenerating) { // Cancel the asynchronous operation BgWorker.CancelAsync(); } else { // Start the bgWorker PrepareStrategyForGenerating(); CheckForLockedSlots(); PrepareIndicatorLists(); bool isEnoughIndicators = CheckAvailableIndicators(); if (_isEntryLocked && _isExitLocked || !isEnoughIndicators) { SystemSounds.Hand.Play(); return; } Cursor = Cursors.WaitCursor; _minutes = (int)NUDWorkingMinutes.Value; ProgressBar.Style = _minutes > 0 ? ProgressBarStyle.Blocks : ProgressBarStyle.Marquee; GeneratedDescription = String.Empty; foreach (Control control in PnlCommon.Controls) { control.Enabled = false; } foreach (Control control in PnlLimitations.Controls) { control.Enabled = false; } foreach (Control control in PnlSettings.Controls) { control.Enabled = false; } IndicatorsField.BlockIndicatorChange(); TsbtLockAll.Enabled = false; TsbtUnlockAll.Enabled = false; TsbtLinkAll.Enabled = false; TsbtOverview.Enabled = false; TsbtStrategyInfo.Enabled = false; LblCalcStrInfo.Enabled = true; LblCalcStrNumb.Enabled = true; ChbHideFSB.Enabled = true; BtnAccept.Enabled = false; BtnCancel.Enabled = false; BtnGenerate.Text = Language.T("Stop"); _isGenerating = true; ProgressBar.Value = 1; _progressPercent = 0; _cycles = 0; if (ChbGenerateNewStrategy.Checked) { Top10Field.ClearTop10Slots(); } BgWorker.RunWorkerAsync(); } }