Completed
Last Updated: 19 Oct 2020 13:35 by ADMIN
Release R3 2020 SP1
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 20 Nov 2015 09:16
Category: Scheduler/Reminder
Type: Bug Report
1
FIX. RadScheduler - appointments do not line up in Timeline view with EnableExactTimeRendering
To reproduce:

public Form1()
{
    InitializeComponent();
    
    this.radScheduler1.ActiveViewType = SchedulerViewType.Timeline;
    Timescales scale = Timescales.Hours;
    this.radScheduler1.GetTimelineView().ShowTimescale(scale);

    Appointment app1 = new Appointment(DateTime.Today.AddHours(6), TimeSpan.FromMinutes(25), "A1");
    Appointment app2 = new Appointment(DateTime.Today.AddHours(6).AddMinutes(25), TimeSpan.FromMinutes(16), "A2");
    Appointment app3 = new Appointment(DateTime.Today.AddHours(6).AddMinutes(41), TimeSpan.FromMinutes(12), "A3");

    this.radScheduler1.Appointments.Add(app1);
    this.radScheduler1.Appointments.Add(app2);
    this.radScheduler1.Appointments.Add(app3); 

    this.radScheduler1.EnableExactTimeRendering = true;  
}


Workaround:

 this.radScheduler1.ElementProvider = new MyElementProvider(this.radScheduler1);

public class MyElementProvider : SchedulerElementProvider
{
    public MyElementProvider(RadScheduler scheduler) : base(scheduler)
    {
    }

    protected override T CreateElement<T>(SchedulerView view, object context)
    {
        if (typeof(T) == typeof(TimelineAppointmentsPresenter))
        {
            return new CustomTimelineAppointmentsPresenter(this.Scheduler, view, (SchedulerTimelineViewElement)context)as T;
        }
        return base.CreateElement<T>(view, context);
    }
}

public class CustomTimelineAppointmentsPresenter: TimelineAppointmentsPresenter
{
    public CustomTimelineAppointmentsPresenter(RadScheduler scheduler, SchedulerView view,
        SchedulerTimelineViewElement timelineViewElement) : base(scheduler, view, timelineViewElement)
    {
    }

    protected override void ResolveOverlappingAppointments(SizeF availableSize)
    {
        List<AppointmentElement> appointments = new List<AppointmentElement>();
        foreach (AppointmentElement element in this.AppointmentElements)
        {
            if (element.Visibility != ElementVisibility.Collapsed)
            {
                appointments.Add(element);
            }
        }

        appointments.Sort(new DateTimeComparer(this.Scheduler));
        List<AppointmentElement> arrangedAppointments = new List<AppointmentElement>();

        foreach (AppointmentElement appointment in appointments)
        {
            for (int i = 0; i < arrangedAppointments.Count; i++)
            {
                AppointmentElement otherAppointment = arrangedAppointments[i];

                if (otherAppointment == appointment)
                {
                    continue;
                }

                RectangleF rect = appointment.DesiredBounds;
                rect.Inflate(new SizeF(-2,-2));
                if (otherAppointment.DesiredBounds.IntersectsWith(rect))
                {
                    appointment.DesiredBounds.Y = otherAppointment.DesiredBounds.Bottom;
                    i = -1;

                    continue;
                }
            }

            arrangedAppointments.Add(appointment);
        }
    }
}
Attached Files:
2 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 11 Dec 2015 15:33
Hello David,

I am glad that the suggested solution is applicable for your case.
David
Posted on: 24 Nov 2015 15:49
Problem solved thanks to your (voodoo) code.