Beispiel #1
0
        public static List <UserTaskViewModel> CreateUserTaskVM(int count)
        {
            var  userTaskVMList = new List <UserTaskViewModel>();
            bool haveGoal       = false;
            var  intervals      = Enum.GetValues(typeof(GoalFrequency))
                                  .Cast <GoalFrequency>()
                                  .Select(v => v.ToString())
                                  .ToList();
            var random = new Random();

            for (int i = 1; i <= count; i++)
            {
                haveGoal = !haveGoal;
                int GoalPomodoroCount     = 0;
                int frequncyIndex         = random.Next(0, intervals.Count - 1);
                int FinishedPomodoroCount = random.Next(0, 5 * (frequncyIndex + 3));
                if (haveGoal)
                {
                    GoalPomodoroCount = random.Next(5 * (frequncyIndex + 1), 5 * (frequncyIndex + 3));
                }

                var a = new UserTaskViewModel()
                {
                    FinishedPomodoroCount = FinishedPomodoroCount,
                    GoalPomodoroCount     = GoalPomodoroCount,
                    HaveGoal      = haveGoal,
                    GoalInterval  = intervals[frequncyIndex],
                    IsGaolAchived = FinishedPomodoroCount >= GoalPomodoroCount,
                    TaskName      = "Task" + i,
                    TaskColor     = ColorPickService.NextRandom(),
                };



                userTaskVMList.Add(a);
            }
            return(userTaskVMList);
        }
Beispiel #2
0
        public NewTaskPageViewModel()
        {
            Id = Guid.NewGuid();

            Colors = new ObservableCollection <string>
            {
                "#0D47A1",
                "#1F77B4",
                "#AEC7E8",
                "#DD2C00",
                "#FF7F0E",
                "#FFBB78",
                "#1B5E20",
                "#2CA02C",
                "#98DF8A",
                "#C51162",
                "#D50000",
                "#D62728",
                "#FF9896",
                "#4A148C",
                "#9467BD",
                "#C5B0D5",
                "#8C564B",
                "#C49C94",
                "#3E2723",
                "#795548",
                "#E377C2",
                "#F7B6D2",
                "#7F7F7F",
                "#AEEA00",
                "#BCBD22",
                "#DBDB8D",
                "#17BECF",
                "#9EDAE5",
                "#78909C",
            };

            Title         = "New Task";
            Frequencies   = new ObservableCollection <string>(Enum.GetNames(typeof(GoalFrequency)).ToList());
            GoalFrequency = Frequencies.ElementAt(0);
            TaskColor     = ColorPickService.NextRandom();
            SaveCommand   = new Command(
                execute: async(o) =>
            {
                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;

                var userTask = CreateUserTask();
                if (userTask != null)
                {
                    MessagingCenter.Send(this, AppMessages.SaveUserTaskMessage, userTask);
                    await Page.Navigation.PopModalAsync();
                }
                IsBusy = false;
            }
                );
        }