Calendar CurrentTimePointer

6 posts, 0 answers
  1. Robert
    Robert avatar
    4 posts
    Member since:
    Mar 2015

    Posted 02 Feb Link to this post

    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

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 03 Feb Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    4 posts
    Member since:
    Mar 2015

    Posted 03 Feb in reply to Dimitar Link to this post

    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

    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

     

  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 04 Feb Link to this post

    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
  6. Robert
    Robert avatar
    4 posts
    Member since:
    Mar 2015

    Posted 09 Feb in reply to Dimitar Link to this post

    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

  7. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 10 Feb Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready