private void LoadProject() { if (projectListCombo.Text == "") { return; } int curRow = 0; List <TFVariableModel> variables = TFVariableParser.GetAsModel(projectListCombo.Text); variableTable.Controls.Clear(); variables.ForEach(delegate(TFVariableModel variable) { Label _desc = new Label { Text = variable.Name, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill }; TextBox _defVal = new TextBox { Text = variable.DefaultVal, Name = variable.Name, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill }; Button _infobutton = new Button { Text = "i" }; _infobutton.Click += (s, e) => { showInfo(variable.Desc); }; variableTable.Controls.Add(_desc, 0, curRow); variableTable.Controls.Add(_defVal, 1, curRow); variableTable.Controls.Add(_infobutton, 2, curRow); curRow += 1; }); foreach (RowStyle RS in variableTable.RowStyles) { RS.SizeType = SizeType.Absolute; RS.Height = 030; } loadProjectState(); }
private void variableSaveButton_Click(object sender, EventArgs e) { List <TFVariableModel> variables = TFVariableParser.GetAsModel(projectListCombo.Text); int n = 0; variables.ForEach(delegate(TFVariableModel variable){ Control[] _found = variableTable.Controls.Find(variable.Name, true); variables[n].DefaultVal = _found[0].Text; n += 1; }); String res = TFVariableParser.SaveToProject(projectListCombo.Text, variables); if (res == "ok") { MessageBox.Show("Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Please edit manually", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } }