private static void AddPrerequisityFor(string[] input) { int.TryParse(input[1], out var taskIndex); int.TryParse(input[2], out var prereqIndex); _system.AddPrerequisity(tasks[taskIndex], tasks[prereqIndex]); var prereqs = _system.GetPrerequisityList(tasks[taskIndex]); foreach (var task in prereqs) { Console.WriteLine(prereqs.IndexOf(task) + " | " + task); } }
private void editPrereqButton_Click(object sender, EventArgs e) { if (taskListBox.SelectedIndex > -1) { var tasks = _system.GetTaskList(); var selected = (Task)taskListBox.SelectedItem; tasks.Remove(selected); PrereqForm dialog = new PrereqForm(tasks, _system.GetPrerequisityList(selected)); dialog.Text = "Edit Prerequisities for Task: " + selected.Name; if (dialog.ShowDialog() == DialogResult.OK) { foreach (var prer in dialog.prerequisitiesAdded) { _system.AddPrerequisity(selected, prer); } foreach (var prer in dialog.prerequisitiesRemoved) { _system.RemovePrerequisity(selected, prer); } taskListBox_SelectedIndexChanged(sender, e); } } }