private void GenerateTableRows()
        {
            foreach (KeyValuePair <string, string> pair in ConfigManager.programMap)
            {
                var checkbox = new GUIControlWrapper <CheckBox>();
                checkbox.control.CheckAlign = ContentAlignment.MiddleCenter;
                checkbox.SetAnchor(AnchorStyles.None);
                checkbox.control.Name            = $"{pair.Key}";
                checkbox.control.CheckedChanged += new EventHandler(ProgramCheckbox_CheckedChanged);

                var nameInput = new GUIControlWrapper <TextBox>();
                nameInput.Text = pair.Key;
                nameInput.SetAnchor(AnchorStyles.None);
                nameInput.control.Name   = $"{pair.Key}_name";
                nameInput.control.Enter += new EventHandler(Name_Focused);
                nameInput.control.Leave += new EventHandler(Name_Changed);

                var pathInput = new GUIControlWrapper <Label>();
                pathInput.Text           = pair.Value;
                pathInput.control.Click += new EventHandler(BrowseFile_Clicked);
                pathInput.SetAnchor(AnchorStyles.None);
                pathInput.control.Name = $"{pair.Key}_openpath";

                table.Controls.Add(checkbox.control, 0, -1);
                table.Controls.Add(nameInput.control, 1, -1);
                table.Controls.Add(pathInput.control, 2, -1);

                table.RowCount += 1;
            }
        }
        private Label GenerateTableHeading(string text)
        {
            var label = new GUIControlWrapper <Label>();

            label.Text = text;
            label.control.TextAlign = ContentAlignment.MiddleCenter;
            label.control.Font      = label.ConstructFont(fontSize: 8, bold: true);

            return(label.control);
        }
        // Generates a Form Control of specific type T with the given parameters; makes instantiating new Controls easier to read
        public static GUIControlWrapper <T> CreateControl <T>(int width, int height, int xPosition, int yPosition, AnchorStyles anchor = 0, int fontSize = 9) where T : System.Windows.Forms.Control, new()
        {
            var newControl = new GUIControlWrapper <T>(width, height);

            newControl.SetPosition(xPosition, yPosition);

            newControl.SetAnchor(anchor);

            newControl.control.Font = newControl.ConstructFont(fontSize);

            return(newControl);
        }
        // Construct the main GUI, containing input boxes and the output log
        public void ConstructMainGUI()
        {
            if (Opened)
            {
                return;
            }

            this.FormBorderStyle = FormBorderStyle.FixedSingle;

            this.Width  = 800;
            this.Height = 600;

            this.MaximizeBox = false;

            this.FormClosing += new FormClosingEventHandler(this.OnClosed);

            var title = CreateControl <Label>(600, 75, 100, 0, AnchorStyles.Left | AnchorStyles.Right);

            title.control.Font      = title.ConstructFont(24, bold: true, underline: true);
            title.control.Text      = "Voice Activated Assistant";
            title.control.TextAlign = ContentAlignment.MiddleCenter;

            this.output             = CreateControl <RichTextBox>(600, 300, 100, 100, AnchorStyles.Left | AnchorStyles.Right, 12);
            this.Output.BorderStyle = BorderStyle.FixedSingle;
            this.Output.ReadOnly    = true;
            this.Output.Enter      += new EventHandler(this.Output_Focused);

            this.input = CreateControl <RichTextBox>(525, 30, 100, 400, AnchorStyles.Left | AnchorStyles.Right, 12);
            this.input.control.Multiline   = false;
            this.input.control.BorderStyle = BorderStyle.FixedSingle;

            var sendButton = CreateControl <Button>(75, 29, 625, 400, AnchorStyles.Left | AnchorStyles.Right, 10);

            sendButton.Text = ">";
            sendButton.control.TextAlign = ContentAlignment.MiddleCenter;
            sendButton.control.Click    += new EventHandler(this.SubmitButton_Clicked);
            this.AcceptButton            = sendButton.control;

            var clearButton = CreateControl <Button>(108, 75, 100, 475, AnchorStyles.Left, 10);

            clearButton.Text = "Clear Chatlog";
            clearButton.control.TextAlign = ContentAlignment.MiddleCenter;
            clearButton.control.Click    += new EventHandler(this.ClearButton_Clicked);

            var runTestsButton = CreateControl <Button>(108, 75, 223, 475, AnchorStyles.Left, 10);

            runTestsButton.Text = "Run Tests";
            runTestsButton.control.TextAlign = ContentAlignment.MiddleCenter;
            runTestsButton.control.Click    += new EventHandler(this.RunTestsButton_Clicked);

            this.openConfigButton      = CreateControl <Button>(108, 75, 346, 475, AnchorStyles.Right, 10);
            this.openConfigButton.Text = "Open Config";
            this.openConfigButton.control.TextAlign = ContentAlignment.MiddleCenter;
            this.openConfigButton.control.Click    += new EventHandler(this.OpenConfigButton_Clicked);

            this.microphoneButton      = CreateControl <Button>(108, 75, 469, 475, AnchorStyles.Right, 10);
            this.microphoneButton.Text = microphoneToggle ? "Mute Microphone" : "Unmute Microphone";
            this.microphoneButton.control.TextAlign = ContentAlignment.MiddleCenter;
            this.microphoneButton.control.Click    += new EventHandler(this.MicrophoneButton_Clicked);

            this.voiceOutputButton      = CreateControl <Button>(108, 75, 592, 475, AnchorStyles.Right, 10);
            this.voiceOutputButton.Text = voiceOutputToggle ? "Mute Output" : "Unmute Output";
            this.voiceOutputButton.control.TextAlign = ContentAlignment.MiddleCenter;
            this.voiceOutputButton.control.Click    += new EventHandler(this.VoiceOutputButton_Clicked);

            this.Controls.Add(title.control);
            this.Controls.Add(this.Output);
            this.Controls.Add(this.input.control);
            this.Controls.Add(clearButton.control);
            this.Controls.Add(sendButton.control);
            this.Controls.Add(runTestsButton.control);
            this.Controls.Add(openConfigButton.control);
            this.Controls.Add(this.microphoneButton.control);
            this.Controls.Add(this.voiceOutputButton.control);

            MainGUI.Opened = true;

            Application.Run(this);

            MainGUI.Opened = false;

            Console.WriteLine("GUI thread closing");
        }