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