Exemple #1
0
        private void OnPaste_Click()
        {
            if (ClipTaskList != null)           //a taskList is on the clipboard
            {
                TaskList newTL = ClipTaskList.Copy();
                if (TreeHistory.Count > 0)               //not on main trunk
                {
                    newTL.Parent = ((TaskList)TreeHistory[TreeHistory.Count - 1]).TaskListNum;
                    switch (tabContr.SelectedIndex)
                    {
                    case 0:                            //main
                        //even though usually only trunks are dated, we will leave the date alone in main
                        //category since user may wish to preserve it. All other children get date cleared.
                        break;

                    case 1:                               //repeating
                        newTL.DateTL = DateTime.MinValue; //never a date
                        //leave dateType alone, since that affects how it repeats
                        break;

                    case 2:                                 //day
                    case 3:                                 //week
                    case 4:                                 //month
                        newTL.DateTL   = DateTime.MinValue; //children do not get dated
                        newTL.DateType = TaskDateType.None; //this doesn't matter either for children
                        break;
                    }
                }
                else                  //one of the main trunks
                {
                    newTL.Parent = 0;
                    switch (tabContr.SelectedIndex)
                    {
                    case 0:                            //main
                        newTL.DateTL   = DateTime.MinValue;
                        newTL.DateType = TaskDateType.None;
                        break;

                    case 1:                               //repeating
                        newTL.DateTL = DateTime.MinValue; //never a date
                        //newTL.DateType=TaskDateType.None;//leave alone
                        break;

                    case 2:                            //day
                        newTL.DateTL   = cal.SelectionStart;
                        newTL.DateType = TaskDateType.Day;
                        break;

                    case 3:                            //week
                        newTL.DateTL   = cal.SelectionStart;
                        newTL.DateType = TaskDateType.Week;
                        break;

                    case 4:                            //month
                        newTL.DateTL   = cal.SelectionStart;
                        newTL.DateType = TaskDateType.Month;
                        break;
                    }
                }
                if (tabContr.SelectedIndex == 1)               //repeating
                {
                    newTL.IsRepeating = true;
                }
                else
                {
                    newTL.IsRepeating = false;
                }
                newTL.FromNum = 0;              //always
                if (tabContr.SelectedIndex == 0)
                {
                    DuplicateExistingList(newTL, true);
                }
                else
                {
                    DuplicateExistingList(newTL, false);
                }
            }
            if (ClipTask != null)           //a task is on the clipboard
            {
                Task newT = ClipTask.Copy();
                if (TreeHistory.Count > 0)               //not on main trunk
                {
                    newT.TaskListNum = ((TaskList)TreeHistory[TreeHistory.Count - 1]).TaskListNum;
                    switch (tabContr.SelectedIndex)
                    {
                    case 0:                            //main
                        //even though usually only trunks are dated, we will leave the date alone in main
                        //category since user may wish to preserve it. All other children get date cleared.
                        break;

                    case 1:                                //repeating
                        newT.DateTask = DateTime.MinValue; //never a date
                        //leave dateType alone, since that affects how it repeats
                        break;

                    case 2:                                //day
                    case 3:                                //week
                    case 4:                                //month
                        newT.DateTask = DateTime.MinValue; //children do not get dated
                        newT.DateType = TaskDateType.None; //this doesn't matter either for children
                        break;
                    }
                }
                else                  //one of the main trunks
                {
                    newT.TaskListNum = 0;
                    switch (tabContr.SelectedIndex)
                    {
                    case 0:                            //main
                        newT.DateTask = DateTime.MinValue;
                        newT.DateType = TaskDateType.None;
                        break;

                    case 1:                                //repeating
                        newT.DateTask = DateTime.MinValue; //never a date
                        //newTL.DateType=TaskDateType.None;//leave alone
                        break;

                    case 2:                            //day
                        newT.DateTask = cal.SelectionStart;
                        newT.DateType = TaskDateType.Day;
                        break;

                    case 3:                            //week
                        newT.DateTask = cal.SelectionStart;
                        newT.DateType = TaskDateType.Week;
                        break;

                    case 4:                            //month
                        newT.DateTask = cal.SelectionStart;
                        newT.DateType = TaskDateType.Month;
                        break;
                    }
                }
                if (tabContr.SelectedIndex == 1)               //repeating
                {
                    newT.IsRepeating = true;
                }
                else
                {
                    newT.IsRepeating = false;
                }
                newT.FromNum = 0;              //always
                Tasks.InsertOrUpdate(newT, true);
            }
            if (WasCut)
            {
                if (ClipTaskList != null)
                {
                    DeleteEntireList(ClipTaskList);
                }
                else if (ClipTask != null)
                {
                    Tasks.Delete(ClipTask);
                }
            }
            FillMain();
        }