private void ArrangeAllDayAppointment(RadRect viewRect) { AppointmentSource appointmentSource = this.Calendar.appointmentSource; if (this.allDayAppointmentInfos == null) { this.allDayAppointmentInfos = new List <CalendarAppointmentInfo>(); } else { this.allDayAppointmentInfos.Clear(); } if (appointmentSource != null) { MultiDayViewSettings settings = this.Calendar.multiDayViewSettings; double appoitmentHeight = settings.AllDayAppointmentMinHeight; foreach (var cell in this.CalendarCells) { LinkedList <IAppointment> appointments = appointmentSource.GetAppointments((IAppointment appointment) => { return(cell.Date.Date >= appointment.StartDate.Date && cell.Date.Date <= appointment.EndDate.Date && appointment.IsAllDay); }); if (appointments.Count > this.allDayAreaRowCount) { this.allDayAreaRowCount = appointments.Count; } var sorterAppointments = appointments.OrderByDescending(a => a.EndDate.Ticks - a.StartDate.Ticks).ToList(); var containedInfos = this.allDayAppointmentInfos.Where(a => sorterAppointments.Contains(a.childAppointment)); double prevBottom = cell.layoutSlot.Y - this.dayViewLayoutSlot.Y; foreach (var appointment in sorterAppointments) { while (true) { int widthCoeff; int xCoeff; DateTime startAppointmentDate = appointment.StartDate; if (this.Calendar.multiDayViewSettings.WeekendsVisible) { widthCoeff = (appointment.EndDate - startAppointmentDate).Days; xCoeff = (cell.Date - startAppointmentDate.Date).Days; } else { widthCoeff = CalendarMathHelper.GetBusinessDaysCount(startAppointmentDate, appointment.EndDate); startAppointmentDate = CalendarMathHelper.SetFirstAvailableBusinessDay(startAppointmentDate, 1); xCoeff = CalendarMathHelper.GetBusinessDaysCount(startAppointmentDate.Date, cell.Date); } RadRect layoutSlot = new RadRect(cell.layoutSlot.X - (xCoeff * this.cellWidth), prevBottom, this.cellWidth + (this.cellWidth * widthCoeff) - this.Calendar.GridLinesThickness / 2, appoitmentHeight); if (containedInfos.FirstOrDefault(a => a.layoutSlot.IntersectsWith(layoutSlot)) == null) { CalendarAppointmentInfo containedInfo = containedInfos.FirstOrDefault(a => a.childAppointment == appointment); if (containedInfo != null) { break; } CalendarAppointmentInfo info = new CalendarAppointmentInfo(); info.Date = cell.Date; info.Appointments = appointments; info.columnIndex = cell.ColumnIndex; info.Brush = appointment.Color; info.cell = cell; info.childAppointment = appointment; info.DetailText = appointment.Description; info.Subject = appointment.Subject; info.IsAllDay = appointment.IsAllDay; info.layoutSlot = layoutSlot; this.allDayAppointmentInfos.Add(info); prevBottom = layoutSlot.Bottom + settings.AllDayAppointmentSpacing; break; } prevBottom = layoutSlot.Bottom + settings.AllDayAppointmentSpacing; } } } int maxVisibleRows = settings.AllDayMaxVisibleRows; this.totalAllDayAreaHeight = this.allDayAreaRowCount > maxVisibleRows ? maxVisibleRows * appoitmentHeight + maxVisibleRows * settings.AllDayAppointmentSpacing + appoitmentHeight / 2 : this.allDayAreaRowCount * appoitmentHeight + this.allDayAreaRowCount * settings.AllDayAppointmentSpacing; if (this.allDayAreaRowCount == 0) { this.totalAllDayAreaHeight = 0; } } }
internal void ArrangeAppointments() { AppointmentSource appointmentSource = this.Calendar.appointmentSource; if (this.appointmentInfos == null) { this.appointmentInfos = new List <CalendarAppointmentInfo>(); } else { this.appointmentInfos.Clear(); } if (appointmentSource != null) { MultiDayViewSettings settings = this.Calendar.multiDayViewSettings; foreach (var calendarCell in this.CalendarCells) { LinkedList <IAppointment> appointmentsPerCell = appointmentSource.GetAppointments((IAppointment appointment) => { return(calendarCell.Date.Date >= appointment.StartDate.Date && calendarCell.Date.Date <= appointment.EndDate.Date && !(appointment.IsAllDay && settings.ShowAllDayArea)); }); var orderedAppointments = new LinkedList <IAppointment>(appointmentsPerCell.OrderBy(a => a.StartDate)); foreach (var appointment in orderedAppointments) { if ((appointment.StartDate.Date == calendarCell.Date.Date && appointment.StartDate.TimeOfDay > settings.DayEndTime) || (appointment.EndDate.Date == calendarCell.Date.Date && appointment.EndDate.TimeOfDay < settings.DayStartTime)) { continue; } double startY = this.DateToVerticalPosition(calendarCell.Date.Date, appointment.StartDate); DateTime endDate = appointment.EndDate.TimeOfDay > settings.DayEndTime ? appointment.EndDate.Add(TimeSpan.FromTicks(settings.DayEndTime.Ticks - appointment.EndDate.TimeOfDay.Ticks)) : appointment.EndDate; double endY = this.DateToVerticalPosition(calendarCell.Date.Date, endDate); if (startY < endY) { CalendarAppointmentInfo info = new CalendarAppointmentInfo(); info.Date = calendarCell.Date; info.Appointments = orderedAppointments; info.columnIndex = calendarCell.ColumnIndex; info.Brush = appointment.Color; info.cell = calendarCell; info.childAppointment = appointment; info.DetailText = appointment.Description; info.Subject = appointment.Subject; info.IsAllDay = appointment.IsAllDay; DateTime currentAppointmentStartDate = appointment.StartDate; DateTime currentAppointmentEndDate = appointment.EndDate; if (!this.Calendar.multiDayViewSettings.WeekendsVisible) { currentAppointmentStartDate = CalendarMathHelper.SetFirstAvailableBusinessDay(currentAppointmentStartDate, 1); currentAppointmentEndDate = CalendarMathHelper.SetFirstAvailableBusinessDay(currentAppointmentEndDate, -1); } info.hasPreviousDay = currentAppointmentStartDate.Date < calendarCell.Date; info.hasNextDay = currentAppointmentEndDate.Date > calendarCell.Date; int xCoeff = (calendarCell.Date - appointment.StartDate.Date).Days; RadRect layoutSlot = new RadRect(calendarCell.layoutSlot.X - this.timeRulerWidth, startY, calendarCell.layoutSlot.Width, endY - startY); info.layoutSlot = layoutSlot; this.appointmentInfos.Add(info); } } } this.ArrangeIntersectedAppointments(); } }