private void SendRowToTerminal(object sender, EventArgs e)
        {
            if (TargetRow == null)
            {
                return;
            }

            CsHelpLayoutPanel panel = (CsHelpLayoutPanel)TargetRow.DataGridView.Parent;

            if (panel == null)
            {
                return;
            }

            object cell0 = TargetRow.Cells[0].Value;

            if (cell0 == null)
            {
                return;
            }

            string result = "";

            switch (TargetRow.DataGridView.Name)
            {
            case CsHelp_GUI.CSH_METHODS:
                result += cell0.ToString();
                ParameterInfo[] parameters = panel.GetMethodInfoAtRow(TargetRow).GetParameters();
                for (int i = 0; i < parameters.Length; i++)
                {
                    result += " " + TclAPI.GetStringLabelForType(parameters[i].ParameterType);
                }
                break;

            default:
                result += cell0.ToString();
                break;
            }

            RichTextBox terminal = ConsoleCtrl.TCLTerminal_input;

            terminal.AppendText(result);
            terminal.Focus();
        }
        public static void CreateDialog()
        {
            CsHelpForm prompt = new CsHelpForm
            {
                Width  = 800,
                Height = 600,
                Text   = "CS Help"
            };

            prompt.ParameterlessMode();

            CsHelpLayoutPanel panel = new CsHelpLayoutPanel
            {
                Dock       = DockStyle.Fill,
                AutoScroll = true,
                Margin     = new Padding(0, 0, 0, 0),
                Name       = "cshelppanel"
            };

            prompt.AddControl(panel);

            RichTextBox txtBox = new RichTextBox
            {
                Dock     = DockStyle.Fill,
                AutoSize = true,
                ReadOnly = true,
                Anchor   = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom,
                Margin   = new Padding(5, 5, 5, 5)
            };

            string NL = "" + Environment.NewLine;

            txtBox.AppendText("TCL version 8.6" + NL);
            txtBox.AppendText(NL + "-------------------------------------------------------------------" + NL + NL + NL);
            txtBox.AppendText("API Commands" + NL + NL);

            txtBox.AppendText("cshelp", color_extraTcl);
            txtBox.AppendText(" singletons" + NL);
            txtBox.AppendText("Opens a list of all singleton objects that exist in GoAhead." + NL);
            txtBox.AppendText("cshelp", color_extraTcl);
            txtBox.AppendText(" enums" + NL);
            txtBox.AppendText("Opens a list of all enums that exist in GoAhead." + NL);
            txtBox.AppendText("cshelp", color_extraTcl);
            txtBox.AppendText(" $object" + NL);
            txtBox.AppendText("Opens a list of all methods and properties that can be executed on 'object', as well as the static members of its type." + NL);
            txtBox.AppendText("'object' can either be the name of a singleton or a GoAhead object in the API's TCL form." + NL);
            txtBox.AppendText("cshelp", color_extraTcl);
            txtBox.AppendText(" $typeName" + NL);
            txtBox.AppendText("Opens a list of all static methods and properties that can be executed from the type 'typeName'." + NL);
            txtBox.AppendText("'typeName' should be the full name of a C# type." + NL + NL);

            txtBox.AppendText("cs", color_extraTcl);
            txtBox.AppendText(" $object $member $parameters" + NL);
            txtBox.AppendText("Used to access the property or method 'member' of the object 'object'." + NL);
            txtBox.AppendText("'object' can either be the name of a singleton or a GoAhead object in the API's TCL form." + NL);
            txtBox.AppendText("If 'member' is a method which requires parameters then we need to supply 'parameters' where each parameter must be prefixed by a type identifier symbol. " +
                              "The symbols are automatically supplied when using the 'Right Click -> Send to terminal' functionality on the method in the cshelp window." + NL);
            txtBox.AppendText("cs", color_extraTcl);
            txtBox.AppendText(" $typeName $member $parameters" + NL);
            txtBox.AppendText("Used to access the static property or method 'member' of the type 'typeName'." + NL);
            txtBox.AppendText("'typeName' should be the full name of a C# type." + NL + NL);

            txtBox.AppendText("cslist", color_extraTcl);
            txtBox.AppendText(" $object" + NL);
            txtBox.AppendText("Converts 'object' into a TCL list if a conversion is possible." + NL);
            txtBox.AppendText("'object' is an object in the API's TCL form." + NL);
            txtBox.AppendText("cslist", color_extraTcl);
            txtBox.AppendText(" $object $member $parameters" + NL);
            txtBox.AppendText("First executes the command 'cs $object $member $parameters' and then 'cslist $result' " +
                              "where 'result' is the result of the cs command." + NL + NL);

            txtBox.AppendText("clear" + NL, color_extraTcl);
            txtBox.AppendText("Clears the TCL console." + NL + NL);

            txtBox.AppendText("clearcontext" + NL, color_extraTcl);
            txtBox.AppendText("Warning: Use with caution." + NL);
            txtBox.AppendText("Clears the TCL context. This clears all the current TCL to C# object references in the context. " +
                              "This is automatically called during OpenBinFPGA." + NL + NL);

            txtBox.AppendText("Every GOA command is also a TCL command." + NL + NL);

            txtBox.AppendText(NL + "-------------------------------------------------------------------" + NL + NL + NL);

            txtBox.AppendText("Standard TCL commands:" + NL + NL);

            foreach (string cmd in CommandsList.Commands)
            {
                txtBox.AppendText(cmd + NL, color_standardTcl);
            }

            txtBox.SelectionStart = 0;
            txtBox.ScrollToCaret();
            panel.Controls.Add(txtBox);

            prompt.Show();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="caption"></param>
        /// <param name="scope">(keyword, ((abbreviated, row[])))</param>
        public static void CreateDialog(List <string> grids, string scopeStr, object scope)
        {
            CsHelpForm prompt = new CsHelpForm
            {
                Width  = 800,
                Height = 600,
                Text   = "CS Help"
            };

            prompt.SetScopeLabel(scopeStr);
            if (scope == null)
            {
                prompt.DeactivateObjectElements();
            }

            CsHelpLayoutPanel panel = new CsHelpLayoutPanel
            {
                Dock       = DockStyle.Fill,
                AutoScroll = true,
                Margin     = new Padding(0, 0, 0, 0),
                Name       = "cshelppanel",
                Scope      = scope
            };

            prompt.AddControl(panel);

            // Singletons
            if (grids.Contains(CSH_SINGLETONS))
            {
                string[] columns = new string[]
                {
                    "Singleton",
                    "Full Name"
                };
                DataGridView grid = CreateGrid(columns);
                grid.Name = CSH_SINGLETONS;

                panel.Controls.Add(grid);
            }

            // Properties
            if (grids.Contains(CSH_PROPERTIES))
            {
                string[] columns = new string[]
                {
                    "Property",
                    "Value",
                    "Type"
                };
                DataGridView grid = CreateGrid(columns);
                grid.Name = CSH_PROPERTIES;

                panel.Controls.Add(grid);
            }

            // Methods
            if (grids.Contains(CSH_METHODS))
            {
                string[] columns = new string[]
                {
                    "Method",
                    "Parameters",
                    "Return Type"
                };
                DataGridView grid = CreateGrid(columns);
                grid.Name = CSH_METHODS;

                panel.Controls.Add(grid);
            }

            // Enums
            if (grids.Contains(CSH_ENUMS))
            {
                string[] columns = new string[]
                {
                    "Enum",
                    "Full Name",
                    "Values"
                };
                DataGridView grid = CreateGrid(columns);
                grid.Name = CSH_ENUMS;

                panel.Controls.Add(grid);
            }

            // Static Properties
            if (grids.Contains(CSH_PROPERTIES_STATIC))
            {
                string[] columns = new string[]
                {
                    "Static Property",
                    "Value",
                    "Type"
                };
                DataGridView grid = CreateGrid(columns);
                grid.Name = CSH_PROPERTIES_STATIC;

                panel.Controls.Add(grid);
            }

            // Static Methods
            if (grids.Contains(CSH_METHODS_STATIC))
            {
                string[] columns = new string[]
                {
                    "Static Method",
                    "Parameters",
                    "Return Type"
                };
                DataGridView grid = CreateGrid(columns);
                grid.Name = CSH_METHODS_STATIC;

                panel.Controls.Add(grid);
            }

            prompt.Show();
            panel.PopulateGrids(false, scopeStr);
        }