Ejemplo n.º 1
0
        private void MoveDown(object obj)
        {
            int curI = (int)SelectedTaskNode.Task.IndexNumber;

            if (SelectedTaskNode.ParentNode != null)
            {
                TreeNode parentNode = SelectedTaskNode.ParentNode;
                int      index      = parentNode.TreeNodes.IndexOf(SelectedTaskNode);
                parentNode.TreeNodes[index].Task.IndexNumber     = parentNode.TreeNodes[index + 1].Task.IndexNumber;
                parentNode.TreeNodes[index + 1].Task.IndexNumber = curI;

                DoTaskCommand(new KeyValuePair <TaskCommandEnum, Task>(TaskCommandEnum.Edit, parentNode.TreeNodes[index].Task));        // todo было бы прикольно вызывать так: parentNode.TreeNodes[index].Task.EditCommand()
                DoTaskCommand(new KeyValuePair <TaskCommandEnum, Task>(TaskCommandEnum.Edit, parentNode.TreeNodes[index + 1].Task));

                parentNode.TreeNodes.Move(index, index + 1);
                ChangeSelection(parentNode.TreeNodes[index + 1]);
            }
            else
            {
                int index = AllTreeRoots.IndexOf(SelectedTaskNode);
                AllTreeRoots[index].Task.IndexNumber     = AllTreeRoots[index + 1].Task.IndexNumber;
                AllTreeRoots[index + 1].Task.IndexNumber = curI;

                DoTaskCommand(new KeyValuePair <TaskCommandEnum, Task>(TaskCommandEnum.Edit, AllTreeRoots[index].Task));
                DoTaskCommand(new KeyValuePair <TaskCommandEnum, Task>(TaskCommandEnum.Edit, AllTreeRoots[index + 1].Task));

                AllTreeRoots.Move(index, index + 1);
                ChangeSelection(AllTreeRoots[index + 1]);
            }
        }
Ejemplo n.º 2
0
        private void MoveUp(object obj)
        {
            int      curI       = (int)SelectedTaskNode.Task.IndexNumber;
            TreeNode newSeleted = SelectedTaskNode;

            if (SelectedTaskNode.ParentNode != null)
            {
                TreeNode parentNode = SelectedTaskNode.ParentNode;
                int      index      = parentNode.TreeNodes.IndexOf(SelectedTaskNode);
                parentNode.TreeNodes[index].Task.IndexNumber     = parentNode.TreeNodes[index - 1].Task.IndexNumber;
                parentNode.TreeNodes[index - 1].Task.IndexNumber = curI;

                DoTaskCommand(new KeyValuePair <TaskCommandEnum, Task>(TaskCommandEnum.Edit, parentNode.TreeNodes[index].Task));
                DoTaskCommand(new KeyValuePair <TaskCommandEnum, Task>(TaskCommandEnum.Edit, parentNode.TreeNodes[index - 1].Task));

                parentNode.TreeNodes.Move(index, index - 1);
                ChangeSelection(parentNode.TreeNodes[index - 1]);
            }
            else
            {
                int index = AllTreeRoots.IndexOf(SelectedTaskNode);
                AllTreeRoots[index].Task.IndexNumber     = AllTreeRoots[index - 1].Task.IndexNumber;
                AllTreeRoots[index - 1].Task.IndexNumber = curI;

                DoTaskCommand(new KeyValuePair <TaskCommandEnum, Task>(TaskCommandEnum.Edit, AllTreeRoots[index].Task));
                DoTaskCommand(new KeyValuePair <TaskCommandEnum, Task>(TaskCommandEnum.Edit, AllTreeRoots[index - 1].Task));

                AllTreeRoots.Move(index, index - 1);
                ChangeSelection(AllTreeRoots[index - 1]);
            }
        }