Hi guys,
I'm hoping someone can lend me a hand in regards to the currentTimePointer functionality on the RadCalendar control.
The pointer only highlights the current day's current time, while I would like the line to extend across the whole week.
Basically, I'm trying to mimic Outlook when it comes to highlighting the current time.
The only accessible properties for the currentTimePointer are the Color and Width, so before I start diving in too deep, is there a fairly easy way to achieve the full length timePointer that I'm looking for?
Thanks,
Robert
5 Answers, 1 is accepted
Thank you for writing.
The RadCalendar control used in the Telerik UI for Winforms suite does not have such functionality. This is why I want to ask you to specify which control and which product you are pointing in this case? You can attach a screenshot that shows the used control as well.
Thank you in advance for your patience and cooperation.
Regards,
Dimitar
Telerik
Thank you for writing.
The RadCalendar control used in the Telerik UI for Winforms suite does not have such functionality. This is why I want to ask you to specify which control and which product you are pointing in this case? You can attach a screenshot that shows the used control as well.
Thank you in advance for your patience and cooperation.
Regards,
Dimitar
Telerik
[/quote]
Hi Dimitar,
Sorry, I've been referring to the functionality inside the RadScheduler control, specifically.
The two exposed properties that can be changed (Color, Width) are accessed through the ViewElement -> DataAreaElement -> Ruler -> CurrentTimePointerColor/Width.
Does this make things a bit clearer?
Thanks,
Robert
Thank you for writing back.
To achieve the desired layout, you should create a custom DayViewAppointmentsTable class and override the DrawCurrentTimeIndicator method. You can use the class by changing the default scheduler ElementProvider:
public class MyElementProvider : SchedulerElementProvider{ public MyElementProvider(RadScheduler scheduler) : base(scheduler) { } protected override T CreateElement<T>(SchedulerView view, object context) { if (typeof(T) == typeof(DayViewAppointmentsTable)) { return new MyDayViewAppointmentsTable(this.Scheduler, view, context as DayViewAppointmentsArea) as T; } return base.CreateElement<T>(view, context); } }class MyDayViewAppointmentsTable : DayViewAppointmentsTable{ public MyDayViewAppointmentsTable(RadScheduler scheduler, SchedulerView view, DayViewAppointmentsArea area) : base(scheduler, view, area) { } protected override void DrawCurrentTimeIndicator(DateTime currentDateTime, SchedulerCellElement todayCell, IGraphics graphics) { TimeSpan span = currentDateTime - currentDateTime.Date.AddHours(this.GetDayViewBase().RulerStartScale).AddMinutes(this.GetDayViewBase().RulerStartScaleMinutes); TimeSpan hours24 = TimeSpan.FromMinutes(this.GetDayViewBase().RulerEndScale * 60 + this.GetDayViewBase().RulerEndScaleMinutes) - TimeSpan.FromMinutes(this.GetDayViewBase().RulerStartScale * 60 + this.GetDayViewBase().RulerStartScaleMinutes); float p = (float) (span.TotalMinutes / hours24.TotalMinutes); float y = this.Area.Ruler.SeparatorsOffset * this.GetDayViewBase().GetRowsCount() * p; float x = this.Area.BoundingRectangle.X; float width = this.Area.BoundingRectangle.Width; y = (float) Math.Ceiling(y); graphics.DrawLine(this.Area.Ruler.CurrentTimePointerColor, x, y, width, y, this.Area.Ruler.CurrentTimePointerWidth); }}Let me know if I can assist you further.
Dimitar
Telerik
Hi Dimitar,
Overriding the DrawCurrentTimeIndicator method works to a degree, but it still doesn't quite match the functionality I'm looking for.
The currentTimePointer now extends from the edge of the scheduler through to whatever the current day is, but no further.
The calculations in your provided override seem to be entirely correct, but the portion of the week that is yet to come seem to have some kind of paint functionality that either prevents it from being drawn over, over paints over the top of the currentTimePointer itself.
Any suggestions?
Thanks,
Robert
Thank you for writing back.
On my side, the line is drawn correctly (see attached image). This is why I have attached my test project. Could you please check it and let me know how it differs from your real setup?
I am looking forward to your reply.
Regards,
Dimitar
Telerik
