コード例 #1
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++;
            }
        }
コード例 #2
0
ファイル: XamlContentLayer.cs プロジェクト: zyhong/UI-For-UWP
        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();
        }
コード例 #3
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++;
            }
        }
コード例 #4
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)
                {
                    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++;
            }
        }