コード例 #1
0
        public void ZTaskManager_SelectTasks(TaskFlag flag, IEnumerable <ITask> expectedResult)
        {
            // Arrange
            foreach (var task in tasks)
            {
                manager.PushTask(task);
            }
            foreach (var task in pTasks)
            {
                manager.PushTaskWithPriority(task);
            }

            manager.Update();

            // Assert
            Assert.That(manager.SelectTasks(flag), Is.EquivalentTo(expectedResult));
        }
コード例 #2
0
        public void View_SelectedTasks(string[] commands)
        {
            // Arrange
            bool     detail    = false;
            TaskFlag selection = TaskFlag.None;

            // Collect selection flags
            for (int i = 1; i < commands.Length; ++i)
            {
                switch (commands[i])
                {
                case PrioritizedTaskFlag:
                    selection = selection | TaskFlag.Prioritized;
                    break;

                case NonPrioritizedTaskFlag:
                    selection = selection | TaskFlag.NonPrioritized;
                    break;

                case UrgentTaskFlag:
                    selection = selection | TaskFlag.Urgent;
                    break;

                case DangerTaskFlag:
                    selection = selection | TaskFlag.Danger;
                    break;

                case ScheduledTaskFlag:
                    selection = selection | TaskFlag.Scheduled;
                    break;

                case NonScheduledTaskFlag:
                    selection = selection | TaskFlag.NonScheduled;
                    break;

                case ShowDetail:
                    detail = true;
                    break;

                default:
                    throw new Exception("Bad selection command");
                }
            }

            // Select tasks and Print
            var selectedTasks = manager.SelectTasks(selection);

            if (selectedTasks.Any())
            {
                if (detail)
                {
                    Print(FormatUtil.BreakLine);
                    ConsoleUtil.WriteTasksInDetail(selectedTasks);
                    detail = false;
                }
                else
                {
                    for (int i = 0; i < selectedTasks.Count; ++i)
                    {
                        Print($"{i}. {selectedTasks[i].Title}");
                    }
                }
            }
        }
コード例 #3
0
ファイル: Task.cs プロジェクト: valentinbreiz/Sharpen
 /// <summary>
 /// Removes a flag from the task
 /// </summary>
 /// <param name="flag">The flag</param>
 public void RemoveFlag(TaskFlag flag)
 {
     m_flags &= ~flag;
 }
コード例 #4
0
ファイル: Task.cs プロジェクト: valentinbreiz/Sharpen
 /// <summary>
 /// Adds a flag to the task
 /// </summary>
 /// <param name="flag">The flag</param>
 public void AddFlag(TaskFlag flag)
 {
     m_flags |= flag;
 }
コード例 #5
0
ファイル: Task.cs プロジェクト: valentinbreiz/Sharpen
 /// <summary>
 /// Checks if the task has a flag
 /// </summary>
 /// <param name="flag">The flag</param>
 /// <returns>If it has the flag</returns>
 public bool HasFlag(TaskFlag flag)
 {
     return((m_flags & flag) == flag);
 }
コード例 #6
0
 public TaskItem(TaskFlag flag, Playground hive = null, PlaygroundHost host = null, string depotKey = null, string appId = null)
 {
     this.Flag = flag;
     this.Hive = hive;
     this.Host = host;
     this.DepotKey = depotKey;
     this.AppId = appId;
 }
コード例 #7
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        Gdk.Pixbuf GetSmallFlag(TaskFlag flag)
        {
            if (!m_small_flags.ContainsKey (flag)) {
                var pixbuf = GetFlag (flag);
                m_small_flags [flag] = pixbuf.ScaleSimple (12, 12, Gdk.InterpType.Bilinear);
            }

            return m_small_flags [flag];
        }
コード例 #8
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        Gdk.Pixbuf GetFlag(TaskFlag flag)
        {
            if (!m_flags.ContainsKey (flag)) {
                var flag_name = flag.ToString ().ToLower ();
                var pixbuf = new Gdk.Pixbuf (Assembly.GetExecutingAssembly (), "Resources.flag-" + flag_name + ".png");
                m_flags [flag] = pixbuf;
            }

            return m_flags [flag];
        }
コード例 #9
0
        /// <summary>
        /// <see cref="TaskFlag.Prioritized"/> or <see cref="TaskFlag.NonPrioritized"/> is
        /// a must. Based on which the user may add additional constraints such as
        /// whether the task is scheduled or not, or if the task is urgent or not.
        /// </summary>
        /// <param name="flag"></param>
        /// <returns></returns>
        public List <ITask> SelectTasks(TaskFlag flag)
        {
            var from = new List <ITask>();

            if ((flag & TaskFlag.Prioritized) == TaskFlag.Prioritized)
            {
                if (CurrentTaskIsPrioritized)
                {
                    from.Add(CurrentTask);
                }
                from.AddRange(priorityList.PeekAll());
            }
            if ((flag & TaskFlag.NonPrioritized) == TaskFlag.NonPrioritized)
            {
                if (!CurrentTaskIsPrioritized)
                {
                    from.Add(CurrentTask);
                }
                from.AddRange(taskStack.PeekAll());
            }

            List <Func <ITask, bool> > selectFunc = new List <Func <ITask, bool> >();

            if ((flag & TaskFlag.Scheduled) == TaskFlag.Scheduled)
            {
                selectFunc.Add(task => task is ZScheduledTask);
            }
            if ((flag & TaskFlag.NonScheduled) == TaskFlag.NonScheduled)
            {
                selectFunc.Add(task => !(task is ZScheduledTask));
            }

            if ((flag & TaskFlag.Urgent) == TaskFlag.Urgent)
            {
                selectFunc.Add(task =>
                {
                    var scheduled = task as ZScheduledTask;
                    return(scheduled != null && scheduled.IsUrgent());
                });
            }
            if ((flag & TaskFlag.Danger) == TaskFlag.Danger)
            {
                selectFunc.Add(task =>
                {
                    var scheduled = task as ZScheduledTask;
                    return(scheduled != null && scheduled.IsInDanger());
                });
            }

            if (selectFunc.Any())
            {
                return(from.Where(task =>
                {
                    foreach (Func <ITask, bool> func in selectFunc)
                    {
                        if (!func(task))
                        {
                            return false;
                        }
                    }
                    return true;
                }).ToList());
            }
            else
            {
                return(from);
            }
        }