void populateRightPane() { DateTime now = DateTime.Now; future.Children.Clear(); //populate the right pane with button for the next 6 days and highlite //any that have appointments for (int i = 1; i < 7; i++) { DateTime t1 = now.AddDays(i); mybutton dayevent = new mybutton(); dayevent.Date = t1; dayevent.Content = t1.DayOfWeek.ToString() + " " + t1.Day.ToString(); dayevent.Click += dayevent_Click; List <DataAccessLayer.Models.Appointment> thisday = allAppts.Where(a => a.StartTime.ToShortDateString() == t1.ToShortDateString()).ToList(); if (thisday.Count() > 0) { dayevent.Foreground = new SolidColorBrush(Colors.Red); } future.Children.Add(dayevent); } if (superuser) { mybutton dayevent = new mybutton(); dayevent.Content = "Date Picker"; dayevent.Click += ShowCalendar_Click;; future.Children.Add(dayevent); } }
private void ShowCalendar_Click(object sender, RoutedEventArgs e) { System.Windows.Controls.Calendar MonthlyCalendar = new System.Windows.Controls.Calendar(); // MonthlyCalendar.CalendarStyle = Microsoft.Windows.Controls.CalendarMode.Month; // MonthlyCalendar.SelectionMode = CalendarSelectionMode.SingleRange; MonthlyCalendar.IsTodayHighlighted = true; MonthlyCalendar.SelectedDatesChanged += MonthlyCalendar_SelectedDatesChanged; // MonthlyCalendar.DisplayDateStart = DateTime.Now; mybutton dayevent = future.Children[future.Children.Count - 1] as mybutton; dayevent.Visibility = Visibility.Collapsed; future.Children.Add(MonthlyCalendar); }
//the user has clicked on a day in the right grid. open a day scheuduler //for the selected day and show appointments if there are any except if in edit mode //then we show all appts for the selected day in left side so the user can delete events private void dayevent_Click(object sender, RoutedEventArgs e) { selectedDayButton = sender as mybutton; DateTime thisDate = (DateTime)(sender as mybutton).Date; cal.Appointments = allAppts; //set control appointments to all as it will filter //currentdate is a dependency property on the calendar that will cause filtering by CurrentDate cal.CurrentDate = thisDate; if (!editMode) { cal.Visibility = Visibility.Visible; future.Visibility = Visibility.Collapsed; } else { List <DataAccessLayer.Models.Appointment> temp = allAppts.Where(a => a.StartTime.ToShortDateString() == thisDate.ToShortDateString()).ToList(); today = new ObservableCollection <DataAccessLayer.Models.Appointment>(temp); lvDataBinding.ItemsSource = today; head.Text = thisDate.DayOfWeek.ToString() + " " + thisDate.Day.ToString(); } }