/// <summary> /// Инициализация окна для истории /// </summary> /// <param name="task">Задача</param> public FHistory(TToDoItem task) { InitializeComponent(); Task = task; InitWindowAndData(); ExtLibs.Logger.Log.Info("Просмотр истории задачи"); }
/// <summary> /// Рекурсивный метод построения дерева /// </summary> /// <param name="root">Корень для текущей итерации</param> /// <param name="list">Список задач</param> public void BuiltTree(TreeNode root, TToDoItem rootitem) { // добавляем корневой узел //TreeNode node = new TreeNode(rootitem.Name, (int)rootitem.Status, (int)rootitem.Status); //int ind = root.Nodes.Add(node); // если есть узлы у него, подзадачи, то рекурсивно додавляем их for (int i = 0; i < rootitem.GetItemsCount; i++) { TreeNode node2 = new TreeNode(rootitem[i].Name, (int)rootitem[i].Status, (int)rootitem[i].Status); int ind2 = root.Nodes.Add(node2); BuiltTree(node2, rootitem[i]); } }
/// <summary> /// Вывод сведенией о задании /// </summary> /// <param name="treeNode">Выбранный в списке заданий узел</param> private void OutputTaskData(TreeNode treeNode) { //TToDoItem task = GlobalVars.List.GetTaskByName(treeNode.Text); CurrentTask = GlobalVars.List.GetTaskByName(treeNode.Text); // ищем и сохранаем найденную задачу в памяти if (CurrentTask != null) { // выводим данные по задаче nameTextBox.Text = CurrentTask.Name; dateTimePicker1.Value = CurrentTask.DateCreated; infoTextBox.Text = CurrentTask.Text; labelTextBox.Text = CurrentTask.Label; statusComboBox.SelectedIndex = (int)CurrentTask.Status; typeComboBox.SelectedIndex = (int)CurrentTask.Type; priorityComboBox.SelectedIndex = (int)CurrentTask.Priority; dateTimePicker2.Value = (CurrentTask.DataPlaned > DateTime.MinValue) ? CurrentTask.DataPlaned : DateTime.Now; dateTimePicker3.Value = (CurrentTask.DateComplete > DateTime.MinValue) ? CurrentTask.DateComplete : DateTime.Now; taskProgressBar.Value = CurrentTask.Progress; //CurrentTask = task; // сохранаем найденную задачу в памяти // обновление параметров компонентов для отображения данных задачи RefreshImages(); } }
/// <summary> /// Кнопка Создать /// </summary> private void CreateExecute(object sender, EventArgs e) { // поверка полей if (nameTextBox.Text == "") { MessageBox.Show("Не задано название задачи!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (infoTextBox.Text == "") { MessageBox.Show("Не введено содержание задачи!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (labelTextBox.Text == "") { MessageBox.Show("Не выбрана или не задана метка!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (statusComboBox.SelectedIndex < 0) { MessageBox.Show("Статус задачи не определен!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (typeComboBox.SelectedIndex < 0) { MessageBox.Show("Не определен тип задачи!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (priorityComboBox.SelectedIndex < 0) { MessageBox.Show("Приоритет задачи не определен!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // создание новго экземпляра задачи item = new TToDoItem(nameTextBox.Text, infoTextBox.Text, labelTextBox.Text, null, AppHelper.GetStatus(statusComboBox.SelectedIndex), AppHelper.GetType(typeComboBox.SelectedIndex), AppHelper.GetPriority(priorityComboBox.SelectedIndex)); string str = ""; str += Enum.Parse(typeof(TStatus), Enum.GetName(typeof(TStatus), statusComboBox.SelectedIndex)); str += " " + Enum.GetName(typeof(TStatus), statusComboBox.SelectedIndex); Console.WriteLine(str); // закрытие окна this.DialogResult = DialogResult.OK; this.Close(); }
private void GetLabels(TToDoItem rootitem, ref string[] buf) { Array.Resize(ref buf, buf.Length + 1); buf[buf.Length - 1] = rootitem.Label; // если есть узлы у него[узла текущего], подзадачи, то рекурсивно обходим их for (int i = 0; i < rootitem.GetItemsCount; i++) { Array.Resize(ref buf, buf.Length + 1); buf[buf.Length - 1] = rootitem[i].Label; GetLabels(rootitem[i], ref buf); } }