/// <summary> /// Hide/Unhide the navigation month option /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MonthlyViewCalendar_DisplayDateChanged(object sender, CalendarDateChangedEventArgs e) { //_log.Info("Inside MonthlyViewCalendar_DisplayDateChanged"); MonthlyViewCalendar calendar = (MonthlyViewCalendar)sender; int monthDiff = Math.Abs((calendar.DisplayDate.Month - DateTime.Today.Month) + 12 * (calendar.DisplayDate.Year - DateTime.Today.Year)); int maxMonthNavigationAllowed = 11; if (TimeSlotDataGrid != null) { TimeSlotDataGrid.Visibility = System.Windows.Visibility.Collapsed; } if (DataContext != null) { var monthlyViewSchedulerViewModel = (MonthlyViewSchedulerViewModel)DataContext; if (monthlyViewSchedulerViewModel != null) { if (calendar.DisplayDate != DateTime.MinValue) { if (calendar.DisplayDate.Month != monthlyViewSchedulerViewModel.CurrentDateSelected.Month) { //User has clicked on the Month Navigation button //Reset the TimeSlot in TimeSlotComboBox to "All Slots" monthlyViewSchedulerViewModel.CurrentTimeSlot = "All Slots"; TimeSlotComboBox.SelectedIndex = 0; if (calendar.DisplayDate <= DateTime.Today) { monthlyViewSchedulerViewModel.CurrentDateSelected = DateTime.Today; } else { monthlyViewSchedulerViewModel.CurrentDateSelected = calendar.DisplayDate; } } else if (isMonthChanging) { monthlyViewSchedulerViewModel.CurrentTimeSlot = "All Slots"; TimeSlotComboBox.SelectedIndex = 0; isMonthChanging = false; } } } } if (monthDiff == 0) { calendar.hidePreviousButton(true); calendar.hideNextButton(false); } else if (monthDiff > maxMonthNavigationAllowed) { calendar.hidePreviousButton(false); calendar.hideNextButton(true); } else { calendar.hidePreviousButton(false); calendar.hideNextButton(false); } }
/// <summary> /// Timeslot selection change /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TimeSlotComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { //_log.Info("Inside TimeSlotComboBox_SelectionChanged"); var monthlyViewSchedulerViewModel = (MonthlyViewSchedulerViewModel)DataContext; string currentTimeSlot = (string)TimeSlotComboBox.SelectedItem; //_log.Info("Current TimeSlot: " + currentTimeSlot); monthlyViewSchedulerViewModel.CurrentTimeSlot = currentTimeSlot; DataContext = monthlyViewSchedulerViewModel; MonthlyViewCalendar.Refresh(); if (!currentTimeSlot.Equals("All Slots")) //if (currentTimeSlot == null || !currentTimeSlot.Equals("All Slots")) { DayQuota dayQuota = monthlyViewSchedulerViewModel.MonthlyQuota[monthlyViewSchedulerViewModel.CurrentDateSelected]; if (dayQuota != null) { float timeSlotQuota = dayQuota.TimeSlotQuota[currentTimeSlot]; if (timeSlotQuota > monthlyViewSchedulerViewModel.RedQuotaCutoff || monthlyViewSchedulerViewModel.IsManagerOverride) { updateRecordFields(currentTimeSlot, monthlyViewSchedulerViewModel.CurrentDateSelected); } } TimeSlotDataGrid.Visibility = System.Windows.Visibility.Collapsed; } else { monthlyViewSchedulerViewModel.ShowTimeSlotInDataGrid(monthlyViewSchedulerViewModel.CurrentDateSelected); TimeSlotDataGrid.Visibility = System.Windows.Visibility.Visible; } }
/// <summary> /// Refresh the scheduler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RefreshScheduler(object sender, RoutedEventArgs e) { //_log.Info("Inside RefreshScheduler"); var monthlyViewSchedulerViewModel = (MonthlyViewSchedulerViewModel)DataContext; monthlyViewSchedulerViewModel.IsRefreshRequested = true; monthlyViewSchedulerViewModel.CurrentTimeSlot = "All Slots"; TimeSlotComboBox.SelectedIndex = 0; DataContext = monthlyViewSchedulerViewModel; MonthlyViewCalendar.Refresh(); }