To reproduce: Appointment a1 = new Appointment(DateTime.Today.AddHours(10).AddMinutes(30), TimeSpan.FromMinutes(30), "A1"); Appointment a2 = new Appointment(DateTime.Today.AddHours(11) , TimeSpan.FromMinutes(30), "A2"); Appointment a3 = new Appointment(DateTime.Today.AddHours(11).AddMinutes(30), TimeSpan.FromMinutes(30), "A3"); this.radScheduler1.Appointments.Add(a1); this.radScheduler1.Appointments.Add(a2); this.radScheduler1.Appointments.Add(a3); this.radScheduler1.ActiveViewType = SchedulerViewType.Timeline; SchedulerTimelineView timelineView = radScheduler1.GetTimelineView(); timelineView.ShowTimescale(Timescales.Minutes); timelineView.GetScaling().DisplayedCellsCount = 10; Please refer to the attached sample project which incorrect behavior when scrolling is illustrated in the attached gif file. Workaround: instead of specifying 30 minutes duration of an appointment, use 29 minutes and 59 seconds.
To reproduce: this.radScheduler1.ActiveViewType = Telerik.WinControls.UI.SchedulerViewType.Timeline; this.radScheduler1.RightToLeft = System.Windows.Forms.RightToLeft.Yes; Please refer to the attached gif file. Select the left border of an appointment and try to resize it to the left. You will notice that you are allowed to resize it to the right and vice versa. Workaround: this.radScheduler1.SchedulerElement.ResizeBehavior = new MyResizingBehavior(this.radScheduler1.SchedulerElement); public class MyResizingBehavior : AppointmentResizingBehavior { RadScheduler scheduler; public MyResizingBehavior(SchedulerVisualElement activeOwner) : base(activeOwner) { scheduler = activeOwner.Scheduler; } protected override bool UpdateMouseCursor(Point mousePosition, Rectangle nearRect, Rectangle farRect) { bool result = base.UpdateMouseCursor(mousePosition, nearRect, farRect); if (scheduler.RightToLeft == RightToLeft.Yes ) { FieldInfo leftFI = typeof(AppointmentResizingBehavior).GetField("leftResize", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo rightFI = typeof(AppointmentResizingBehavior).GetField("rightResize", BindingFlags.NonPublic | BindingFlags.Instance); if (nearRect.Contains(mousePosition) && scheduler.Cursor == Cursors.SizeWE) { leftFI.SetValue(this, false); rightFI.SetValue(this, true); } else if (farRect.Contains(mousePosition) && scheduler.Cursor == Cursors.SizeWE) { leftFI.SetValue(this, true); rightFI.SetValue(this, false); } } return result; } }
Color[] colors = new Color[] { Color.LightBlue, Color.LightGreen, Color.LightYellow, Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue }; string[] names = new string[] { "Alan Smith", "Anne Dodsworth", "Boyan Mastoni", "Richard Duncan", "Maria Shnaider" }; for (int i = 0; i < names.Length; i++) { Resource resource = new Resource(); resource.Id = new EventId(i); resource.Name = names[i]; resource.Color = colors[i]; this.radScheduler1.Resources.Add(resource); } this.radScheduler1.GroupType = GroupType.Resource; this.radScheduler1.ActiveView.ResourcesPerView = 4; this.radScheduler1.ActiveViewType = SchedulerViewType.Timeline; this.radScheduler1.GetTimelineView().GroupSeparatorWidth = 0; By default, the GroupSeparatorWidth property is set to 3. If you need to remove the resources separator, it is necessary to set the GroupSeparatorWidth property to 0 which is not possible at the moment with the public API. Workaround: FieldInfo fi = typeof(SchedulerView).GetField("groupSeparatorWidth", BindingFlags.Instance | BindingFlags.NonPublic); fi.SetValue(this.radScheduler1.GetTimelineView(), 0);
To reproduce: please refer to the attached sample project. Edit some appointment by changing its name or time slot. In the AppointmentChanged event the changes are stored to database. However, if you restart the application you will notice that the changes are not saved at all. Workaround: call the IEditableObject.EndEdit method for the affected record before saving the changes to the database. private void RadScheduler1_AppointmentChanged(object sender, AppointmentChangedEventArgs e) { IEditableObject editableObject = e.Appointment.DataItem as IEditableObject; if (editableObject!=null) { editableObject.EndEdit(); } SaveChanges(); }
To reproduce: please run the attached sample project and have a look at the gif file. Workaround: in the _HideWeekDays method, don't pass 0 width as a parameter in the SetColumnWidth method. Use 0.01 instead.
Run the attached project and add one appointment. Press the "save" button and restart the application. Workaround: private void radButton1_Click(object sender, EventArgs e) { Telerik.WinControls.UI.Appointment a = new Telerik.WinControls.UI.Appointment(DateTime.Now, TimeSpan.FromHours(2)); this.radScheduler1.Appointments.Add(a); this.radScheduler1.Appointments.Remove(a); dbContext.SaveChanges(); }
Workaround: create a derivative of the EditAppointmentDialog. Open the designer and adjust the form's height and button's position. Then replace the default dialog with the custom one: public RadForm1() { InitializeComponent(); this.radScheduler1.AppointmentEditDialogShowing += radScheduler1_AppointmentEditDialogShowing; } CustomEditAppointmentDialog dialog; private void radScheduler1_AppointmentEditDialogShowing(object sender, Telerik.WinControls.UI.AppointmentEditDialogShowingEventArgs e) { if (dialog==null) { dialog = new CustomEditAppointmentDialog(); } e.AppointmentEditDialog = dialog; }
How to reproduce: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.radScheduler1.AppointmentAdded += radScheduler1_AppointmentAdded; Appointment appointment = new Appointment(DateTime.Now, TimeSpan.FromMinutes(60), "Summary", "Description"); appointment.StatusId = 2; appointment.BackgroundId = 6; this.radScheduler1.Appointments.Add(appointment); } private void radScheduler1_AppointmentAdded(object sender, AppointmentAddedEventArgs e) { Console.WriteLine("AppointmentAdded"); } } Workaround: public Form1() { InitializeComponent(); this.radScheduler1.Appointments.CollectionChanged += Appointments_CollectionChanged; Appointment appointment = new Appointment(DateTime.Now, TimeSpan.FromMinutes(60), "Summary", "Description"); appointment.StatusId = 2; appointment.BackgroundId = 6; this.radScheduler1.Appointments.Add(appointment); } private void Appointments_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add) { Console.WriteLine("AppointmentAdded"); } }
To reproduce: Image img1; Image img2; public RadForm1() { InitializeComponent(); new Telerik.WinControls.RadControlSpy.RadControlSpyForm().Show(); img1 = Image.FromFile(@"..\..\delete.png"); img2 = Image.FromFile(@"..\..\111.png"); Color[] colors = new Color[]{Color.LightBlue, Color.LightGreen, Color.LightYellow, .Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue}; string[] names = new string[]{"Alan Smith", "Anne Dodsworth", n Mastoni", "Richard Duncan", "Maria Shnaider"}; for (int i = 0; i < names.Length; i++) { Resource resource = new Resource(); resource.Id = new EventId(i); resource.Name = names[i]; resource.Color = colors[i]; resource.Image = img2; this.radScheduler1.Resources.Add(resource); } this.radScheduler1.ActiveView.ResourcesPerView = 2; this.radScheduler1.GroupType = GroupType.Resource; SchedulerDayViewGroupedByResourceElement dayView = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement; dayView.ResourceHeaderHeight = 120; radScheduler1.AppointmentFormatting += RadScheduler1_AppointmentFormatting; radScheduler1.Appointments.Add(new Appointment(DateTime.Now.AddHours(-7), DateTime.Now.AddHours(-5), "Summary", "Description") { ResourceId = radScheduler1.Resources[0].Id }); } private void RadScheduler1_AppointmentFormatting(object sender, SchedulerAppointmentEventArgs e) { e.AppointmentElement.Image = img1 } - Drag the appointment to the top if needed. - Scroll down. Workaround: private void RadScheduler1_AppointmentFormatting(object sender, SchedulerAppointmentEventArgs e) { if (e.AppointmentElement.Children.Count ==0) { LightVisualElement el = new LightVisualElement(); el.DrawImage = true; el.Image = img1; e.AppointmentElement.Children.Add(el); } }
To reproduce: - Bind the scheduler using SchedulerBindingDataSource and group by resources. - At runtime change the data source of the SchedulerBindingDataSource. - A System.ArgumentException is thrown.
To reproduce: 1. Add a RadScheduler on a form and set the culture: this.radScheduler1.Culture = new System.Globalization.CultureInfo("fa-IR"); 2. In regional settings set the Format to Persian(Iran) as it is illustrated in the attached screenshot. 3. Run the application and try to add an appointment. Open the Recurrence dialog and you will get the exception.
Please refer to the attached sample project and gif file. Workaround: this.radScheduler1.ElementProvider = new CustomSchedulerElementProvider(this.radScheduler1); public class CustomSchedulerElementProvider : SchedulerElementProvider { public CustomSchedulerElementProvider(RadScheduler scheduler) : base(scheduler) { } protected override T CreateElement<T>(SchedulerView view, object context) { if (typeof(T) == typeof(TimelineGroupingByResourcesElement)) { return new CustomTimelineGroupingByResourcesElement(this.Scheduler,view)as T; } return base.CreateElement<T>(view, context); } } public class CustomTimelineGroupingByResourcesElement : TimelineGroupingByResourcesElement { public CustomTimelineGroupingByResourcesElement(RadScheduler scheduler, SchedulerView view) : base(scheduler, view) { } protected override SizeF ArrangeOverride(SizeF finalSize) { RectangleF contentRect = new RectangleF(PointF.Empty, finalSize); int vScrollOffset = this.View.AllowResourcesScrolling ? this.ResourceScrollBarThickness : 0; if (this.VScrollBar != null && this.VScrollBar.Maximum < this.VScrollBar.LargeChange) { vScrollOffset = 0; } IList<SchedulerTimelineViewElement> timelineElements = this.GetChildViewElements(); IList<LightVisualElement> viewSeparators = this.GetViewSeparators(); List<RectangleF> resourcesBounds = new List<RectangleF>(); List<RectangleF> separatorsBounds = new List<RectangleF>(); int scrollBarOffset = 0; if (timelineElements.Count > 0) { if (timelineElements[timelineElements.Count - 1].NavigationElement.Visibility == ElementVisibility.Visible) { scrollBarOffset = 17; } } int headerHeight = 0; if (timelineElements.Count > 0 && timelineElements[0].Header.Visibility != ElementVisibility.Collapsed) { headerHeight = timelineElements[0].ViewHeaderHeight + timelineElements[0].ColumnHeaderHeight; } FieldInfo fi = typeof(TimelineGroupingByResourcesElement).GetField("leftCell", BindingFlags.Instance | BindingFlags.NonPublic); SchedulerCellElement leftCell = fi.GetValue(this) as SchedulerCellElement; FieldInfo fi2 = typeof(TimelineGroupingByResourcesElement).GetField("bottomCell", BindingFlags.Instance | BindingFlags.NonPublic); SchedulerCellElement bottomCell = fi2.GetValue(this) as SchedulerCellElement; if (leftCell != null) { RectangleF arrangeRectangle = new RectangleF(0, 0, ResourceHeaderWidth, headerHeight); if (this.RightToLeft) { arrangeRectangle = LayoutUtils.RTLTranslateNonRelative(arrangeRectangle, contentRect); } leftCell.Arrange(arrangeRectangle); } if (bottomCell != null) { RectangleF arrangeRectangle = new RectangleF(0, finalSize.Height - scrollBarOffset, ResourceHeaderWidth, scrollBarOffset); if (this.RightToLeft) { arrangeRectangle = LayoutUtils.RTLTranslateNonRelative(arrangeRectangle, contentRect); } bottomCell.Arrange(arrangeRectangle); } float separatorsWidth = this.View.GroupSeparatorWidth * (this.View.ResourcesPerView - 1); float resourcesHeight = finalSize.Height - separatorsWidth - headerHeight ; float y = 0; for (int i = 0; i < timelineElements.Count; i++) { SchedulerTimelineViewElement timelineElement = timelineElements[i]; LightVisualElement separator = i < viewSeparators.Count ? viewSeparators[i] : null; if (timelineElement != null) { float calculatedHeight = this.GetResourceSize(i, resourcesHeight); RectangleF arrangeRect = new RectangleF(this.ResourceHeaderWidth, y, finalSize.Width - this.ResourceHeaderWidth - vScrollOffset, calculatedHeight); if (i == 0) { arrangeRect.Height += headerHeight; } else if (i == timelineElements.Count - 1) { arrangeRect.Height = finalSize.Height - arrangeRect.Top - 1; } if (this.RightToLeft) { arrangeRect = LayoutUtils.RTLTranslateNonRelative(arrangeRect, contentRect); } timelineElement.Arrange(arrangeRect); y += arrangeRect.Height; if (i == 0) { arrangeRect.Height -= headerHeight; } else { arrangeRect.Y -= headerHeight; } resourcesBounds.Add(arrangeRect); } if (separator != null) { float calculatedHeight = this.View.GroupSeparatorWidth; RectangleF arrangeRect = new RectangleF(this.ResourceHeaderWidth, y, finalSize.Width - this.ResourceHeaderWidth - vScrollOffset, calculatedHeight); if (this.RightToLeft) { arrangeRect = LayoutUtils.RTLTranslateNonRelative(arrangeRect, contentRect); } separator.Arrange(arrangeRect); arrangeRect.Y -= headerHeight; separatorsBounds.Add(arrangeRect); y += calculatedHeight; } } if (this.ResourcesHeader != null) { RectangleF arrangeRectangle = new RectangleF(0, headerHeight, this.ResourceHeaderWidth, finalSize.Height - scrollBarOffset - headerHeight); if (this.RightToLeft) { arrangeRectangle = LayoutUtils.RTLTranslateNonRelative(arrangeRectangle, contentRect); } this.ResourcesHeader.SetResourcesLayoutInfo(resourcesBounds, separatorsBounds); this.ResourcesHeader.Arrange(arrangeRectangle); } if (this.View.AllowResourcesScrolling) { RectangleF scrollbarRect = new RectangleF(finalSize.Width - vScrollOffset, 0, vScrollOffset, finalSize.Height - scrollBarOffset); if (this.RightToLeft) { scrollbarRect = LayoutUtils.RTLTranslateNonRelative(scrollbarRect, contentRect); } this.VScrollBar.Arrange(scrollbarRect); } else { this.VScrollBar.Arrange(RectangleF.Empty); } return finalSize; } }
To reproduce: Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim dayView As SchedulerDayView = Me.RadScheduler1.GetDayView() dayView.RangeFactor = ScaleRange.FiveMinutes Dim ruler As RulerPrimitive = TryCast(Me.RadScheduler1.SchedulerElement.ViewElement, _ SchedulerDayViewElement).DataAreaElement.Ruler ruler.FormatStrings = New RulerFormatStrings("hh", "mm", "hh", "mm") End Sub Add a RadScheduler to a form and use the code snippet above. Run the application and scroll to the current time to see the current time indicator. Leave the form opened so you can see it on the second monitor but focus on another application for 5 minutes. You will notice that the current time indicator won't be redrawn until you focus RadScheduler again, click on the view or perform scrolling. The expected behavior is that RadScheduler will move the current time indicator as time is ticking. Workaround: use a timer to refresh RadScheduler at a certain interval: Dim timer As New Timer timer.Interval = 1000 AddHandler timer.Tick, AddressOf TimerTick timer.Start() Private Sub TimerTick(sender As Object, e As EventArgs) Me.RadScheduler1.SchedulerElement.RefreshViewElement() End Sub
Please refer to the attached gif files. The separator ";" should be displayed when the appointment's information is displayed in a single line. Otherwise, the information should be displayed multi-line like in the OutlookSeparator.gif. Note: you can test with different AppointmentTitleFormat. Important: setting the Text in the AppointmentFormatting event must have higher priority than AppointmentTitleFormat!!! Workaround: Sub New() InitializeComponent() Me.RadScheduler1.ElementProvider = New MyElementProvider(Me.RadScheduler1) Me.RadScheduler1.Appointments.Add(New Appointment(DateTime.Now, TimeSpan.FromMinutes(40), "Summary", "Description", "Location")) End Sub Public Class CustomAppointmentElement Inherits AppointmentElement Public Sub New(scheduler As RadScheduler, view As SchedulerView, appointment As IEvent) MyBase.New(scheduler, view, appointment) End Sub Protected Overrides Function CreateAppointmentText() As String Return String.Format("{0:HH:mm} - {1:HH:mm} {3} <b>{2}</b>", Me.Appointment.Start, Me.Appointment.End, _ Me.Appointment.Location, Me.Appointment.Summary) End Function End Class Public Class MyElementProvider Inherits SchedulerElementProvider Public Sub New(scheduler As RadScheduler) MyBase.New(scheduler) End Sub Protected Overrides Function CreateElement(Of T As SchedulerVisualElement)(view As SchedulerView, context As Object) As T If GetType(T) = GetType(AppointmentElement) Then Return TryCast(New CustomAppointmentElement(Me.Scheduler, view, DirectCast(context, IEvent)), T) End If Return MyBase.CreateElement(Of T)(view, context) End Function End Class
To reproduce: please refer to the attached sample project and gif file illustrating the visual problem. Workaround: subscribe to the RadSchedulerNavigator.ShowWeekendStateChanged event and refresh the scheduler view element: AddHandler Me.RadSchedulerNavigator1.ShowWeekendStateChanged, AddressOf ShowWeekendStateChanged Private Sub ShowWeekendStateChanged(sender As Object, args As StateChangedEventArgs) Me.RadScheduler1.SchedulerElement.RefreshViewElement() End Sub
The resulting behavior should be similar to having all day appointments in the control with the view having its ShowAllDayArea property set to false. Currently when printed the all day appointments are drawn in the all day area.
How to reproduce: Public Class Form1 Sub New() InitializeComponent() End Sub Protected Overrides Sub OnLoad(e As EventArgs) MyBase.OnLoad(e) Me.SetUpScheduler() For i As Integer = 0 To 0 Dim app As New Appointment(DateTime.Now.AddHours(1), TimeSpan.FromMinutes(60), "Summary" & i, "Description1") app.ResourceId = Me.RadScheduler1.Resources(i).Id Me.RadScheduler1.Appointments.Add(app) Dim app2 As New Appointment(DateTime.Now.AddHours(3), TimeSpan.FromMinutes(60), "Summary" & i, "Description2") app2.BackgroundId = 2 app2.ResourceId = Me.RadScheduler1.Resources(i).Id Me.RadScheduler1.Appointments.Add(app2) Dim recurringAppointment As New Appointment(DateTime.Now, TimeSpan.FromMinutes(60), "Recurring" & i, "Recurring Appointment") recurringAppointment.BackgroundId = 4 recurringAppointment.ResourceId = Me.RadScheduler1.Resources(i).Id recurringAppointment.RecurrenceRule = New DailyRecurrenceRule(DateTime.Now, 1, 10) Me.RadScheduler1.Appointments.Add(recurringAppointment) Next 'AddHandler Me.RadScheduler1.CellPrintElementFormatting, AddressOf RadScheduler1_CellPrintElementFormatting End Sub Private Sub SetUpScheduler() Dim colors As Color() = New Color() {Color.LightBlue, Color.LightGreen, Color.LightYellow, Color.Red, Color.Orange, Color.Pink, _ Color.Purple, Color.Peru, Color.PowderBlue} 'Dim names As String() = New String() {"Alan Smith", "Anne Dodsworth", "Boyan Mastoni", "Richard Duncan", "Maria Schneider"} Dim names As String() = New String() {"Rick Astley"} For i As Integer = 0 To names.Length - 1 Dim resource As New Resource() resource.Id = New EventId(i) resource.Name = names(i) resource.Color = colors(i) Me.RadScheduler1.Resources.Add(resource) Next Me.RadScheduler1.ActiveView.ResourcesPerView = 1 Me.RadScheduler1.GroupType = GroupType.Resource Me.RadSchedulerNavigator1.SchedulerNavigatorElement.TimeZonesElementLayout.Visibility = ElementVisibility.Collapsed Me.RadSchedulerNavigator1.ShowWeekendCheckBox.Visibility = ElementVisibility.Collapsed Me.RadSchedulerNavigator1.SchedulerNavigatorElement.MonthViewButton.Visibility = ElementVisibility.Collapsed Me.RadSchedulerNavigator1.SchedulerNavigatorElement.TimelineViewButtonVisible = False End Sub Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click Me.PrintScheduler(Me.RadScheduler1) End Sub Private Sub PrintScheduler(radScheduler As RadScheduler) Dim doc As RadPrintDocument = New RadPrintDocument doc.AssociatedObject = radScheduler Dim schedulerPrintStyle As Telerik.WinControls.UI.SchedulerPrintStyle = Nothing Select Case Me.RadScheduler1.ActiveViewType Case SchedulerViewType.Day schedulerPrintStyle = New SchedulerDailyPrintStyle() 'schedulerPrintStyle = New CustomRadSchedulerDailyPrintStyle() Case SchedulerViewType.Week, SchedulerViewType.WorkWeek schedulerPrintStyle = New SchedulerWeeklyCalendarPrintStyle() 'schedulerPrintStyle = New CustomSchedulerWeeklyCalendarPrintStyle() End Select schedulerPrintStyle.DateStartRange = radScheduler.ActiveView.StartDate schedulerPrintStyle.DateEndRange = radScheduler.ActiveView.EndDate schedulerPrintStyle.TimeStartRange = TimeSpan.FromMinutes(5) schedulerPrintStyle.TimeEndRange = TimeSpan.FromHours(23).Add(TimeSpan.FromMinutes(59)) schedulerPrintStyle.AppointmentFont = New Font("Consolas", 8.5) schedulerPrintStyle.GroupType = SchedulerPrintGroupType.Resource AddHandler schedulerPrintStyle.CellElementFormatting, AddressOf radSchedWork_PrintSchedulerCellElementFormatting radScheduler.PrintStyle = schedulerPrintStyle radScheduler.PrintPreview() End Sub Private Sub radSchedWork_PrintSchedulerCellElementFormatting(sender As Object, e As PrintSchedulerCellEventArgs) e.CellElement.BackColor = Color.White e.CellElement.DrawFill = False Dim cell As SchedulerPrintCellElement = TryCast(e.CellElement, SchedulerPrintCellElement) If cell IsNot Nothing Then Dim msg As String = "PrintSchedulerCellElementFormatting for Date {0}" Debug.Print(String.Format(msg, e.CellElement.Date)) 'If cell.DateFormat = "hh:mm" Then ' cell.DateFormat = "hh:mm tt" 'ElseIf cell.DateFormat = "dd MMM" Then ' cell.DateFormat = "dd ddd" 'Else e.CellElement.DrawFill = True If e.CellElement.[Date].Hour Mod 2 = 0 Then If e.CellElement.[Date].Day Mod 2 = 0 Then e.CellElement.BackColor = Color.LightSalmon Else e.CellElement.BackColor = Color.LightBlue End If Else e.CellElement.BackColor = Color.LightGreen End If 'End If End If End Sub Private Sub RadScheduler1_CellFormatting(sender As Object, e As SchedulerCellEventArgs) Handles RadScheduler1.CellFormatting 'reset all properties for cells that may be changed here e.CellElement.BackColor = Color.White e.CellElement.DrawFill = False If e.CellElement.[Date].Hour Mod 2 = 0 Then e.CellElement.DrawFill = True If e.CellElement.[Date].Day Mod 2 = 0 Then e.CellElement.BackColor = Color.LightSalmon Else e.CellElement.BackColor = Color.LightBlue End If Else e.CellElement.BackColor = Color.LightGreen End If End Sub End Class Workaround: Private Sub PrintScheduler(radScheduler As RadScheduler) Dim doc As RadPrintDocument = New RadPrintDocument doc.AssociatedObject = radScheduler Dim schedulerPrintStyle As Telerik.WinControls.UI.SchedulerPrintStyle = Nothing Select Case Me.RadScheduler1.ActiveViewType Case SchedulerViewType.Day 'schedulerPrintStyle = New SchedulerDailyPrintStyle() schedulerPrintStyle = New CustomRadSchedulerDailyPrintStyle() Case SchedulerViewType.Week, SchedulerViewType.WorkWeek 'schedulerPrintStyle = New SchedulerWeeklyCalendarPrintStyle() schedulerPrintStyle = New CustomSchedulerWeeklyCalendarPrintStyle() End Select schedulerPrintStyle.DateStartRange = radScheduler.ActiveView.StartDate schedulerPrintStyle.DateEndRange = radScheduler.ActiveView.EndDate schedulerPrintStyle.TimeStartRange = TimeSpan.FromMinutes(5) schedulerPrintStyle.TimeEndRange = TimeSpan.FromHours(23).Add(TimeSpan.FromMinutes(59)) schedulerPrintStyle.AppointmentFont = New Font("Consolas", 8.5) schedulerPrintStyle.GroupType = SchedulerPrintGroupType.Resource AddHandler schedulerPrintStyle.CellElementFormatting, AddressOf radSchedWork_PrintSchedulerCellElementFormatting radScheduler.PrintStyle = schedulerPrintStyle radScheduler.PrintPreview() End Sub Public Class CustomRadSchedulerDailyPrintStyle Inherits SchedulerDailyPrintStyle Private currentPage As Integer Public Overrides Sub DrawPage(graphics As Graphics, drawingArea As Rectangle, pageNumber As Integer) Me.currentPage = pageNumber MyBase.DrawPage(graphics, drawingArea, pageNumber) End Sub Protected Overrides Sub DrawCells(appArea As Rectangle, graphics As Graphics) Dim currentDate = Me.GetPageDate(Me.currentPage) Dim rowCount As Single = Math.Max(1, CInt(Math.Ceiling((TimeEndRange - TimeSpan.FromHours(TimeStartRange.Hours)).TotalHours))) Dim rowHeight As Single = CSng(appArea.Height) / rowCount For row As Integer = 0 To rowCount - 1 Dim headerCellRect As New RectangleF(appArea.X, appArea.Y + row * rowHeight, Me.HoursColumnWidth, rowHeight) Dim element As New SchedulerPrintCellElement() element.DrawBorder = True element.Font = Me.DateHeadingFont element.[Date] = currentDate.AddHours(CInt(TimeStartRange.Add(TimeSpan.FromHours(row)).TotalHours)) element.DateFormat = "hh:mm" element.TextAlignment = ContentAlignment.TopRight Me.DrawCell(element, graphics, headerCellRect) element.DrawText = False Dim numberOfSubRows As Integer = 1 If Me.Scheduler.ActiveViewType = SchedulerViewType.Day OrElse Me.Scheduler.ActiveViewType = SchedulerViewType.MultiDay OrElse Me.Scheduler.ActiveViewType = SchedulerViewType.Week OrElse Me.Scheduler.ActiveViewType = SchedulerViewType.WorkWeek Then numberOfSubRows = 60 / CInt(DirectCast(Me.Scheduler.ActiveView, SchedulerDayViewBase).RangeFactor) End If For i As Integer = 0 To numberOfSubRows - 1 Dim rect As New RectangleF(appArea.X + HoursColumnWidth, appArea.Y + row * rowHeight + rowHeight / numberOfSubRows * i, appArea.Width - HoursColumnWidth, rowHeight / numberOfSubRows) If i = numberOfSubRows - 1 Then rect.Height += (appArea.Y + (row + 1) * rowHeight) - (rect.Y + rect.Height) End If Me.DrawCell(element, graphics, rect) Next Next End Sub End Class Public Class CustomSchedulerWeeklyCalendarPrintStyle Inherits SchedulerWeeklyCalendarPrintStyle Protected Overrides Sub DrawCells(appArea As RectangleF, graphics As Graphics, pageNumber As Integer) Dim days As Integer = Me.GetNumberOfDays(pageNumber) Dim currentDate As DateTime = Me.GetPageDate(pageNumber) If Me.TwoPagesPerWeek AndAlso pageNumber Mod 2 = 0 Then 'page numbers are 1-based currentDate = currentDate.AddDays(Me.GetNumberOfDays(pageNumber - 1)) End If Dim rowCount As Single = Math.Max(1, CInt(Math.Ceiling((TimeEndRange - TimeSpan.FromHours(TimeStartRange.Hours)).TotalHours))) Dim rowHeight As Single = CSng(appArea.Height) / rowCount Dim columnWidth As Single = (appArea.Width - Me.HoursColumnWidth) / CSng(days) For row As Integer = 0 To rowCount - 1 Dim headerCellRect As New RectangleF(appArea.X, appArea.Y + row * rowHeight, Me.HoursColumnWidth, rowHeight) Dim element As New SchedulerPrintCellElement() element.DrawBorder = True element.Font = Me.DateHeadingFont element.[Date] = DateTime.Today.AddHours(CInt(TimeStartRange.Add(TimeSpan.FromHours(row)).TotalHours)) element.[Date] = currentDate.AddHours(CInt(TimeStartRange.Add(TimeSpan.FromHours(row)).TotalHours)) element.DateFormat = "hh:mm" element.TextAlignment = ContentAlignment.TopRight Me.DrawCell(element, graphics, headerCellRect) element.DrawText = False Dim numberOfSubRows As Integer = 60 / CInt(DirectCast(Me.Scheduler.ActiveView, SchedulerDayViewBase).RangeFactor) For i As Integer = 0 To numberOfSubRows - 1 Dim rect As New RectangleF(appArea.X + HoursColumnWidth, appArea.Y + row * rowHeight + rowHeight / numberOfSubRows * i, appArea.Width - HoursColumnWidth, rowHeight / numberOfSubRows) If i = numberOfSubRows - 1 Then rect.Height += (appArea.Y + (row + 1) * rowHeight) - (rect.Y + rect.Height) End If Me.DrawCell(element, graphics, rect) Next For j As Integer = 0 To days - 1 element = New SchedulerPrintCellElement() element.DrawBorder = True element.DrawText = False element.[Date] = currentDate.AddDays(j).AddHours(CInt(TimeStartRange.Add(TimeSpan.FromHours(row)).TotalHours)) Dim rect As New RectangleF(appArea.X + HoursColumnWidth + j * columnWidth, appArea.Y + row * rowHeight, columnWidth, rowHeight) Me.DrawCell(element, graphics, rect) Next Next End Sub End Class
When you create an appointment that starts on 30 November and ends at 00:00 on 1 December, the appointment time slot is extended to the next day. This happens when it is the end of the previous month and the beginning of the next one. Please refer to the attached sample gif file illustrating how to reproduce the problem with the Demo Application. Workaround: if the end time is at midnight, reduce the duration with one minute. private void radScheduler1_AppointmentAdded(object sender, Telerik.WinControls.UI.AppointmentAddedEventArgs e) { if (e.Appointment.End.Hour==0 && e.Appointment.End.Minute==0) { e.Appointment.End = e.Appointment.End.AddMinutes(-1); } }
To reproduce: use the following code Sub New() InitializeComponent() AddHandler Me.RadScheduler1.ActiveViewChanged, AddressOf ActiveViewChanged Me.RadScheduler1.ActiveViewType = Telerik.WinControls.UI.SchedulerViewType.Week End Sub Private Sub ActiveViewChanged(sender As Object, e As Telerik.WinControls.UI.SchedulerViewChangedEventArgs) Dim dayView As SchedulerDayViewBase = TryCast(Me.RadScheduler1.ActiveView, SchedulerDayViewBase) Dim dayViewElement As SchedulerDayViewElement = TryCast(Me.RadScheduler1.SchedulerElement.ViewElement, SchedulerDayViewElement) If dayViewElement IsNot Nothing Then Dim ruler As RulerPrimitive = dayViewElement.DataAreaElement.Ruler ruler.StartScale = 6 ruler.EndScale = 22 dayView.WorkTime = New TimeInterval(TimeSpan.FromHours(13), TimeSpan.FromHours(16)) End If End Sub When you run the project you will notice that the work time starts from 19:00 to 22:00. When you switch between DayView and WeekView, the ruler is not aligned with the scheduler cells as well. The attached gif file illustrates the incorrect behavior. Workaround: use the RulerStartScale and RulerEndScale of the SchedulerDayViewBase Sub New() InitializeComponent() AddHandler Me.RadScheduler1.ActiveViewChanged, AddressOf ActiveViewChanged Me.RadScheduler1.ActiveViewType = Telerik.WinControls.UI.SchedulerViewType.Week End Sub Private Sub ActiveViewChanged(sender As Object, e As Telerik.WinControls.UI.SchedulerViewChangedEventArgs) Dim dayView As SchedulerDayViewBase = TryCast(Me.RadScheduler1.ActiveView, SchedulerDayViewBase) If dayView IsNot Nothing Then dayView.RulerStartScale = 6 dayView.RulerEndScale = 22 dayView.WorkTime = New TimeInterval(TimeSpan.FromHours(13), TimeSpan.FromHours(16)) End If End Sub
Currently, the control lacks such support and when this culture is used an exception is thrown. To reproduce use the sample project and press the navigator's Next button several times. StackTrace: System.ArgumentOutOfRangeException occurred HResult=-2146233086 Message=Year, Month, and Day parameters describe an un-representable DateTime. Source=mscorlib StackTrace: at System.DateTime.DateToTicks(Int32 year, Int32 month, Int32 day) at Telerik.WinControls.UI.DateHelper.GetEndOfMonth(DateTime date, DateTimeFormatInfo dateTimeFormat) at Telerik.WinControls.UI.DateHelper.GetMonthDisplayWeeks(DateTime date, DateTimeFormatInfo dateTimeFormat) at Telerik.WinControls.UI.SchedulerNavigatorElement.NavigateBackwards() at Telerik.WinControls.UI.SchedulerNavigatorElement.OnNavigateBackwards(Object sender, EventArgs e) at Telerik.WinControls.UI.SchedulerNavigatorElement.NavigateButton_Click(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at Telerik.WinControls.RadElement.OnClick(EventArgs e) at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e) at Telerik.WinControls.UI.RadButtonElement.OnClick(EventArgs e) at Telerik.WinControls.RadElement.DoClick(EventArgs e) at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e) at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e) at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at Telerik.WinControls.RadControl.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at SchedulerShamsiTest.Program.Main() in c:\Users\dyordano\Desktop\RadSchedulerFixPersianLocale (1)\SchedulerShamsiTest\Program.cs:line 19 InnerException: