Exemplo n.º 1
0
        /// <summary>
        /// Should only call when in current task scope. Returns teh title of the task being archived
        /// </summary>
        /// <param name="cat"></param>
        /// <returns>the title of the task being archived</returns>
        public string ArchiveCurrentTask(Category cat)
        {
            if (currentTask == null)
            {
                throw new Exception(YouHaveNotLoadedACurrentTask);
            }

            string title = CurrentTask.Title;

            archiveList.Add(currentTask.SendToArchive(cat));
            currentTask = null;
            return(title);
        }
Exemplo n.º 2
0
 private void RePushCurrentTask()
 {
     if (currentTask != null)
     {
         if (CurrentTaskIsPrioritized)
         {
             priorityList.Push(CurrentTask as ZScheduledTask);
         }
         else
         {
             taskStack.Push(CurrentTask);
         }
         currentTask = null;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Fetches the current task
        /// </summary>
        private void LoadTask()
        {
            bool taskStackIsEmpty = taskStack.Empty();

            if (priorityList.Any())
            {
                if (priorityList.Peek().IsUrgent() || taskStackIsEmpty)
                {
                    currentTask = ZCurrentTask.MakeCurrentTaskWithPriority(priorityList.Pop());
                }
            }
            else if (taskStackIsEmpty)
            {
                throw new Exception("No tasks are pushed");
            }
            else
            {
                currentTask = ZCurrentTask.MakeCurrentTask(taskStack.Pop());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns title of the task being delayed.
        /// </summary>
        /// <returns>title of the delayed task</returns>
        public string PutOffCurrentTaskToBottom()
        {
            // Load Task and Check Priority
            if (currentTask == null)
            {
                LoadTask();
                Console.WriteLine("Warning: current task is not loaded, a task is auto-pushed as current task.");
            }
            CheckPriority();

            // Reserve title for return
            string title = CurrentTask.Title;

            // Push task back to stack and delay
            taskStack.Push(CurrentTask);
            currentTask = null;
            taskStack.DelayCurrentTaskToBottom();

            return(title);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Put off the current task by a number of positions.
        /// </summary>
        /// <param name="by">number of positions to put off</param>
        /// <returns>the name of the task being put off</returns>
        public string PutOffCurrentTask(int by)
        {
            // Load task if not already (with warning)
            if (currentTask == null)
            {
                LoadTask();
                Console.WriteLine("Warning: current task is not loaded, a task is auto-pushed as current task.");
            }

            // Make sure that the task is not prioritized, (Exception thrown otherwise)
            CheckPriority();

            // Push the current task back into the stack and delay it
            string title = CurrentTask.Title; //return the title later on

            taskStack.Push(CurrentTask);
            currentTask = null;
            taskStack.DelayCurrentTaskBy(by);

            return(title);
        }