private void buttonModify_Click(object sender, EventArgs e) { if (listBoxConstraints.SelectedIndex != -1) { int selectedIndex = listBoxConstraints.SelectedIndex; CSPInstanceEntry currentEntry = constraintInstance.createdEntries[selectedIndex]; currentEntry.constraintName = controller.getConstraints()[comboBoxConstraints.SelectedIndex].Name; currentEntry.typedInExpressions.Clear(); foreach (Expression typedExpression in CSPConstraintDataGridView1.getTypedExpressions()) { currentEntry.typedInExpressions.Add(typedExpression); } if (constraintInstance.createdEntries.Count <= selectedIndex) { constraintInstance.createdEntries.Insert(selectedIndex, currentEntry); } constraintInstance.createdEntries[selectedIndex] = currentEntry; listBoxConstraints.Items.RemoveAt(selectedIndex); listBoxConstraints.Items.Insert(selectedIndex, computeConstraintString(currentEntry)); listBoxConstraints.SelectedIndex = selectedIndex; } }
private void buttonAdd_Click(object sender, EventArgs e) { if (!this.CSPConstraintDataGridView1.getTypedInValues().Contains("")) { CSPInstanceEntry currentEntry = new CSPInstanceEntry(repository); foreach (Expression expr in CSPConstraintDataGridView1.getTypedExpressions()) { currentEntry.typedInExpressions.Add(expr); } currentEntry.constraintName = controller.getConstraints()[comboBoxConstraints.SelectedIndex].Name; constraintInstance.createdEntries.Add(currentEntry); this.listBoxConstraints.Items.Add(computeConstraintString(currentEntry)); listBoxConstraints.SelectedIndex = listBoxConstraints.Items.Count - 1; } }