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 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); }
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++; } }