private void EnsureTimeRulerItems()
        {
            if (this.timeRulerItems == null)
            {
                this.timeRulerItems = new ElementCollection <CalendarTimeRulerItem>(this);
            }

            if (this.timeRulerItems.Count == 0)
            {
                MultiDayViewSettings settings = this.Calendar.multiDayViewSettings;

                long   dayViewAreaTicks = settings.DayEndTime.Ticks - settings.DayStartTime.Ticks;
                double numberOfItems    = Math.Ceiling((double)dayViewAreaTicks / (double)settings.TimerRulerTickLength.Ticks);
                for (int i = 0; i < numberOfItems; i++)
                {
                    CalendarTimeRulerItem timeRulerItem = new CalendarTimeRulerItem();
                    this.timeRulerItems.Add(timeRulerItem);
                }
            }
            else
            {
                foreach (CalendarTimeRulerItem timeRulerItem in this.timeRulerItems)
                {
                    timeRulerItem.layoutSlot = RadRect.Empty;
                }
            }
        }
Example #2
0
        private void LayoutLowerAllDayAreaHorizontalBorder(CalendarGridLine horizontalAllDayLowerLine)
        {
            MultiDayViewSettings settings = this.Owner.MultiDayViewSettings;
            Style allDayAreaBorderStyle   = settings.AllDayAreaBorderStyle ?? settings.defaultAllDayAreaBorderStyle;

            if (allDayAreaBorderStyle != null)
            {
                this.horizontalLowerGridLineBorder.Style = allDayAreaBorderStyle;
            }

            if (!XamlDecorationLayer.IsStrokeBrushExplicitlySet(this.horizontalLowerGridLineBorder.Style))
            {
                this.horizontalLowerGridLineBorder.BorderBrush = this.Owner.GridLinesBrush;
            }

            if (this.horizontalLowerGridLineBorder.BorderBrush != null && !XamlDecorationLayer.IsStrokeThicknessExplicitlySet(this.horizontalLowerGridLineBorder.Style))
            {
                this.horizontalLowerGridLineBorder.BorderThickness = new Thickness(this.Owner.GridLinesThickness);
            }

            RadRect layoutSlot = horizontalAllDayLowerLine.layoutSlot;

            layoutSlot.Height = this.horizontalLowerGridLineBorder.BorderThickness.Left;
            XamlMultiDayViewLayer.ArrangeUIElement(this.horizontalLowerGridLineBorder, layoutSlot, true);
        }
        private void EnsureTodaySlot()
        {
            MultiDayViewSettings settings = this.Calendar.multiDayViewSettings;
            DateTime             today    = DateTime.Now.Date;

            if (this.todaySlot == null)
            {
                this.todaySlot       = new Slot();
                this.todaySlot.Start = today.AddTicks(settings.DayStartTime.Ticks);
                this.todaySlot.End   = today.AddTicks(settings.DayEndTime.Ticks);
            }

            double   startY  = this.DateToVerticalPosition(today, this.todaySlot.Start);
            DateTime endDate = this.todaySlot.End.TimeOfDay > settings.DayEndTime
                ? endDate = this.todaySlot.End.Add(TimeSpan.FromTicks(settings.DayEndTime.Ticks - this.todaySlot.End.TimeOfDay.Ticks))
                : endDate = this.todaySlot.End;

            double            endY      = this.DateToVerticalPosition(today, endDate);
            CalendarCellModel todayCell = this.CalendarCells.FirstOrDefault(a => a.Date == today);

            if (todayCell != null && startY < endY)
            {
                RadRect layoutSlot = new RadRect(todayCell.layoutSlot.X - this.timeRulerWidth, startY, todayCell.layoutSlot.Width, endY - startY);
                this.todaySlot.layoutSlot = layoutSlot;
            }
            else if (todayCell == null)
            {
                this.todaySlot.layoutSlot = RadRect.Empty;
            }
        }
Example #4
0
        internal void UpdateTimeRulerAllDayText(RadRect allDayLabelLayout)
        {
            if (allDayLabelLayout != RadRect.Empty)
            {
                if (this.allDayTextBlock == null)
                {
                    this.allDayTextBlock = new TextBlock();
                    this.topLeftHeaderPanel.Children.Add(this.allDayTextBlock);
                }

                MultiDayViewSettings settings = this.Owner.MultiDayViewSettings;
                Style allDayAreaTextStyle     = settings.AllDayAreaTextStyle ?? settings.defaultAllDayAreaTextStyle;
                if (allDayAreaTextStyle != null)
                {
                    this.allDayTextBlock.Style = allDayAreaTextStyle;
                }

                if (this.allDayTextBlock.Text != null && !this.IsTextExplicitlySet(this.allDayTextBlock.Style))
                {
                    this.allDayTextBlock.Text = settings.AllDayAreaText;
                }

                if (this.allDayTextBlock.Visibility == Visibility.Collapsed)
                {
                    this.allDayTextBlock.Visibility = Visibility.Visible;
                }

                XamlMultiDayViewLayer.ArrangeUIElement(this.allDayTextBlock, allDayLabelLayout, true);
            }
            else if (this.allDayTextBlock != null && this.allDayTextBlock.Visibility == Visibility.Visible)
            {
                this.allDayTextBlock.Visibility = Visibility.Collapsed;
            }
        }
Example #5
0
        internal void UpdateSlots(IEnumerable <Slot> slots)
        {
            this.RecycleSlots(slots);
            foreach (var slot in slots)
            {
                if (!this.bufferedViewPortArea.IntersectsWith(slot.layoutSlot))
                {
                    continue;
                }

                Border slotVisual = this.GetDefaultSlotVisual(slot);
                if (slotVisual != null)
                {
                    MultiDayViewSettings settings = this.Owner.MultiDayViewSettings;
                    StyleSelector        specialSlotStyleSelector = settings.SpecialSlotStyleSelector ?? settings.defaultSpecialSlotStyleSelector;
                    if (specialSlotStyleSelector != null)
                    {
                        var style = specialSlotStyleSelector.SelectStyle(slot, slotVisual);
                        if (style != null)
                        {
                            slotVisual.Style = style;
                        }
                    }

                    XamlContentLayer.ArrangeUIElement(slotVisual, slot.layoutSlot, true);
                    Canvas.SetZIndex(slotVisual, XamlMultiDayViewLayer.DefaultSlotZIndex);
                    Canvas.SetLeft(slotVisual, slot.layoutSlot.X - this.leftOffset + this.leftHeaderPanel.Width);
                }
            }

            foreach (Border slot in this.recycledSlots)
            {
                slot.Visibility = Visibility.Collapsed;
            }
        }
        private void EnsureSlots()
        {
            if (this.specialSlots == null)
            {
                this.specialSlots = new List <KeyValuePair <Slot, Slot> >();
            }
            else
            {
                foreach (var slot in this.specialSlots)
                {
                    slot.Value.layoutSlot = RadRect.Empty;
                }
            }

            MultiDayViewSettings settings = this.Calendar.multiDayViewSettings;
            IEnumerable <Slot>   slots    = settings.SpecialSlotsSource;

            if (slots != null && slots.Count() > 0)
            {
                foreach (var calendarCell in this.CalendarCells)
                {
                    var slotsPerCell = slots.Where(a => calendarCell.Date.Date >= a.Start.Date && calendarCell.Date.Date <= a.End.Date);
                    foreach (var slot in slotsPerCell)
                    {
                        if ((slot.Start.Date == calendarCell.Date.Date && slot.Start.TimeOfDay > settings.DayEndTime) ||
                            (slot.End.Date == calendarCell.Date.Date && slot.End.TimeOfDay < settings.DayStartTime))
                        {
                            continue;
                        }

                        double   startY  = this.DateToVerticalPosition(calendarCell.Date.Date, slot.Start);
                        DateTime endDate = slot.End.TimeOfDay > settings.DayEndTime
                            ? endDate = slot.End.Add(TimeSpan.FromTicks(settings.DayEndTime.Ticks - slot.End.TimeOfDay.Ticks))
                            : endDate = slot.End;

                        double endY = this.DateToVerticalPosition(calendarCell.Date.Date, endDate);
                        if (startY < endY)
                        {
                            RadRect layoutSlot = new RadRect(calendarCell.layoutSlot.X - this.timeRulerWidth, startY, calendarCell.layoutSlot.Width, endY - startY);

                            var specialSlot = this.specialSlots.FirstOrDefault(a => a.Key == slot && a.Value.layoutSlot == RadRect.Empty);
                            if (specialSlot.Value != null)
                            {
                                specialSlot.Value.layoutSlot = layoutSlot;
                            }
                            else
                            {
                                slot.layoutSlot = layoutSlot;
                                this.specialSlots.Add(new KeyValuePair <Slot, Slot>(slot, slot.Copy()));
                            }
                        }
                    }
                }
            }
        }
        private void ApplyTimeRulerStyle(object item, FrameworkElement container)
        {
            MultiDayViewSettings settings = this.Owner.MultiDayViewSettings;
            CalendarTimeRulerItemStyleSelector itemStyleSelector = settings.TimeRulerItemStyleSelector ?? settings.defaultTimeRulerItemStyleSelector;

            if (itemStyleSelector != null)
            {
                var style = itemStyleSelector.SelectStyle(item, container);
                if (style != null)
                {
                    container.Style = style;
                }
            }
        }
        private void ArrangeTimerRuler(RadRect viewRect)
        {
            CalendarModel        model       = this.Calendar;
            MultiDayViewSettings settings    = model.multiDayViewSettings;
            DateTime             currentDate = model.DisplayDate.Date;

            double   timeWidth     = this.dayViewLayoutSlot.X - viewRect.X;
            TimeSpan timeSlotTime  = settings.DayStartTime;
            string   textToMeasure = string.Format(this.Calendar.Culture, this.Calendar.TimeFormat, currentDate.Add(timeSlotTime));
            RadSize  timeTextSize  = model.View.MeasureContent(null, textToMeasure);

            this.halfTextHeight = timeTextSize.Height / 2;

            double previousBottom = viewRect.Y - this.halfTextHeight;

            string labelText = string.Empty;
            double heightCoeff;
            double timeItemHeight;
            double oneHourTicks = (double)TimeSpan.FromHours(1).Ticks;

            var itemsCount = this.timeRulerItems.Count;

            for (int hourIndex = 0; hourIndex < itemsCount; hourIndex++)
            {
                CalendarTimeRulerItem timerRulerItem = this.timeRulerItems[hourIndex];
                timerRulerItem.StartTime = timeSlotTime;
                timerRulerItem.Label     = labelText;

                timeSlotTime = timeSlotTime.Add(TimeSpan.FromTicks(settings.TimerRulerTickLength.Ticks));
                if (timeSlotTime > settings.DayEndTime)
                {
                    timeSlotTime = settings.DayEndTime;
                }

                timerRulerItem.EndTime = timeSlotTime;

                heightCoeff    = (timerRulerItem.EndTime - timerRulerItem.StartTime).Ticks / oneHourTicks;
                timeItemHeight = settings.TimeLinesSpacing * heightCoeff;
                if (hourIndex == itemsCount - 1)
                {
                    timeItemHeight += this.halfTextHeight - this.Calendar.GridLinesThickness;
                }

                timerRulerItem.Arrange(new RadRect(0f, previousBottom, timeWidth, timeItemHeight));

                previousBottom = timerRulerItem.layoutSlot.Bottom;
                labelText      = string.Format(this.Calendar.Culture, this.Calendar.TimeFormat, currentDate.Add(timeSlotTime));
            }
        }
Example #9
0
        private void PrepareDecorationVisual(Border visual, CalendarNode node, CalendarDecorationType decorationType)
        {
            visual.Tag = node;

            if (decorationType == CalendarDecorationType.GridLine)
            {
                RadCalendar calendar = this.Owner;
                if (calendar.DisplayMode == CalendarDisplayMode.MultiDayView)
                {
                    MultiDayViewSettings settings = calendar.MultiDayViewSettings;
                    CalendarTimeRulerItemStyleSelector styleSelector = settings.TimeRulerItemStyleSelector ?? settings.defaultTimeRulerItemStyleSelector;
                    if (styleSelector != null)
                    {
                        Style style = styleSelector.SelectStyle(node, visual);
                        if (style != null)
                        {
                            visual.Style = style;

                            if (!XamlDecorationLayer.IsStrokeBrushExplicitlySet(visual.Style))
                            {
                                visual.BorderBrush = this.Owner.GridLinesBrush;
                            }

                            if (visual.BorderBrush != null && !XamlDecorationLayer.IsStrokeThicknessExplicitlySet(visual.Style))
                            {
                                visual.BorderThickness = new Thickness(this.Owner.GridLinesThickness);
                            }
                        }
                        else
                        {
                            visual.BorderBrush     = this.Owner.GridLinesBrush;
                            visual.BorderThickness = new Thickness(this.Owner.GridLinesThickness);
                        }
                    }
                }
                else
                {
                    visual.BorderBrush     = this.Owner.GridLinesBrush;
                    visual.BorderThickness = new Thickness(this.Owner.GridLinesThickness);
                }
            }
            else
            {
                this.ApplyStyleToCellDecorationVisual(visual, node);
            }
        }
Example #10
0
        private RadRect GetCalendarViewRect(RadRect availableRect)
        {
            double        dayNamesPanelHeight = 0d;
            CalendarModel calendar            = this.Calendar;

            if (calendar.AreDayNamesVisible)
            {
                dayNamesPanelHeight = calendar.View.MeasureContent(CalendarHeaderCellType.DayName, calendar.Culture.DateTimeFormat.AbbreviatedDayNames[0]).Height;
            }

            double panelWidth = 0d;

            if (calendar.DisplayMode == CalendarDisplayMode.MonthView && calendar.AreWeekNumbersVisible)
            {
                string stringToMeasure = string.Format(calendar.Culture, calendar.WeekNumberFormat, WeekNumberMeasureString);
                panelWidth = calendar.View.MeasureContent(CalendarHeaderCellType.WeekNumber, stringToMeasure).Width;
            }
            else if (calendar.DisplayMode == CalendarDisplayMode.MultiDayView)
            {
                MultiDayViewSettings settings = this.Calendar.multiDayViewSettings;
                TimeSpan             endTime  = settings.DayEndTime;
                string stringToMeasure        = string.Format(this.Calendar.Culture, this.Calendar.TimeFormat, calendar.DisplayDate.Date.Add(endTime));
                panelWidth = calendar.View.MeasureContent(null, stringToMeasure).Width;

                if (!string.IsNullOrEmpty(settings.AllDayAreaText))
                {
                    stringToMeasure = MultiDayViewSettings.DefaultAllDayText;
                    double allDayWidth = calendar.View.MeasureContent(null, stringToMeasure).Width;
                    if (allDayWidth > panelWidth)
                    {
                        panelWidth = allDayWidth;
                    }
                }
            }

            double width  = Math.Max(availableRect.Width - panelWidth, 0d);
            double height = Math.Max(availableRect.Height - dayNamesPanelHeight, 0d);

            return(new RadRect(panelWidth, dayNamesPanelHeight, width, height));
        }
Example #11
0
        internal void UpdateCurrentTimeIndicator()
        {
            CalendarModel    model = this.Owner.Model;
            CalendarGridLine currentTimeIndicator = model.CurrentTimeIndicator;

            if (currentTimeIndicator != null)
            {
                if (this.viewPortArea.IntersectsWith(currentTimeIndicator.layoutSlot) && currentTimeIndicator.layoutSlot.IsSizeValid())
                {
                    if (this.currentTimeIndicatorBorder == null)
                    {
                        this.currentTimeIndicatorBorder = new Border();
                        this.AddVisualChild(this.currentTimeIndicatorBorder);
                        Canvas.SetZIndex(this.currentTimeIndicatorBorder, XamlMultiDayViewLayer.DefaultCurrentTimeIndicatorZIndex);
                    }
                    else if (this.currentTimeIndicatorBorder.Visibility == Visibility.Collapsed)
                    {
                        this.currentTimeIndicatorBorder.Visibility = Visibility.Visible;
                        Canvas.SetZIndex(this.currentTimeIndicatorBorder, XamlMultiDayViewLayer.DefaultCurrentTimeIndicatorZIndex);
                    }

                    MultiDayViewSettings settings   = model.multiDayViewSettings;
                    Style currentTimeIndicatorStyle = settings.CurrentTimeIndicatorStyle ?? settings.defaultCurrentTimeIndicatorStyle;
                    if (currentTimeIndicatorStyle != null)
                    {
                        this.currentTimeIndicatorBorder.Style = currentTimeIndicatorStyle;
                    }

                    Canvas.SetLeft(this.currentTimeIndicatorBorder, -this.leftOffset);
                    Canvas.SetTop(this.currentTimeIndicatorBorder, currentTimeIndicator.layoutSlot.Y);
                    this.currentTimeIndicatorBorder.Width = currentTimeIndicator.layoutSlot.Width;
                }
                else if (this.currentTimeIndicatorBorder?.Visibility == Visibility.Visible)
                {
                    this.currentTimeIndicatorBorder.Visibility = Visibility.Collapsed;
                    this.currentTimeIndicatorBorder.ClearValue(Canvas.ZIndexProperty);
                    this.currentTimeIndicatorBorder.ClearValue(Border.StyleProperty);
                }
            }
        }
        private void ArrangeCurrentTimeIndicator(RadRect viewRect)
        {
            if (this.currentTimeIndicator == null)
            {
                this.currentTimeIndicator = new CalendarGridLine();
                this.currentTimeIndicator.IsHorizontal = true;
                this.currentTimeIndicator.root         = this.root;
            }

            MultiDayViewSettings settings    = this.Calendar.multiDayViewSettings;
            DateTime             currentDate = DateTime.Now;

            if (currentDate.TimeOfDay >= settings.DayStartTime && currentDate.TimeOfDay <= settings.DayEndTime)
            {
                double verticalPosition = this.DateToVerticalPosition(currentDate, currentDate);
                this.currentTimeIndicator.Arrange(new RadRect(this.layoutSlot.X, verticalPosition, viewRect.Width, CalendarMultiDayViewModel.DefaultCurrentTimeIndicatorHeight));
            }
            else
            {
                this.currentTimeIndicator.layoutSlot = RadRect.Empty;
            }
        }
        private void EnsureSlots()
        {
            MultiDayViewSettings settings = this.Calendar.multiDayViewSettings;
            IEnumerable <Slot>   slots    = settings.SpecialSlotsSource;

            if (slots != null && slots.Count() > 0)
            {
                foreach (Slot slot in slots)
                {
                    slot.layoutSlot = RadRect.Empty;
                }

                foreach (var calendarCell in this.CalendarCells)
                {
                    var slotsPerCell = slots.Where(a => calendarCell.Date.Date >= a.Start.Date && calendarCell.Date.Date <= a.End.Date);
                    foreach (var slot in slotsPerCell)
                    {
                        if ((slot.Start.Date == calendarCell.Date.Date && slot.Start.TimeOfDay > settings.DayEndTime) ||
                            (slot.End.Date == calendarCell.Date.Date && slot.End.TimeOfDay < settings.DayStartTime))
                        {
                            continue;
                        }

                        double   startY  = this.DateToVerticalPosition(calendarCell.Date.Date, slot.Start);
                        DateTime endDate = slot.End.TimeOfDay > settings.DayEndTime
                            ? endDate = slot.End.Add(TimeSpan.FromTicks(settings.DayEndTime.Ticks - slot.End.TimeOfDay.Ticks))
                            : endDate = slot.End;

                        double endY = this.DateToVerticalPosition(calendarCell.Date.Date, endDate);
                        if (startY < endY)
                        {
                            RadRect layoutSlot = new RadRect(calendarCell.layoutSlot.X - this.timeRulerWidth, startY, calendarCell.layoutSlot.Width, endY - startY);
                            slot.layoutSlot = layoutSlot;
                        }
                    }
                }
            }
        }
        internal void UpdateTodaySlot()
        {
            Slot todaySlot = this.Owner.Model.multiDayViewModel.todaySlot;

            if (this.todaySlotBorder == null)
            {
                this.todaySlotBorder = new Border();
                this.contentPanel.Children.Add(this.todaySlotBorder);
            }
            else
            {
                this.todaySlotBorder.ClearValue(Border.VisibilityProperty);
                this.todaySlotBorder.ClearValue(Border.StyleProperty);
                this.todaySlotBorder.ClearValue(Canvas.ZIndexProperty);
                this.todaySlotBorder.ClearValue(Canvas.LeftProperty);
            }

            if (this.bufferedViewPortArea.IntersectsWith(todaySlot.layoutSlot))
            {
                MultiDayViewSettings settings = this.Owner.MultiDayViewSettings;
                Style todaySlotStyle          = settings.TodaySlotStyle ?? settings.defaulTodaySlotStyle;
                if (todaySlotStyle != null)
                {
                    this.todaySlotBorder.Style = todaySlotStyle;
                }

                RadRect layoutSlot = todaySlot.layoutSlot;
                XamlMultiDayViewLayer.ArrangeUIElement(this.todaySlotBorder, layoutSlot, true);

                Canvas.SetZIndex(this.todaySlotBorder, XamlMultiDayViewLayer.DefaultTodaySlotZIndex);
                Canvas.SetLeft(this.todaySlotBorder, layoutSlot.X - this.leftOffset + this.leftHeaderPanel.Width);
            }
            else if (this.todaySlotBorder.Visibility == Visibility.Visible)
            {
                this.todaySlotBorder.Visibility = Visibility.Collapsed;
            }
        }
        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();
            }
        }