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; } }
// 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); }