Ejemplo n.º 1
0
        public void Add(MapNode node)
        {
            DateTime dateTime = node.GetDueDate();
            ControlGroup ctrlGroup = GetApplicableGroup(dateTime);

            if (ctrlGroup != null)
            {
                ITaskGroup taskGroup = (ITaskGroup)ctrlGroup.Tag;
                TaskView tv = new TaskView(node, taskGroup.ShortDueDateString(dateTime), OnTaskViewEvent);
                AddToGroup(ctrlGroup, tv);
            }
        }
Ejemplo n.º 2
0
        public void Add(MapNode node)
        {
            DateTime     dateTime  = node.GetDueDate();
            ControlGroup ctrlGroup = GetApplicableGroup(dateTime);

            if (ctrlGroup != null)
            {
                ITaskGroup taskGroup = (ITaskGroup)ctrlGroup.Tag;
                TaskView   tv        = new TaskView(node, taskGroup.ShortDueDateString(dateTime), OnTaskViewEvent);
                AddToGroup(ctrlGroup, tv);
            }
        }
Ejemplo n.º 3
0
        public void Add(TaskView tv)
        {
            ControlGroup ctrlGroup = GetApplicableGroup(tv.DueDate);

            if (ctrlGroup != null)
            {
                ITaskGroup taskGroup = (ITaskGroup)ctrlGroup.Tag;
                tv.TaskDueOnText = taskGroup.ShortDueDateString(tv.DueDate);
                tv.RefreshTaskPath();
                tv.TaskTitle = tv.MapNode.Text;
                AddToGroup(ctrlGroup, tv);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called as the day changes to refresh task list
        /// </summary>
        public void RefreshTaskList()
        {
            TaskView tv = (TaskView)GetFirstControl();

            while (tv != null)
            {
                RemoveTask(tv);
                Add(tv);
                tv = (TaskView)GetNextControl(tv);
            }

            todayDate = DateTime.Today;
        }
Ejemplo n.º 5
0
        public void Add(TaskView tv)
        {
            ControlGroup ctrlGroup = GetApplicableGroup(tv.DueDate);

            if (ctrlGroup != null)
            {
                ITaskGroup taskGroup = (ITaskGroup)ctrlGroup.Tag;
                tv.TaskDueOnText = taskGroup.ShortDueDateString(tv.DueDate);
                tv.RefreshTaskPath();
                tv.TaskTitle = tv.MapNode.Text;
                AddToGroup(ctrlGroup, tv);
            }
        }
Ejemplo n.º 6
0
        public void Clear(MapTree tree)
        {
            TaskView tv = (TaskView)GetFirstControl();

            while (tv != null)
            {
                TaskView nextTV = (TaskView)GetNextControl(tv);

                if (tv.MapNode.Tree == tree)
                {
                    RemoveTask(tv);
                }

                tv = nextTV;
            }
        }
Ejemplo n.º 7
0
        public void OnTaskViewEvent(TaskView tv, TaskView.TaskViewEvent e)
        {
            switch (e)
            {
            case TaskView.TaskViewEvent.Remove:
                tv.MapNode.RemoveTask();
                break;

            case TaskView.TaskViewEvent.Complete:
                tv.MapNode.CompleteTask();
                break;

            case TaskView.TaskViewEvent.Defer:
                MoveDown(tv);
                break;

            case TaskView.TaskViewEvent.Expedite:
                MoveUp(tv);
                break;

            case TaskView.TaskViewEvent.Edit:
                SetDueDateUsingPicker(tv.MapNode);
                break;

            case TaskView.TaskViewEvent.Today:
                SetDueDateToday(tv.MapNode);
                break;

            case TaskView.TaskViewEvent.Tomorrow:
                SetDueDateTomorrow(tv.MapNode);
                break;

            case TaskView.TaskViewEvent.NextWeek:
                SetDueDateNextWeek(tv.MapNode);
                break;

            case TaskView.TaskViewEvent.NextMonth:
                SetDueDateNextMonth(tv.MapNode);
                break;

            case TaskView.TaskViewEvent.NextQuarter:
                SetDueDateNextQuarter(tv.MapNode);
                break;
            }

            PluginManager.FocusMapEditor();
        }
Ejemplo n.º 8
0
        private TaskView FindTaskViewInGroup(ControlGroup taskGroup, MapNode node, DateTime dueDate)
        {
            for (int i = 0; i < taskGroup.Count; i++)
            {
                TaskView tv = (TaskView)taskGroup[i];
                if (tv.MapNode == node)
                {
                    return(tv);
                }

                if (tv.DueDate > dueDate)
                {
                    break;
                }
            }

            return(null);
        }
Ejemplo n.º 9
0
        private void RemoveTask(TaskView tv)
        {
            var taskGroup = GetControlGroup(tv);

            taskGroup.Remove(tv);
        }
Ejemplo n.º 10
0
 private void OnTaskViewEvent(TaskView tv, TaskView.TaskViewEvent e)
 {
     TaskViewEvent(tv, e);
 }
Ejemplo n.º 11
0
        private void AddToGroup(ControlGroup taskGroup, TaskView taskView)
        {
            if (taskGroup.Count == 0)
            {
                taskGroup.Add(taskView); // add if list is empty
            }
            else
            {
                for (int i = taskGroup.Count - 1; i >= 0; i--)
                {
                    TaskView tv = (TaskView)taskGroup[i];
                    if (tv.DueDate > taskView.DueDate)
                    {
                        continue;
                    }
                    else
                    {
                        taskGroup.Insert(i + 1, taskView); // add in the middle or end
                        return;
                    }
                }

                taskGroup.Insert(0, taskView); // add at the top after all controls are moved down using loop
            }
        }
Ejemplo n.º 12
0
        public void MoveUp(TaskView tv)
        {
            DateTime updateDate = tv.DueDate.Subtract(TimeSpan.FromDays(1)); //new date for TaskView  (setting default value, used if nothing else works)

            TaskView prevTV = (TaskView)GetPreviousControl(tv, true);
            if (prevTV != null) //1- Move Down within a group
            {
                //1.1 Calculate due date 1 hour before previous
                DateTime previousDueDate = prevTV.MapNode.GetDueDate();
                updateDate = previousDueDate.Subtract(TimeSpan.FromHours(1));

                //1.2 Check if it falls between 'previous' and 'previous to previous'
                TaskView previousToPrevious = (TaskView)GetPreviousControl(prevTV, true);
                if (previousToPrevious != null)
                {
                    DateTime previousToPreviousDueDate = previousToPrevious.MapNode.GetDueDate();
                    if (updateDate < previousToPreviousDueDate)
                    {
                        updateDate = updateDate.Subtract(TimeSpan.FromTicks((previousToPreviousDueDate - previousDueDate).Ticks / 2));
                    }
                }

                //1.3 Check if calculated due date stays within the group
                if (!GetTaskGroup(tv).CanContain(updateDate))
                {
                    updateDate = GetTaskGroup(tv).StartTime;
                }

            }
            else //2- Move up to previous group
            {
                ControlGroup cg = GetPreviousControlGroup(GetControlGroup(tv));

                //2.1 Check if we are not in the first group
                if (cg != null)
                {
                    //2.1.1 set the default first due date of the group
                    updateDate = GetTaskGroup(cg).EndTime.Subtract(new TimeSpan(16,59,59));

                    //2.1.2 Check if due date is after the last existing item
                    if (cg.Count > 0 && ((TaskView)cg[cg.Count - 1]).DueDate >= updateDate)
                        updateDate = GetTaskGroup(cg).EndTime;

                    //2.1.3 Check if due date is after the orignal date
                    if (updateDate > tv.DueDate)
                        updateDate = GetTaskGroup(cg).StartTime.Date;

                }
            }

            //3- Update due date
            tv.MapNode.UpdateDueDate(updateDate);
        }
Ejemplo n.º 13
0
        public void MoveDown(TaskView tv)
        {
            DateTime updateDate = tv.DueDate.AddDays(5); //new date for TaskView  (setting default value, used if nothing else works)

            TaskView nextTV = (TaskView)GetNextControl(tv, true);
            if (nextTV != null) //1- Move Down within a group
            {
                //1.1 Calculate due date 1 hour after next
                DateTime nextDueDate = nextTV.MapNode.GetDueDate();
                updateDate = nextDueDate.AddHours(1);

                //1.2 Check if it falls between 'next' and 'next to next'
                TaskView nextToNext = (TaskView)GetNextControl(nextTV, true);
                if (nextToNext != null)
                {
                    DateTime nextToNextDueDate = nextToNext.MapNode.GetDueDate();
                    if (updateDate > nextToNextDueDate)
                    {
                        updateDate = updateDate.AddTicks((nextToNextDueDate - nextDueDate).Ticks / 2);
                    }
                }

                //1.3 Check if calculated due date stays within the group
                if(!GetTaskGroup(tv).CanContain(updateDate))
                {
                    updateDate = GetTaskGroup(tv).EndTime;
                }

            }
            else //2- Move Down to next group
            {
                ControlGroup cg = GetNextControlGroup(GetControlGroup(tv));

                //2.1 Check if we are not in the last group
                if (cg != null)
                {
                    //2.1.1 set the default first due date of the group
                    updateDate = GetTaskGroup(cg).StartTime.AddHours(7);

                    //2.1.2 Check if due date is before the first existing item
                    if (cg.Count > 0 && ((TaskView)cg[0]).DueDate <= updateDate)
                        updateDate = GetTaskGroup(cg).StartTime;

                    //2.1.3 Check if due date is before the orignal date
                    if (updateDate <= tv.DueDate)
                    {
                        if (GetTaskGroup(cg).EndTime.Date <= tv.DueDate)
                            updateDate = tv.DueDate.AddDays(1);
                        else
                            updateDate = GetTaskGroup(cg).EndTime.Date;
                    }

                }
            }

            //3- Update due date
            tv.MapNode.UpdateDueDate(updateDate);
        }
Ejemplo n.º 14
0
 public ITaskGroup GetTaskGroup(TaskView tv)
 {
     return (ITaskGroup)GetControlGroup(tv).Tag;
 }
Ejemplo n.º 15
0
 public ITaskGroup GetTaskGroup(TaskView tv)
 {
     return((ITaskGroup)GetControlGroup(tv).Tag);
 }
Ejemplo n.º 16
0
 private void MoveUp(TaskView tv)
 {
     taskListView.MoveUp(tv);
 }
Ejemplo n.º 17
0
        public void MoveDown(TaskView tv)
        {
            DateTime updateDate = tv.DueDate.AddDays(5); //new date for TaskView  (setting default value, used if nothing else works)

            TaskView nextTV = (TaskView)GetNextControl(tv, true);

            if (nextTV != null) //1- Move Down within a group
            {
                //1.1 Calculate due date 1 hour after next
                DateTime nextDueDate = nextTV.MapNode.GetDueDate();
                updateDate = nextDueDate.AddHours(1);

                //1.2 Check if it falls between 'next' and 'next to next'
                TaskView nextToNext = (TaskView)GetNextControl(nextTV, true);
                if (nextToNext != null)
                {
                    DateTime nextToNextDueDate = nextToNext.MapNode.GetDueDate();
                    if (updateDate > nextToNextDueDate)
                    {
                        updateDate = updateDate.AddTicks((nextToNextDueDate - nextDueDate).Ticks / 2);
                    }
                }

                //1.3 Check if calculated due date stays within the group
                if (!GetTaskGroup(tv).CanContain(updateDate))
                {
                    updateDate = GetTaskGroup(tv).EndTime;
                }
            }
            else //2- Move Down to next group
            {
                ControlGroup cg = GetNextControlGroup(GetControlGroup(tv));

                //2.1 Check if we are not in the last group
                if (cg != null)
                {
                    //2.1.1 set the default first due date of the group
                    updateDate = GetTaskGroup(cg).StartTime.AddHours(7);

                    //2.1.2 Check if due date is before the first existing item
                    if (cg.Count > 0 && ((TaskView)cg[0]).DueDate <= updateDate)
                    {
                        updateDate = GetTaskGroup(cg).StartTime;
                    }

                    //2.1.3 Check if due date is before the orignal date
                    if (updateDate <= tv.DueDate)
                    {
                        if (GetTaskGroup(cg).EndTime.Date <= tv.DueDate)
                        {
                            updateDate = tv.DueDate.AddDays(1);
                        }
                        else
                        {
                            updateDate = GetTaskGroup(cg).EndTime.Date;
                        }
                    }
                }
            }

            //3- Update due date
            tv.MapNode.UpdateDueDate(updateDate);
        }
Ejemplo n.º 18
0
 private void OnTaskViewEvent(TaskView tv, TaskView.TaskViewEvent e)
 {
     TaskViewEvent(tv, e);
 }
Ejemplo n.º 19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="tv"></param>
 private void MoveDown(TaskView tv)
 {
     taskListView.MoveDown(tv);
 }
Ejemplo n.º 20
0
        private void RemoveTask(TaskView tv)
        {
            var taskGroup = GetControlGroup(tv);

            taskGroup.Remove(tv);
        }