Forex_Strategy_Builder.Dialogs.Generator.Generator.BtnGenerate_Click C# (CSharp) Method

BtnGenerate_Click() private method

BtnGenerate_Click
private BtnGenerate_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        void BtnGenerate_Click(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)
                {
                    System.Media.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;

                indicatorsLayout.BlockIndikatorChange();

                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)
                    top10Layout.ClearTop10Slots();

                bgWorker.RunWorkerAsync();
            }

            return;
        }