Esempio n. 1
0
        public ICollection <object> GetLightResults(PomodoroContainerType type)
        {
            IEnumerable <PomodoroContainer> enumToGoThrough = null;
            List <object> lst = new List <object>();

            switch (type)
            {
            case PomodoroContainerType.Action:
                enumToGoThrough = ActionResults;
                break;

            case PomodoroContainerType.Task:
                enumToGoThrough = TaskResults;
                break;

            case PomodoroContainerType.Project:
                enumToGoThrough = ProjectResults;
                break;
            }
            foreach (PomodoroContainer result in enumToGoThrough)
            {
                lst.Add(new { ID = result.Ident, Name = result.PathItemName, ContainerType = result.Type });
            }
            return(lst);
        }
Esempio n. 2
0
        public ICollection <string> GetLightStringResults(PomodoroContainerType type)
        {
            IEnumerable <PomodoroContainer> enumToGoThrough = null;
            List <string> lst = new List <string>();

            switch (type)
            {
            case PomodoroContainerType.Action:
                enumToGoThrough = ActionResults;
                break;

            case PomodoroContainerType.Task:
                enumToGoThrough = TaskResults;
                break;

            case PomodoroContainerType.Project:
                enumToGoThrough = ProjectResults;
                break;
            }
            foreach (PomodoroContainer result in enumToGoThrough)
            {
                lst.Add(result.PathItemName);
            }
            return(lst);
        }
Esempio n. 3
0
        public static Color GetIntensityColor(int value, PomodoroContainerType containerType)
        {
            int mult = 0;

            switch (containerType)
            {
            case PomodoroContainerType.Workspace:
                mult = 300;
                break;

            case PomodoroContainerType.Project:
            case PomodoroContainerType.Sprint:
                mult = 400;
                break;

            case PomodoroContainerType.Task:
                mult = 600;
                break;

            case PomodoroContainerType.Action:
                mult = 800;
                break;
            }

            float x = Math.Min(4095, value * mult);
            int   r = Math.Max(0, 200 - (int)(160f * (x / 4095f)));
            int   g = Math.Max(0, 200 - (int)(219f * (x / 4095f)));
            int   b = Math.Max(0, 200 - (int)(19f * (x / 4095f)));

            return(Color.FromArgb(r, g, b));
        }
Esempio n. 4
0
        public ActionResult Autocomplete(PomodoroContainerType itemType, ItemSelectorTarget target /*int? ActionID = null*/)
        {
            SearchResults results    = null;
            SelectList    selectList = null;

            switch (itemType)
            {
            case PomodoroContainerType.Project:
                results    = SearchProjects(String.Empty, null, null);
                selectList = new SelectList(results.GetLightResults(PomodoroContainerType.Project), "ID", "Name");
                break;

            case PomodoroContainerType.Task:
                results    = SearchTasks(String.Empty, null, null);
                selectList = new SelectList(results.GetLightResults(PomodoroContainerType.Task), "ID", "Name");
                break;

            case PomodoroContainerType.Action:
                results    = SearchActions(String.Empty, null, (target != ItemSelectorTarget.Navigate) ? (Status?)Status.Active : null);
                selectList = new SelectList(results.GetLightResults(PomodoroContainerType.Action), "ID", "Name");
                break;
            }
            if (target == ItemSelectorTarget.ChangeParentItem)
            {
                ViewBag.ElementID = "parent";
                ViewBag.parent    = selectList;
            }
            else
            {
                ViewBag.ElementID = "id";
                ViewBag.id        = selectList;
            }

            return(PartialView("Autocomplete", results));
        }
Esempio n. 5
0
        public static ICollection <PomodoroSet> GetPomodoroSets(IEnumerable <Pomodoro> pomodoros,
                                                                PomodoroContainerType containerType = PomodoroContainerType.Action, bool GroupDifferentDates = false)
        {
            List <PomodoroSet> list = new List <PomodoroSet>();

            if (pomodoros.ToList().Count == 0 || containerType == PomodoroContainerType.Unspecified)
            {
                return(list);
            }

            PomodoroSet set           = new PomodoroSet();
            Pomodoro    last          = null;
            bool        sameContainer = false;

            foreach (Pomodoro item in pomodoros.OrderBy(p => p.StartLocal))
            {
                if (last != null)
                {
                    switch (containerType)
                    {
                    case PomodoroContainerType.Project:
                        sameContainer = last.Action.Task.ProjectID == item.Action.Task.ProjectID;
                        break;

                    case PomodoroContainerType.Task:
                        sameContainer = last.Action.TaskID == item.Action.TaskID;
                        break;

                    case PomodoroContainerType.Action:
                        sameContainer = last.ActionID == item.ActionID;
                        break;

                    case PomodoroContainerType.Sprint:
                        sameContainer = last.Action.Task.ProjectID == item.Action.Task.ProjectID;
                        break;

                    case PomodoroContainerType.Workspace:
                        sameContainer = true;
                        break;
                    }
                }
                if (last == null || (sameContainer && last.Status == item.Status) &&
                    (GroupDifferentDates || (last.Start.HasValue && item.Start.HasValue && last.StartLocal.Value.Date == item.StartLocal.Value.Date)))
                {
                    set.Add(item);
                }
                else
                {
                    list.Add(set);
                    set = new PomodoroSet();
                    set.Add(item);
                }
                last = item;
            }
            list.Add(set);
            return(list);
        }
Esempio n. 6
0
        public ActionResult ItemSelector(PomodoroContainerType type, ItemSelectorTarget target,
                                         int?collectedThingID, int?sourceItemID, string defaultItemName)
        {
            string itemDesc = "Pomodoro";

            switch (type)
            {
            case PomodoroContainerType.Project:
                itemDesc = "Task";
                break;

            case PomodoroContainerType.Task:
                itemDesc = "Action";
                break;
            }
            string title = "Please select the ";

            switch (target)
            {
            case ItemSelectorTarget.ChangeParentItem:
                title += "new " + type.ToString() + " for the current " + itemDesc;
                break;

            case ItemSelectorTarget.CreateItemFromCollectedThing:
                title += type.ToString() + " for the new " + itemDesc;
                break;

            case ItemSelectorTarget.SelectActiveAction:
                title += "new active Action to work";
                break;

            case ItemSelectorTarget.Navigate:
                title += "item to view its details";
                break;
            }
            ItemSelectorViewModel viewModel = new ItemSelectorViewModel()
            {
                Target           = target,
                Title            = title,
                ItemType         = type,
                CollectedThingID = collectedThingID,
                SourceItemID     = sourceItemID,
                DefaultItemName  = defaultItemName,
                AvailableWork    = db.GetMyProjects(User)
                                   .Include(p => p.Tasks.Select(t => t.Actions))
            };

            return(PartialView("Panels/ItemSelector/_ItemSelector", viewModel));
        }
Esempio n. 7
0
        public static string GetBoxCssClass(PomodoroContainerType type)
        {
            switch (type)
            {
            case PomodoroContainerType.Project:
                return("box-danger");

            case PomodoroContainerType.Task:
                return("box-primary");

            case PomodoroContainerType.Action:
                return("box-success");
            }
            return(string.Empty);
        }
Esempio n. 8
0
        public ActionResult ItemNavSelector(PomodoroContainerType type, ItemSelectorTarget target,
                                            ItemSelectorType selectorType, int?collectedThingID, int?sourceItemID, string defaultItemName)
        {
            ItemSelectorViewModel viewModel = new ItemSelectorViewModel()
            {
                Target           = target,
                ItemType         = type,
                CollectedThingID = collectedThingID,
                SourceItemID     = sourceItemID,
                SelectorType     = selectorType,
                DefaultItemName  = defaultItemName,
                AvailableWork    = db.GetMyProjects(User)
                                   .Include(p => p.Tasks.Select(t => t.Actions))
            };

            return(PartialView("Panels/ItemSelector/_ItemNavSelector", viewModel));
        }
Esempio n. 9
0
        public static string GetIntensityColorRGB(int value, PomodoroContainerType containerType)
        {
            Color c = GetIntensityColor(value, containerType);

            return(GetColorRGB(c));
        }