Esempio n. 1
0
        internal RadSize MeasureContent(object content)
        {
            this.EnsureMeasurementPresenter();
            this.measurementPresenter.Text = content.ToString();

            return(XamlContentLayerHelper.MeasureVisual(this.measurementPresenter));
        }
        internal RadSize MeasureContent(object owner, object content)
        {
            this.EnsureMeasurementPresenter();

            if (owner is CalendarHeaderCellType)
            {
                CalendarHeaderCellType headerType = (CalendarHeaderCellType)owner;


#if NETFX_CORE
                var localPresenter = this.measurementPresenter;
#else
                // UNO TODO
                var localPresenter = this.measurementPresenter.Child as TextBlock;
#endif

                if (headerType == CalendarHeaderCellType.DayName)
                {
                    if (this.Owner.DayNameCellStyleSelector != null)
                    {
                        localPresenter.Style = this.Owner.DayNameCellStyleSelector.SelectStyle(new CalendarCellStyleContext()
                        {
                            Label = content.ToString()
                        }, this.Owner);
                    }
                    else
                    {
                        localPresenter.Style = this.Owner.DayNameCellStyle.ContentStyle;
                    }
                }
                else
                {
                    if (this.Owner.WeekNumberCellStyleSelector != null)
                    {
                        localPresenter.Style = this.Owner.WeekNumberCellStyleSelector.SelectStyle(new CalendarCellStyleContext()
                        {
                            Label = content.ToString()
                        }, this.Owner);
                    }
                    else
                    {
                        localPresenter.Style = this.Owner.WeekNumberCellStyle.ContentStyle;
                    }
                }

                localPresenter.Text = content.ToString();

                return(XamlContentLayerHelper.MeasureVisual(this.measurementPresenter));
            }

            return(RadSize.Empty);
        }
        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++;
            }
        }
Esempio n. 4
0
        internal RadSize MeasureContent(object owner, object content)
        {
            this.EnsureMeasurementPresenter();

            if (owner is CalendarHeaderCellType)
            {
                CalendarHeaderCellType headerType = (CalendarHeaderCellType)owner;
                if (headerType == CalendarHeaderCellType.DayName)
                {
                    if (this.Owner.DayNameCellStyleSelector != null)
                    {
                        this.measurementPresenter.Style = this.Owner.DayNameCellStyleSelector.SelectStyle(new CalendarCellStyleContext()
                        {
                            Label = content.ToString()
                        }, this.Owner);
                    }
                    else
                    {
                        this.measurementPresenter.Style = this.Owner.DayNameCellStyle != null
                            ? this.Owner.DayNameCellStyle.ContentStyle
                            : this.Owner.defaultDayNameCellStyle.ContentStyle;
                    }
                }
                else
                {
                    if (this.Owner.WeekNumberCellStyleSelector != null)
                    {
                        this.measurementPresenter.Style = this.Owner.WeekNumberCellStyleSelector.SelectStyle(new CalendarCellStyleContext()
                        {
                            Label = content.ToString()
                        }, this.Owner);
                    }
                    else
                    {
                        this.measurementPresenter.Style = this.Owner.WeekNumberCellStyle.ContentStyle;
                    }
                }

                this.measurementPresenter.Text = content.ToString();

                return(XamlContentLayerHelper.MeasureVisual(this.measurementPresenter));
            }

            return(RadSize.Empty);
        }
Esempio n. 5
0
        private FrameworkElement GetDefaultVisual(CalendarCellModel cell)
        {
            TextBlock visual;

            if (this.recycledContainers.Count > 0)
            {
                visual = this.recycledContainers.Dequeue();
                visual.ClearValue(TextBlock.VisibilityProperty);
                this.realizedCalendarCellDefaultPresenters.Add(cell, visual);
            }
            else
            {
                visual = this.CreateDefaultVisual();
                this.realizedCalendarCellDefaultPresenters.Add(cell, visual);
            }

            XamlContentLayerHelper.PrepareDefaultVisual(visual, cell);

            return(visual);
        }
Esempio n. 6
0
        private FrameworkElement GetDefaultVisual(CalendarNode cell, int virtualIndex)
        {
            TextBlock visual;

            if (virtualIndex < this.realizedCalendarCellDefaultPresenters.Count)
            {
                visual = this.realizedCalendarCellDefaultPresenters[virtualIndex];

                visual.ClearValue(TextBlock.VisibilityProperty);
                visual.ClearValue(TextBlock.StyleProperty);
            }
            else
            {
                visual = this.CreateDefaultVisual();
            }

            XamlContentLayerHelper.PrepareDefaultVisual(visual, cell);

            return(visual);
        }
        private FrameworkElement GetDefaultVisual(CalendarNode cell, int virtualIndex)
        {
#if NETFX_CORE
            TextBlock visual;

            if (virtualIndex < this.realizedCalendarCellDefaultPresenters.Count)
            {
                visual = this.realizedCalendarCellDefaultPresenters[virtualIndex];

                visual.ClearValue(TextBlock.VisibilityProperty);
                visual.ClearValue(TextBlock.StyleProperty);
            }
            else
            {
                visual = this.CreateDefaultVisual();
            }

            XamlContentLayerHelper.PrepareDefaultVisual(visual, cell);

            return(visual);
#else
            // TODO UNO
            DefaultPresenter visual;

            if (virtualIndex < this.realizedCalendarCellDefaultPresenters.Count)
            {
                visual = this.realizedCalendarCellDefaultPresenters[virtualIndex];

                visual.ClearValue(Border.VisibilityProperty);
                (visual.Child as TextBlock).ClearValue(TextBlock.StyleProperty);
            }
            else
            {
                visual = this.CreateDefaultVisual();
            }

            XamlContentLayerHelper.PrepareDefaultVisualUno(visual, cell);

            return(visual);
#endif
        }
Esempio n. 8
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();
        }
Esempio n. 9
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++;
            }
        }
        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++;
            }
        }