public TreeNode AddNewTask() { Task newTask = new Task("new task"); TreeNode newTreeNode = new TreeNode(); //newTreeNode.Text = newTask.Description; //TODO to check how it works with tostring overwritten newTreeNode.Text = newTask.ToString(); newTreeNode.BackColor = Color.White; this._taskDictionary.Add(newTreeNode, newTask); if (!tags.Contains(newTask.Tag)) { tags.Add(newTask.Tag); } return(newTreeNode); }
public Add(Task task) { InitializeComponent(); tbTitle.Text = task.Title; tbDescription.Text = task.Description; tbPerformer.Text = task.Performer; tbHour.Text = task.hour.ToString(); tbMinutes.Text = task.minutes.ToString(); tbData.Text = task.ToString(); rtbTags.Text = task.TegsToString(task.Tags); task.Tags.Clear(); task1 = task; }
private void uppdateTask(int index) { AddEditTask aet = new AddEditTask(); aet.EditMode = true; Task T = (Task)tasks[index]; aet.TaskName = T.Name; aet.TimeDue = T.DateDue; aet.TimeCreated = T.DateCreated; aet.TaskStatus = T.Status; bool?result = aet.ShowDialog(); if (result != result.HasValue) { return; } Task updatedTask = new Task(aet.TaskName, aet.TimeCreated, aet.TimeDue, aet.TaskStatus ); // Update confirmation MessageBoxResult result2; result2 = MessageBox.Show($"Are you sure you like to update {updatedTask.Name}'s details?", "Confirmation", MessageBoxButton.YesNo); if (result2 == MessageBoxResult.Yes) { tasks[index] = updatedTask; listBox1.Items[index] = updatedTask.ToString(); } else { return; } }
//Buttons private void button1_Click(object sender, EventArgs e) { if (tbHour.Text.Length != 0 && tbMinutes.Text.Length != 0) { task1.hour = int.Parse(tbHour.Text); task1.minutes = int.Parse(tbMinutes.Text); } task1.Title = tbTitle.Text; task1.Description = tbDescription.Text; task1.Performer = tbPerformer.Text; task1.day = monthCalendar1.SelectionRange.End.Day.ToString(); task1.month = monthCalendar1.SelectionRange.End.Month.ToString(); task1.year = monthCalendar1.SelectionRange.End.Year.ToString(); string TegsString = rtbTags.Text; string[] split = TegsString.Split(' '); task1.Tags.Clear(); foreach (string s in split) { task1.Tags.Add(s); } task1.Status = CheckStatus(task1); if (CheckTask(task1)) { tbData.Text = task1.ToString(); button2.PerformClick(); this.Close(); } else { MessageBox.Show("Тot correctly Write", "Error"); } }
public void UpdateCurrentTask(string controlName, string newValue, TreeView treeView) { if (treeView.SelectedNode != null) { switch (controlName) { case "registrationDateTextBox": _currentTaskOrSubtask.RegistrationDate = Convert.ToDateTime(newValue); //Convert.ToDateTime(control.Text); break; case "taskNameTextBox": _currentTaskOrSubtask.Description = newValue; //control.Text; //treeView.SelectedNode.Text = _currentTaskOrSubtask.Description; //TODO to check!!! treeView.SelectedNode.Text = _currentTaskOrSubtask.ToString(); break; case "tagTextBox": _currentTaskOrSubtask.Tag = newValue; treeView.SelectedNode.Text = _currentTaskOrSubtask.ToString(); //if (!tags.Contains(_currentTaskOrSubtask.Tag)) tags.Add(_currentTaskOrSubtask.Tag); break; case "statusDescriptionTextBox": _currentTaskOrSubtask.StatusDescription = newValue; treeView.SelectedNode.Text = _currentTaskOrSubtask.ToString(); break; case "taskStatusComboBox": _currentTaskOrSubtask.Status = (CommonTaskStatus)Convert.ToInt32(newValue); //(CommonTaskStatus)((ComboBox)control).SelectedIndex switch (_currentTaskOrSubtask.Status) { case CommonTaskStatus.New: treeView.SelectedNode.BackColor = Color.White; break; case CommonTaskStatus.InProgress: treeView.SelectedNode.BackColor = Color.Yellow; break; case CommonTaskStatus.Done: treeView.SelectedNode.BackColor = Color.LightGreen; break; case CommonTaskStatus.Weekly: treeView.SelectedNode.BackColor = Color.Fuchsia; break; case CommonTaskStatus.Monthly: treeView.SelectedNode.BackColor = Color.Cyan; break; default: treeView.SelectedNode.BackColor = Color.White; break; } //18-08-2015 if (_currentTaskOrSubtask.SubTaskList != null) { foreach (KeyValuePair <TreeNode, Task> subTaskPair in _currentTaskOrSubtask.SubTaskList) { if (subTaskPair.Value.Status < _currentTaskOrSubtask.Status) { subTaskPair.Value.Status = _currentTaskOrSubtask.Status; switch (subTaskPair.Value.Status) { case CommonTaskStatus.New: subTaskPair.Key.BackColor = Color.White; break; case CommonTaskStatus.InProgress: subTaskPair.Key.BackColor = Color.Yellow; break; case CommonTaskStatus.Done: subTaskPair.Key.BackColor = Color.LightGreen; break; case CommonTaskStatus.Weekly: subTaskPair.Key.BackColor = Color.Fuchsia; break; case CommonTaskStatus.Monthly: subTaskPair.Key.BackColor = Color.Cyan; break; default: subTaskPair.Key.BackColor = Color.White; break; } } } } break; default: break; } } }
private void readOutTaskOrSubTaskInfoFromXmlNodes(Boolean isSubtask, XmlNode taskOrSubtaskNode, TreeNode parentNodeKey) { Task taskOrSubTask = new Task(); TreeNode taskOrSubtaskNodeKey = new TreeNode(); Boolean subtaskExists = false; if ((taskOrSubtaskNode.Attributes != null) & (taskOrSubtaskNode.Attributes["Description"] != null)) { taskOrSubTask.Description = taskOrSubtaskNode.Attributes["Description"].Value; //taskOrSubtaskNodeKey.Text = taskOrSubTask.Description; //TODO to check } foreach (XmlNode taskOrSubTaskProperiesNode in taskOrSubtaskNode) { if (taskOrSubTaskProperiesNode.FirstChild != null) { switch (taskOrSubTaskProperiesNode.Name) { case "Status": taskOrSubTask.Status = (CommonTaskStatus)Convert.ToInt32(taskOrSubTaskProperiesNode.FirstChild.Value); //to check here switch (taskOrSubTask.Status) { case CommonTaskStatus.New: taskOrSubtaskNodeKey.BackColor = Color.White; break; case CommonTaskStatus.InProgress: taskOrSubtaskNodeKey.BackColor = Color.Yellow; break; case CommonTaskStatus.Done: taskOrSubtaskNodeKey.BackColor = Color.LightGreen; break; case CommonTaskStatus.Weekly: taskOrSubtaskNodeKey.BackColor = Color.Fuchsia; break; case CommonTaskStatus.Monthly: taskOrSubtaskNodeKey.BackColor = Color.Cyan; break; default: taskOrSubtaskNodeKey.BackColor = Color.White; break; } break; case "StatusDescription": taskOrSubTask.StatusDescription = taskOrSubTaskProperiesNode.FirstChild.Value; break; case "RegistrationDate": taskOrSubTask.RegistrationDate = Convert.ToDateTime(taskOrSubTaskProperiesNode.FirstChild.Value); break; case "Tag": taskOrSubTask.Tag = taskOrSubTaskProperiesNode.FirstChild.Value; break; case "SubTaskList": //WorkAround to eliminate issue with subtask adding to dictiionary while task isn't added to dictionary if (!isSubtask) { subtaskExists = true; taskOrSubtaskNodeKey.Text = taskOrSubTask.ToString(); //TODO new added to check this._taskDictionary.Add(taskOrSubtaskNodeKey, taskOrSubTask); if (!tags.Contains(taskOrSubTask.Tag)) { tags.Add(taskOrSubTask.Tag); } } if (taskOrSubTaskProperiesNode.HasChildNodes) { foreach (XmlNode subtaskNode in taskOrSubTaskProperiesNode.ChildNodes) { readOutTaskOrSubTaskInfoFromXmlNodes(true, subtaskNode, taskOrSubtaskNodeKey); } } break; default: break; } } } if (isSubtask) {//solved with WA issue при добавлении сабтаски в дикшенари парент (таска ) еще не добавлена в свой дикшенари -Ю нельзя найти парента и добавить сабтаску if (parentNodeKey != null) { taskOrSubtaskNodeKey.Text = taskOrSubTask.ToString();//TODO new added to check this._taskDictionary[parentNodeKey].SubTaskList.Add(taskOrSubtaskNodeKey, taskOrSubTask); if (!tags.Contains(taskOrSubTask.Tag)) { tags.Add(taskOrSubTask.Tag); } } } else if (!subtaskExists) { taskOrSubtaskNodeKey.Text = taskOrSubTask.ToString();//TODO new added to check this._taskDictionary.Add(taskOrSubtaskNodeKey, taskOrSubTask); if (!tags.Contains(taskOrSubTask.Tag)) { tags.Add(taskOrSubTask.Tag); } } }