private void AddTask(Task parentTask) { var addTaskViewModel = new AddTaskViewModel(addTaskViewFactory.Create(), tasksRepository); addTaskViewModel.ParentTask = parentTask; addTaskViewModel.Present(); SelectedItem = null; UpdateTasks(); }
private void CreateTaskHandler(object sender, DelegateCommandEventArgs eventArgs) { var task = new Task(TaskName, Executors); if (ParentTask != null) { ParentTask.AddSubtask(task); } tasksRepository.Add(task); view.Close(); }
public void AddSubtask(Task task) { if (task == this) { throw new ArgumentException("задача не может быть подзадачей для самой себя"); } if(!subtasks.Contains(task)) { task.ParentTask = this; subtasks.Add(task); } }
private TreeViewItem CreateTaskTreeViewItem(Task task) { var taskTreeViewItem = new TreeViewItem(); taskTreeViewItem.DataContext = task; taskTreeViewItem.Header = task.Name; foreach(var childTask in task.Subtasks) { taskTreeViewItem.Items.Add(CreateTaskTreeViewItem(childTask)); } return taskTreeViewItem; }