internal void LoadCalendarView() { calendar.Items.Clear(); List <Slot> filteredSlots = getFilteredSlots(); List <Slot> slotsOnView = new List <Slot>(); // Add filtered slots to items foreach (Slot slot in filteredSlots) { CalendarItem ci = getCalendarItemFromSlot(slot); if (ci.IsOnViewDateRange) { calendar.Items.Add(ci); slot.IsOnView = true; slotsOnView.Add(slot); } } // IsOnView = false if the slot is not on the view foreach (Slot slot in CurrentPeriod.ListSlots) { if (!slotsOnView.Any(s => s == slot)) { slot.IsOnView = false; } } foreach (CalendarItem ci in calendar.Items) { if (ci.StartDate.Hour > 10 && calendar.Items.Count(c => c.Date.DayOfYear == ci.Date.DayOfYear) < 2) { Rectangle r = new Rectangle(new Point(ci.Bounds.X, ci.Bounds.Y + ((calendar.Days[0].BodyBounds.Height - (calendar.Days[0].HeaderBounds.Height * 2)) / 2)), ci.Bounds.Size); ci.SetBounds(r); } } }