public MainWindow() { months = new List <string> { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; user = new TutoringDB.CurrentUser(); readUser = new TutoringDB.TutorDatabaseEntities(); readUser.CurrentUsers.Load(); var userList = from i in readUser.CurrentUsers select i; user = userList.FirstOrDefault(); InitializeComponent(); finished = true; monthLabel.Content = months.FirstOrDefault(w => w == DateTime.Today.ToString("MMMM")); selectedMonth = DateTime.Today.Month; currYear = DateTime.Today.Year; calendarMonth = (MonthCounter)DateTime.Today.Month; nextButton.Click += (o, e) => refreshCalendar(1); prevButton.Click += (o, e) => refreshCalendar(2); Notifications = new ObservableCollection <Notification>(); NotificationCommand = new RelayCommand <object>(onNotificationClicked); //readUser.TutorTuteeNotifications.Load(); //var nots = from i in readUser.TutorTuteeNotifications // where i.Tutee.Username == user.UserName || i.Tutor.UserName == user.UserName // select i; //foreach (var not in nots) Notifications.Add(new Notification(not.Message, not.Type, (int)not.targetId)); //if (Notifications.Count == 0) //{ // Notifications.Add(new Notification("Nothing here!", "empty", -1)); //} //else Notifications.Add(new Notification("Clear", "clear", -1)); //NotificationsList.ItemsSource = Notifications; refreshNotifications(); DataContext = this; }
private void refreshCalendar(int x) { switch (x) { case 1: selectedMonth = (((selectedMonth - 1) + 1) % 12) + 1; if (selectedMonth == 0) { currYear += 1; selectedMonth++; } calendarMonth = (MonthCounter)selectedMonth; break; case 2: if (selectedMonth != 1) { selectedMonth = (((selectedMonth - 1) - 1) % 12) + 1; } //Handle the going back a year crashing else { selectedMonth = 12; currYear -= 1; } calendarMonth = (MonthCounter)selectedMonth; break; default: break; } DateTime targetDate = new DateTime(currYear, selectedMonth, 1); //monthLabel.Content = months.FirstOrDefault(w => w == DateTime.Today.Month.ToString("MMMM")); monthLabel.Content = calendarMonth.ToString(); calendar.BuildCalendar(targetDate); }