Esempio n. 1
0
 public AllHabitsTrackerViewModel(HabitsTrackerLogic habitsTrackerLogic)
 {
     this.habitsTrackerLogic = habitsTrackerLogic;
     workOfDay  = new Day();
     Condition  = "Visible";
     day        = Convert.ToInt32(DateTime.Now.ToString("dd"));
     month      = Convert.ToInt32(DateTime.Now.ToString("MM"));
     year       = Convert.ToInt32(DateTime.Now.ToString("yyyy"));
     WeekHabits = new ObservableCollection <WeekHabit>();
     WeekHabit.ListDays.Clear();
     WeekHabit.SetWeek(DateTime.Now.ToString("dd"), DateTime.Now.ToString("MM"), year);
     DayMonth = WeekHabit.Week;
     Completion();
     MondayCheck    = new RelayCommand <string>(MonCheck);
     TuesdayCheck   = new RelayCommand <string>(TueCheck);
     WednesdayCheck = new RelayCommand <string>(WedCheck);
     ThursdayCheck  = new RelayCommand <string>(ThuCheck);
     FridayCheck    = new RelayCommand <string>(FriCheck);
     SaturdayCheck  = new RelayCommand <string>(SatCheck);
     SundayCheck    = new RelayCommand <string>(SunCheck);
     IsVisible      = false;
     nowWeek        = DayMonth;
     dispatcher     = Dispatcher.CurrentDispatcher;
 }
Esempio n. 2
0
        public ObservableCollection <WeekHabit> GetWeekHabits(List <string> dates)
        {
            CheckMonths(dates);
            ObservableCollection <WeekHabit> weekHabits = new ObservableCollection <WeekHabit>();

            foreach (var habitTracker in habitsTracker)
            {
                if (IsCreateInThePast(habitTracker, dates) && IsDeleteInTheFuture(habitTracker, dates))
                {
                    WeekHabit weekHabit = new WeekHabit();
                    weekHabit.Habit = habitTracker.Habit;
                    for (int i = 0; i < habitTracker.Dates.Count; i++)
                    {
                        for (int j = 0; j < dates.Count; j++)
                        {
                            if (habitTracker.Dates[i].Year == Convert.ToInt32(dates[j].Split(new char[] { '.' })[2]) &&
                                habitTracker.Dates[i].MonthsCheckList[Convert.ToInt32(dates[j].Split(new char[] { '.' })[1]) - 1].Count != 0)
                            {
                                foreach (var day in habitTracker.Dates[i].MonthsCheckList[Convert.ToInt32(dates[j].Split(new char[] { '.' })[1]) - 1])
                                {
                                    if (day == Convert.ToInt32(dates[j].Split(new char[] { '.' })[0]))
                                    {
                                        switch (j)
                                        {
                                        case 0:
                                            weekHabit.IsDoneOnMonday = true;
                                            break;

                                        case 1:
                                            weekHabit.IsDoneOnTuesday = true;
                                            break;

                                        case 2:
                                            weekHabit.IsDoneOnWednesday = true;
                                            break;

                                        case 3:
                                            weekHabit.IsDoneOnThursday = true;
                                            break;

                                        case 4:
                                            weekHabit.IsDoneOnFriday = true;
                                            break;

                                        case 5:
                                            weekHabit.IsDoneOnSaturday = true;
                                            break;

                                        case 6:
                                            weekHabit.IsDoneOnSunday = true;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    weekHabits.Add(weekHabit);
                }
            }
            return(weekHabits);
        }