Example #1
0
        private void UpdateAllDayAppointments(List <CalendarAppointmentInfo> allDayAppointmentInfos)
        {
            int         index    = 0;
            RadCalendar calendar = this.Owner;

            foreach (var appInfo in allDayAppointmentInfos)
            {
                if (!this.allDayClipArea.IntersectsWith(appInfo.layoutSlot))
                {
                    continue;
                }

                AppointmentControl appointmentControl = this.GetDefaultAllDayAppointmentVisual(index);
                if (appointmentControl != null)
                {
                    RadRect layoutSlot = appInfo.layoutSlot;
                    appointmentControl.Header = appInfo.Subject;
                    if (appInfo.Brush != null)
                    {
                        appointmentControl.Background = appInfo.Brush;
                    }

                    appointmentControl.appointmentInfo = appInfo;

                    StyleSelector styleSelector = calendar.AppointmentStyleSelector;
                    if (styleSelector != null)
                    {
                        var style = styleSelector.SelectStyle(appInfo, appointmentControl);
                        if (style != null)
                        {
                            appointmentControl.Style = style;
                        }
                    }
                    else if (appointmentControl.Style != null)
                    {
                        appointmentControl.ClearValue(AppointmentControl.StyleProperty);
                    }

                    AppointmentTemplateSelector headerTemplateSelector = calendar.AppointmentHeaderTemplateSelector;
                    if (headerTemplateSelector != null)
                    {
                        DataTemplate template = headerTemplateSelector.SelectTemplate(appInfo, appInfo.cell);
                        if (template != null)
                        {
                            appointmentControl.HeaderTemplate = template;
                        }
                    }

                    XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true);
                    index++;
                }
            }

            while (index < this.realizedAllDayAppointmentDefaultPresenters.Count)
            {
                this.realizedAllDayAppointmentDefaultPresenters[index].Visibility = Visibility.Collapsed;
                index++;
            }
        }
        internal void UpdateAppointments(List <CalendarAppointmentInfo> appointmentInfos)
        {
            int         index    = 0;
            RadCalendar calendar = this.Owner;

            foreach (var appointmentInfo in appointmentInfos)
            {
                if (!this.bufferedViewPortArea.IntersectsWith(appointmentInfo.layoutSlot))
                {
                    continue;
                }

                AppointmentControl appointmentControl = this.GetDefaultAppointmentVisual(index);
                if (appointmentControl != null)
                {
                    RadRect layoutSlot = appointmentInfo.layoutSlot;
                    layoutSlot.Width             -= 3;
                    appointmentControl.Content    = appointmentInfo.DetailText;
                    appointmentControl.Header     = appointmentInfo.Subject;
                    appointmentControl.Background = appointmentInfo.Brush;

                    if (appointmentInfo.hasPrevDay)
                    {
                        appointmentControl.LeftIndicatorVisibility = Visibility.Visible;
                    }

                    if (appointmentInfo.hasNextDay)
                    {
                        appointmentControl.RightIndicatorVisibility = Visibility.Visible;
                    }

                    appointmentControl.appointmentInfo = appointmentInfo;

                    StyleSelector contentStyleSelector = calendar.AppointmentStyleSelector;
                    if (contentStyleSelector != null)
                    {
                        var style = contentStyleSelector.SelectStyle(appointmentInfo, appointmentControl);
                        if (style != null)
                        {
                            appointmentControl.Style = style;
                        }
                    }
                    else if (appointmentControl.Style != null)
                    {
                        appointmentControl.ClearValue(AppointmentControl.StyleProperty);
                    }

                    AppointmentTemplateSelector templateSelector = calendar.AppointmentTemplateSelector;
                    if (templateSelector != null)
                    {
                        DataTemplate template = templateSelector.SelectTemplate(appointmentInfo, appointmentInfo.cell);
                        if (template != null)
                        {
                            appointmentControl.ContentTemplate = template;
                        }
                    }

                    AppointmentTemplateSelector headerTemplateSelector = calendar.AppointmentHeaderTemplateSelector;
                    if (headerTemplateSelector != null)
                    {
                        DataTemplate template = headerTemplateSelector.SelectTemplate(appointmentInfo, appointmentInfo.cell);
                        if (template != null)
                        {
                            appointmentControl.HeaderTemplate = template;
                        }
                    }

                    XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true);
                    Canvas.SetZIndex(appointmentControl, XamlMultiDayViewLayer.DefaultAppointmentZIndex);
                    Canvas.SetLeft(appointmentControl, layoutSlot.X - this.leftOffset + this.leftHeaderPanel.Width);
                    index++;
                }
            }

            while (index < this.realizedAppointmentDefaultPresenters.Count)
            {
                this.realizedAppointmentDefaultPresenters[index].Visibility = Visibility.Collapsed;
                index++;
            }
        }