private void AddCourseToDisplay(Course course) { // Generate random color byte r = (byte)rnd.Next(64, 192 + 1); byte g = (byte)rnd.Next(64, 192 + 1); byte b = (byte)rnd.Next(64, 192 + 1); Color courseColor = Color.FromRgb(r, g, b); // Not used because that's not distinct enough // Show relavent time slots List <TimeSlot> termSlots = course.TimeSlots.Where(item => item.Availability == _TermName).ToList(); // Section info string currentSectionName = termSlots.Count > 0 ? termSlots[0].SectionNameText : string.Empty; Color currentSectionColor = Color.FromRgb((byte)rnd.Next(64, 192 + 1), (byte)rnd.Next(64, 192 + 1), (byte)rnd.Next(64, 192 + 1)); foreach (TimeSlot slot in termSlots) { // Section compare info string sectionNameCompare = slot.SectionNameText; if (sectionNameCompare != currentSectionName) { currentSectionColor = Color.FromRgb((byte)rnd.Next(64, 192 + 1), (byte)rnd.Next(64, 192 + 1), (byte)rnd.Next(64, 192 + 1)); currentSectionName = sectionNameCompare; } // Generate Slot CourseSlot newSlot = new CourseSlot(course, slot, currentSectionColor, this); newSlot.SetValue(Grid.RowProperty, slot.StartTime - 8); newSlot.SetValue(Grid.ColumnProperty, (int)slot.Day - 1); newSlot.SetValue(Grid.RowSpanProperty, slot.TimeSpan); TimetableGrid.Children.Add(newSlot); } }
internal void ShowOnlyCurrentSlot(Course course, TimeSlot slot) { foreach (UIElement element in TimetableGrid.Children) { CourseSlot courseSlot = element as CourseSlot; if (courseSlot != null && courseSlot.Course == course && (courseSlot.Slot.Type == slot.Type && courseSlot.Slot.SectionCode == slot.SectionCode)) { courseSlot.Visibility = Visibility.Visible; } else { courseSlot.Visibility = Visibility.Collapsed; } } }