private void OnRenameTaskClick(object sender, EventArgs e)
 {
     try
     {
         TaskNode tn = this.SelectedNode as TaskNode;
         if (tn != null)
         {
             DlgAddTask adu = new DlgAddTask();
             adu.Task = tn.Task;
             if (adu.ShowDialog() == DialogResult.OK)
             {
                 tn.Text = adu.Task.TaskName;
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandler.ShowMessageBox(CGConstants.MODULE_TASKTREE, ex);
     }
 }
        private void OnAddTaskClick(object sender, EventArgs e)
        {
            try
            {
                DlgAddTask adt = new DlgAddTask();
                if (adt.ShowDialog() == DialogResult.OK)
                {
                    BaseNode bn = (BaseNode)this.SelectedNode;
                    TaskNode tn = new TaskNode(adt.Task);
                    bn.Nodes.Add(tn);
                    if (bn.Parent != null && bn.Parent.Nodes.Count > 0)
                    {
                        bn.Parent.Expand();
                    }
                }

                if (this.SelectedNode is BaseNode)
                {
                    BaseNode bn = this.SelectedNode as BaseNode;
                    if (bn != null)
                    {
                        RootNodeEventArgs re = new RootNodeEventArgs();
                        re.Tasks = new Collection <TaskInfo>();
                        foreach (TaskNode tasknode in bn.Nodes)
                        {
                            re.Tasks.Add(tasknode.Task);
                        }
                        OnRootNodeSelected(re);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowMessageBox(CGConstants.MODULE_TASKTREE, ex);
            }
        }