Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
0
        private void UpdateTimeRulerItems(ElementCollection <CalendarTimeRulerItem> timeRulerItems)
        {
            this.RecycleTimeRulerItems(timeRulerItems);
            foreach (var item in timeRulerItems)
            {
                if (!this.viewPortArea.IntersectsWith(item.layoutSlot))
                {
                    continue;
                }

                FrameworkElement element = this.GetDefaultTimeRulerItemVisual(item);
                if (element != null)
                {
                    this.ApplyTimeRulerStyle(item, element);
                    RadRect layoutSlot = item.layoutSlot;

                    XamlContentLayer.ArrangeUIElement(element, layoutSlot, true);
                }
            }

            foreach (TextBlock item in this.recycledTimeRulerItems)
            {
                item.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 3
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++;
            }
        }
Exemplo n.º 4
0
        private void UpdateAllDayAppointments(List <CalendarAppointmentInfo> allDayAppointmentInfos)
        {
            if (allDayAppointmentInfos == null)
            {
                return;
            }

            foreach (var appointmentInfo in allDayAppointmentInfos)
            {
                AppointmentControl appControl;
                if (this.realizedAppointmentPresenters.TryGetValue(appointmentInfo, out appControl))
                {
                    this.visibleAppointmentPresenters.Add(appointmentInfo, appControl);
                }
            }

            RadCalendar calendar = this.Owner;

            foreach (var appInfo in allDayAppointmentInfos)
            {
                AppointmentControl appointmentControl;
                this.visibleAppointmentPresenters.TryGetValue(appInfo, out appointmentControl);

                if (!this.allDayClipArea.IntersectsWith(appInfo.layoutSlot))
                {
                    if (appointmentControl != null)
                    {
                        this.RecycleAppointmentVisual(appInfo, appointmentControl);
                    }

                    continue;
                }

                if (appointmentControl != null)
                {
                    RadRect layoutSlot = appInfo.layoutSlot;
                    XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true);
                    continue;
                }

                appointmentControl = this.GetDefaultAllDayAppointmentVisual(appInfo);
                if (appointmentControl != null)
                {
                    appointmentControl.appointmentInfo = appInfo;
                    calendar.PrepareContainerForAppointment(appointmentControl, appInfo);

                    RadRect layoutSlot = appInfo.layoutSlot;
                    XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true);
                }
            }

            this.RecycleAppointments(this.recycledAppointments);
            this.recycledAppointments.Clear();
            this.visibleAppointmentPresenters.Clear();
        }
Exemplo n.º 5
0
        internal void UpdateUI(IEnumerable <CalendarCellModel> cellsToUpdate = null)
        {
            if (this.Owner.AppointmentSource == null)
            {
                return;
            }
            if (cellsToUpdate == null)
            {
                cellsToUpdate = this.Owner.Model.CalendarCells;
            }

            int         index    = 0;
            RadCalendar calendar = this.Owner;

            foreach (CalendarCellModel cell in cellsToUpdate)
            {
                CalendarAppointmentInfo info = new CalendarAppointmentInfo();
                info.Date         = cell.Date;
                info.Appointments = this.Owner.AppointmentSource.GetAppointments((IAppointment appointment) =>
                {
                    return(cell.Date.Date >= appointment.StartDate.Date && cell.Date.Date <= appointment.EndDate.Date);
                });

                if (info.Appointments.Count > 0)
                {
                    foreach (var appointment in info.Appointments)
                    {
                        info.Subject += (info.Subject != null ? Environment.NewLine : string.Empty) + appointment.Subject;
                    }

                    var element = this.GetDefaultVisual(index);
                    element.Clip = new RectangleGeometry()
                    {
                        Rect = new Rect(0, 0, cell.LayoutSlot.Width, cell.LayoutSlot.Height)
                    };
                    element.appointmentInfo = info;
                    calendar.PrepareContainerForAppointment(element, info);

                    RadRect layoutSlot = cell.layoutSlot;
                    layoutSlot = XamlContentLayerHelper.ApplyLayoutSlotAlignment(element, layoutSlot);
                    XamlContentLayer.ArrangeUIElement(element, layoutSlot, false);
                    index++;
                }
            }

            while (index < this.realizedCalendarCellDefaultPresenters.Count)
            {
                this.realizedCalendarCellDefaultPresenters[index].Visibility = Visibility.Collapsed;
                index++;
            }
        }
Exemplo n.º 6
0
        internal void UpdateUI(IEnumerable <CalendarCellModel> cellsToUpdate = null)
        {
            if (cellsToUpdate == null)
            {
                cellsToUpdate = this.Owner.Model.CalendarCells;
            }

            this.ClearTemplatedVisuals(cellsToUpdate);
            this.RecycleDefaultVisuals(cellsToUpdate);

            foreach (CalendarCellModel cell in cellsToUpdate)
            {
                FrameworkElement element = this.GetCalendarCellVisual(cell);

                if (element != null)
                {
                    RadRect layoutSlot = cell.layoutSlot;

                    // Tag is set only for default visuals
                    if (element.Tag is CalendarCellModel)
                    {
                        layoutSlot = XamlContentLayerHelper.ApplyLayoutSlotAlignment(element, layoutSlot);
                        XamlContentLayer.ArrangeUIElement(element, layoutSlot, false);
                    }
                    else
                    {
                        XamlContentLayer.ArrangeUIElement(element, layoutSlot);
                    }
                }
            }

            foreach (FrameworkElement visual in this.recycledContainers)
            {
                visual.Visibility = Visibility.Collapsed;
            }

            this.UpdateCalendarViewClip();
        }
Exemplo n.º 7
0
        private void UpdateTimerRulerLines(ElementCollection <CalendarGridLine> timeRulerLines)
        {
            this.RecycleTimeRulerLines(timeRulerLines);
            foreach (var gridLine in timeRulerLines)
            {
                if (!this.viewPortArea.IntersectsWith(gridLine.layoutSlot))
                {
                    continue;
                }

                Border border = this.GetTimerRulerLine(gridLine);
                if (border != null)
                {
                    this.ApplyTimeRulerStyle(gridLine, border);

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

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

                    RadRect layoutSlot = gridLine.layoutSlot;
                    XamlContentLayer.ArrangeUIElement(border, layoutSlot, true);
                    Canvas.SetLeft(border, -this.leftOffset);
                    Canvas.SetZIndex(border, XamlMultiDayViewLayer.DefaultLineZIndex);
                }
            }

            foreach (var recycledLine in this.recycledTimeRulerLines)
            {
                recycledLine.Visibility = Visibility.Collapsed;
            }
        }
Exemplo n.º 8
0
        internal void UpdateUI()
        {
            if (this.Owner.Model.CalendarHeaderCells == null)
            {
                this.VisualElement.Visibility = Visibility.Collapsed;
                return;
            }

            this.VisualElement.ClearValue(FrameworkElement.VisibilityProperty);

            int index = 0;

            foreach (CalendarHeaderCellModel cell in this.Owner.Model.CalendarHeaderCells)
            {
                if (!cell.layoutSlot.IsSizeValid())
                {
                    continue;
                }

                FrameworkElement element = this.GetDefaultVisual(cell, index);

                if (element != null)
                {
                    RadRect layoutSlot = cell.layoutSlot;
                    layoutSlot = XamlContentLayerHelper.ApplyLayoutSlotAlignment(element, layoutSlot);
                    XamlContentLayer.ArrangeUIElement(element, layoutSlot, false);

                    index++;
                }
            }

            while (index < this.realizedCalendarCellDefaultPresenters.Count)
            {
                this.realizedCalendarCellDefaultPresenters[index].Visibility = Visibility.Collapsed;
                index++;
            }
        }
Exemplo n.º 9
0
        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++;
            }
        }
        internal void UpdateUI(IEnumerable <CalendarCellModel> cellsToUpdate = null)
        {
            if (this.Owner.AppointmentSource == null)
            {
                return;
            }
            if (cellsToUpdate == null)
            {
                cellsToUpdate = this.Owner.Model.CalendarCells;
            }

            int         index    = 0;
            RadCalendar calendar = this.Owner;

            foreach (CalendarCellModel cell in cellsToUpdate)
            {
                CalendarAppointmentInfo info = new CalendarAppointmentInfo();
                info.Date         = cell.Date;
                info.Appointments = this.Owner.AppointmentSource.GetAppointments((IAppointment appointment) =>
                {
                    return(cell.Date.Date >= appointment.StartDate.Date && cell.Date.Date <= appointment.EndDate.Date);
                });

                if (info.Appointments.Count > 0)
                {
                    AppointmentControl element = new AppointmentControl();

                    foreach (var appointment in info.Appointments)
                    {
                        info.Subject += (info.Subject != null ? Environment.NewLine : string.Empty) + appointment.Subject;
                    }

                    element      = this.GetDefaultVisual(index);
                    element.Clip = new RectangleGeometry()
                    {
                        Rect = new Rect(0, 0, cell.LayoutSlot.Width, cell.LayoutSlot.Height)
                    };
                    element.Header          = info.Subject;
                    element.Background      = info.Brush;
                    element.appointmentInfo = info;

                    XamlContentLayerHelper.MeasureVisual(element);
                    if (element != null)
                    {
                        StyleSelector styleSelector = calendar.AppointmentStyleSelector;
                        if (styleSelector != null)
                        {
                            var style = styleSelector.SelectStyle(info, element);
                            if (style != null)
                            {
                                element.Style = style;
                            }
                        }

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

                        RadRect layoutSlot = cell.layoutSlot;
                        layoutSlot = XamlContentLayerHelper.ApplyLayoutSlotAlignment(element, layoutSlot);
                        XamlContentLayer.ArrangeUIElement(element, layoutSlot, false);

                        index++;
                    }
                }
            }

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