/// <summary> /// Show the time slots in the DataGrid /// </summary> /// <param name="date"></param> public void ShowTimeSlotInDataGrid(DateTime date) { _log.Notice("Inside ShowTimeSlotInDataGrid"); TimeSlotRowInDataGrid.Clear(); //CurrentDateSelected = date; DayQuota dailyQuota = monthlyQuota[date]; Dictionary <string, float> tsQuotas = dailyQuota.TimeSlotQuota; List <TimeSlotCell[]> listTimeSlots = new List <TimeSlotCell[]>(); TimeSlotCell[] listTimeSlot = new TimeSlotCell[4]; int i = 0; foreach (KeyValuePair <string, float> tsQuota in tsQuotas.OrderBy(key => key.Key)) { string quotaColor; if (tsQuota.Value <= RedQuotaCutoff) { quotaColor = "Red"; } else if (tsQuota.Value >= GreenQuotaCutoff) { quotaColor = "Green"; } else { quotaColor = "Yellow"; } TimeSlotCell cell = new TimeSlotCell(tsQuota.Key, quotaColor); listTimeSlot[i] = cell; if (i == 3) { listTimeSlots.Add(listTimeSlot); listTimeSlot = new TimeSlotCell[4]; i = 0; } else { i++; } } if (listTimeSlot.Length > 0) { listTimeSlots.Add(listTimeSlot); } foreach (TimeSlotCell[] superList in listTimeSlots) { TimeSlotRow timeSlotRow = new TimeSlotRow(superList[0], superList[1], superList[2], superList[3]); if (superList[0] != null) { TimeSlotRowInDataGrid.Add(timeSlotRow); } } }
/// <summary> /// Handle selection of TimeSlot from DataGrid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TimeSlotDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) { //_log.Info("Inside TimeSlotDataGrid_MouseDoubleClick"); TimeSlotRow row = (TimeSlotRow)TimeSlotDataGrid.CurrentItem; TextBlock timeSlot = (TextBlock)TimeSlotDataGrid.CurrentColumn.GetCellContent(row); var monthlyViewSchedulerViewModel = (MonthlyViewSchedulerViewModel)DataContext; DayQuota dayQuota = monthlyViewSchedulerViewModel.MonthlyQuota[monthlyViewSchedulerViewModel.CurrentDateSelected]; if (dayQuota != null) { float timeSlotQuota = dayQuota.TimeSlotQuota[timeSlot.Text]; if (timeSlotQuota > monthlyViewSchedulerViewModel.RedQuotaCutoff || monthlyViewSchedulerViewModel.IsManagerOverride) { updateRecordFields(timeSlot.Text, monthlyViewSchedulerViewModel.CurrentDateSelected); } } }
/// <summary> /// Show the time slots in the DataGrid /// </summary> /// <param name="date"></param> public void ShowTimeSlotInDataGrid(DateTime date) { _log.Notice("Inside ShowTimeSlotInDataGrid"); TimeSlotRowInDataGrid.Clear(); //CurrentDateSelected = date; DayQuota dailyQuota = monthlyQuota[date]; Dictionary<string, float> tsQuotas = dailyQuota.TimeSlotQuota; List<TimeSlotCell[]> listTimeSlots = new List<TimeSlotCell[]>(); TimeSlotCell[] listTimeSlot = new TimeSlotCell[4]; int i = 0; foreach (KeyValuePair<string, float> tsQuota in tsQuotas.OrderBy(key => key.Key)) { string quotaColor; if (tsQuota.Value <= RedQuotaCutoff) { quotaColor = "Red"; } else if (tsQuota.Value >= GreenQuotaCutoff) { quotaColor = "Green"; } else { quotaColor = "Yellow"; } TimeSlotCell cell = new TimeSlotCell(tsQuota.Key, quotaColor); listTimeSlot[i] = cell; if (i == 3) { listTimeSlots.Add(listTimeSlot); listTimeSlot = new TimeSlotCell[4]; i = 0; } else { i++; } } if (listTimeSlot.Length > 0) { listTimeSlots.Add(listTimeSlot); } foreach (TimeSlotCell[] superList in listTimeSlots) { TimeSlotRow timeSlotRow = new TimeSlotRow(superList[0], superList[1], superList[2], superList[3]); if (superList[0] != null) { TimeSlotRowInDataGrid.Add(timeSlotRow); } } }