This is a migrated thread and some comments may be shown as answers.
Calendar CurrentTimePointer
5 Answers 10 Views
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 02 Feb 2016, 12:28 PM

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

Sort by
0
Dimitar
Telerik team
answered on 03 Feb 2016, 02:12 PM
Hello Robert,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Robert
Top achievements
Rank 1
answered on 03 Feb 2016, 04:03 PM
[quote]Dimitar said:Hello Robert,

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items

[/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

 

0
Dimitar
Telerik team
answered on 04 Feb 2016, 01:49 PM
Hi 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.
 
Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Robert
Top achievements
Rank 1
answered on 09 Feb 2016, 04:33 PM

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

0
Dimitar
Telerik team
answered on 10 Feb 2016, 02:13 PM
Hi 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Robert
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Robert
Top achievements
Rank 1
Share this question
or