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; } }
protected override Style SelectStyleCore(object item, DependencyObject container) { if (item is IGroupHeader) { return(_gridView.GroupHeaderContainerStyle); } else if (item is IGroupFooter) { return(_gridView.GroupFooterContainerStyle); } else { StyleSelector itemSelector = _gridView.ItemContainerStyleSelector; if (itemSelector != null) { return(itemSelector.SelectStyle(item, container)); } else if (_gridView.ItemContainerStyle != null) { return(_gridView.ItemContainerStyle); } return(base.SelectStyleCore(item, container)); } }
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++; } }
/// <summary> /// Applies the style to the specified container element. /// </summary> /// <param name="container">The container element to apply the style to.</param> /// <param name="item">The data object associated with the <paramref name="container"/>.</param> /// <param name="style">The <see cref="Style"/> to apply to the container element.</param> /// <param name="styleSelector">The <see cref="StyleSelector"/> object that returns a <see cref="Style"/>.</param> private static void ApplyStyle(DependencyObject container, object item, Style style, StyleSelector styleSelector) { if (container.ReadLocalValue(FrameworkElement.StyleProperty) == container.ReadLocalValue(StyleProperty)) { if (style == null && styleSelector != null) { style = styleSelector.SelectStyle(item, container); } if (style != null) { VerifyStyle(style.TargetType, container.GetType()); container.SetValue(FrameworkElement.StyleProperty, style); container.SetValue(StyleProperty, style); return; } container.ClearValue(FrameworkElement.StyleProperty); } }
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++; } }