private void Evaluate()
        {
            if (!btnEvaluate.Enabled)
            {
                return;
            }

            Hashtable parameters = new Hashtable();

            foreach (Control ctrl in pnlVariables.Controls)
            {
                if (ctrl.Visible)
                {
                    Panel pnl = ctrl as Panel;
                    if (pnl != null)
                    {
                        parameters.Add(pnl.Tag, pnl.Controls[1].Text);
                    }
                }
            }
            string message;

            double[] data = SyntheticGenerator.GenerateData(tbNoOfSamples.Value, tbSamplesPerSecond.Value, tctFormula.Text, parameters, out message);
            if (message != null)
            {
                lblMessage.Text = message;
                spectrum.Series[0].Points.Clear();
            }
            else
            {
                lblMessage.Text = "";
                FftAnalyzer.Windowing(tbNoOfSamples.Value, data, WindowType, 1, data, false);
                RenderScopeData(data);
                _fftAnalyzer.ExecuteFftAsync(data, SamplesPerSecond, 1, WindowingTypes.Square); // already windowed.
            }
        }
        private void GetVariables()
        {
            foreach (Control ctrl in pnlVariables.Controls)
            {
                ctrl.Visible = false;
            }

            string message;
            var    extractedParameters = SyntheticGenerator.ExtractVariables(tctFormula.Text, out message);

            if (message != null)
            {
                lblMessage.Text = message;
            }
            else
            {
                lblMessage.Text = "";
                foreach (
                    var param in
                    extractedParameters.Where(p => p.ToLowerInvariant() != "pi" && p.ToLowerInvariant() != "t"))
                {
                    string key = $"var_{param}";
                    if (!pnlVariables.Controls.ContainsKey(key))
                    {
                        // Add new
                        Panel pnl = new Panel
                        {
                            BorderStyle = BorderStyle.FixedSingle,
                            Name        = key,
                            Tag         = param,
                            Size        = new Size(143, 29)
                        };
                        pnlVariables.Controls.Add(pnl);

                        Label lbl = new Label
                        {
                            Text     = param,
                            AutoSize = true,
                            Location = new Point(8, 8),
                            Name     = $"varl_{param}"
                        };
                        pnl.Controls.Add(lbl);

                        TextBox txt = new TextBox
                        {
                            Text     = "",
                            Location = new Point(66, 3),
                            Size     = new Size(67, 20),
                            Name     = $"vart_{param}"
                        };
                        txt.TextChanged += Txt_TextChanged;
                        txt.KeyDown     += Txt_KeyDown;
                        txt.KeyPress    += Txt_KeyPress;
                        pnl.Controls.Add(txt);
                    }
                    else
                    {
                        pnlVariables.Controls[key].Visible = true;
                    }
                }
                CheckEnableRun();
            }
        }