Completed
Last Updated: 03 Dec 2018 17:21 by Dimitar
ADMIN
Hristo
Created on: 27 Nov 2018 13:16
Category: Scheduler/Reminder
Type: Bug Report
3
FIX. RadScheduler - the all-day header element needs to be scrolled after selecting an all-day header.
How to reproduce: check the attached (video radscheduler-selection-incorrect.gif)
 public RadForm1()
 {
     InitializeComponent();

     Appointment appointment = new Appointment(DateTime.Today.AddHours(13), TimeSpan.FromHours(1), "Test Appointment");
     this.radScheduler1.Appointments.Add(appointment);

     for (int i = 0; i < 25; i++)
     {
         appointment = new Appointment(DateTime.Today.AddHours(24), TimeSpan.FromHours(1), "AllDay: " + i);
         appointment.AllDay = true;
         this.radScheduler1.Appointments.Add(appointment);
     }
     this.radScheduler1.AllowAppointmentsMultiSelect = true;
 }

Workaround: create a custom input behavior

this.radScheduler1.SchedulerInputBehavior = new CustomSchedulerInputBehavior(this.radScheduler1);

public class CustomSchedulerInputBehavior : SchedulerInputBehavior
{
    public CustomSchedulerInputBehavior(RadScheduler scheduler) 
        : base(scheduler)
    {
    }

    public override bool HandleMouseWheel(MouseEventArgs args)
    {
        if (!this.Scheduler.AllowMouseWheelSupport)
            return false;

        bool scrolled = false;

        if (this.Scheduler.SelectionBehavior.IsAllDayAreaSelection || this.IsLastSelectedAppointmentAllDay(this.Scheduler.SelectionBehavior.SelectedAppointments))
        {
            if (this.Scheduler.GroupType == GroupType.Resource)
            {
                SchedulerDayViewGroupedByResourceElement grouped = this.Scheduler.ViewElement as SchedulerDayViewGroupedByResourceElement;
                IList<SchedulerDayViewElement> childViews = grouped != null ? grouped.GetChildViewElements() : null;
                if (childViews != null && childViews.Count > 0)
                {
                    RadScrollBarElement scroll = childViews[childViews.Count - 1].AllDayHeaderElement.ScrollBar;
                    if (scroll.Visibility != ElementVisibility.Collapsed)
                    {
                        int newValue = scroll.Value - childViews[childViews.Count - 1].AllDayHeaderElement.HeaderHeight * Math.Sign(args.Delta);
                        newValue = Math.Max(Math.Min(newValue, scroll.Maximum - scroll.LargeChange + 1), scroll.Minimum);
                        scroll.Value = newValue;
                        scrolled = true;
                    }
                }
            }
            else
            {
                SchedulerDayViewElement dayView = this.Scheduler.ViewElement as SchedulerDayViewElement;
                RadScrollBarElement scroll = dayView != null ? dayView.AllDayHeaderElement.ScrollBar : null;

                if (scroll != null && scroll.Visibility != ElementVisibility.Collapsed)
                {
                    int newValue = scroll.Value - dayView.AllDayHeaderElement.HeaderHeight * Math.Sign(args.Delta);
                    newValue = Math.Max(Math.Min(newValue, scroll.Maximum - scroll.LargeChange + 1), scroll.Minimum);
                    scroll.Value = newValue;
                    scrolled = true;
                }
            }
        }

        if (scrolled)
        {
            return false;
        }

        if (args.Delta > 0)
        {
            this.Scheduler.ViewElement.Scroll(true);
        }
        else
        {
            this.Scheduler.ViewElement.Scroll(false);
        }
        return false;
    }

    private bool IsLastSelectedAppointmentAllDay(ReadOnlyCollection<IEvent> selectedAppointments)
    {
        if (selectedAppointments.Count > 0)
        {
            return selectedAppointments[selectedAppointments.Count - 1].AllDay;
        }

        return false;
    }

}

(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments