Exemplo n.º 1
0
        public NewTaskPageViewModel()
        {
            Id = Guid.NewGuid();

            Title         = "New Task";
            Frequencies   = new ObservableCollection <string>(Enum.GetNames(typeof(GoalFrequency)).ToList());
            GoalFrequency = Frequencies.ElementAt(0);
            TaskColor     = ColorPickService.GetRandom();
            Colors        = new ObservableCollection <string>(ColorPickService.Colors);
            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;
            }
                );
        }
Exemplo n.º 2
0
        public static UserTask CreateUserTask()
        {
            var  userTaskVMList = new List <UserTaskViewModel>();
            bool haveGoal       = false;
            var  intervals      = Enum.GetValues(typeof(GoalFrequency))
                                  .Cast <GoalFrequency>()
                                  .Select(v => v.ToString())
                                  .ToList();


            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));
            }

            UserTask userTask = new UserTask()
            {
                Id            = Guid.NewGuid(),
                TaskName      = "Task" + ++createdTaskCount,
                TaskColor     = ColorPickService.GetRandom(),
                TaskStatistic = new FinishedTaskStatistic()
                {
                    DailyFinishedCount   = FinishedPomodoroCount,
                    MonthlyFinishedCount = FinishedPomodoroCount,
                    WeeklyFinishedCount  = FinishedPomodoroCount,
                    YearlyFinishedCount  = FinishedPomodoroCount,
                },
                TaskGoal = new TaskGoal()
                {
                    GoalInterval  = (GoalFrequency)frequncyIndex,
                    PomodoroCount = GoalPomodoroCount,
                },
            };

            return(userTask);
        }
Exemplo n.º 3
0
        private void DrawDonutChart(List <TaskStatistic> statistics)
        {
            var entries = new List <Microcharts.ChartEntry>();

            Dictionary <Guid, (int count, string name)> taskDictionary = new Dictionary <Guid, (int count, string name)>();

            foreach (var statistic in statistics)
            {
                if (!taskDictionary.ContainsKey(statistic.TaskId))
                {
                    taskDictionary[statistic.TaskId] = (count : 1, name : statistic.TaskName);
                }
                else
                {
                    taskDictionary[statistic.TaskId] = (count : taskDictionary[statistic.TaskId].count + 1, name : taskDictionary[statistic.TaskId].name);
                }
            }

            foreach (var item in taskDictionary)
            {
                var entry = new Microcharts.ChartEntry(item.Value.count)
                {
                    Label      = item.Value.name,
                    ValueLabel = item.Value.count.ToString(),
                    Color      = SKColor.Parse(ColorPickService.GetRandom()),
                };
                entries.Add(entry);
            }

            TaskDonutChart = new Microcharts.DonutChart()
            {
                IsAnimated        = true,
                AnimationDuration = TimeSpan.FromMilliseconds(300),
                LabelTextSize     = 25,
                Entries           = entries,
                BackgroundColor   = SkiaSharp.SKColors.Transparent,
                Margin            = 10,
            };
        }
Exemplo n.º 4
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.GetRandom(),
                };



                userTaskVMList.Add(a);
            }
            return(userTaskVMList);
        }