Occupied Timeslots

4 posts, 0 answers
  1. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 23 Feb 2012 Link to this post

    Hi,

    Is there anything like this for the Winform Scheduler:
    http://demos.telerik.com/aspnet-ajax/scheduler/examples/limitconcurrentappointments/defaultcs.aspx

    I still want to keep all  the functionality ie drag and drop, resize etc I just want to check that no appointments overlap.

    I can't see anything in the winform demo

    Thanks
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 27 Feb 2012 Link to this post

    Hello Karl,

    Thank you for your question.

    This functionality is not support out of the box, but you can achieve this by utilizing some of RadScheduler's events. The following code snippet demonstrates this:
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.radScheduler1.Appointments.CollectionChanging += new NotifyCollectionChangingEventHandler(Appointments_CollectionChanging);
        }
     
        void Appointments_CollectionChanging(object sender, NotifyCollectionChangingEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                e.Cancel = this.IsIntersecting(e.NewItems[0] as IEvent);
            }
        }
     
        private bool IsIntersecting(IEvent newApp)
        {
            if(newApp == null)
            {
                return false;
            }
     
            foreach (IEvent app in this.radScheduler1.Appointments)
            {
                if (newApp.Start < app.End && newApp.End > app.Start)
                {
                    return true;
                }
            }
     
            return false;
        }
    }

    I hope this is useful. Should you have any further questions, we will be glad to address them.

    Regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 05 Mar 2012 Link to this post

    Hi,

    The Appointments_CollectionChanging does not seem to fire, I looked a little more and it says it won't fire if I have not implemented INotifyPropertyChanging, I followed the customeditappointmentdialog example for my project.

    public

     

     

    class TimeAppointment : Appointment
    {

    }

    and then added this to implement it

     

    public class TimeAppointment : Appointment, INotifyPropertyChanged
    {
      
      
      
    public event PropertyChangedEventHandler PropertyChanged;
      
    protected override void OnPropertyChanged(string propertyName)
      
    {
      
    if (this.PropertyChanged != null)
      
    {
      
    this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      
    }
      
    }
      
    }


    But it still won't fire.

    Any ideas?

    Thanks

  5. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 08 Mar 2012 Link to this post

    Hello Karl,

    You do not need to implement the mentioned interface when using the CollectionChaning event. It should fire properly when adding new appointments. However, to check if the appointments overlap when dragging or resizing them, you should use the AppointmentMoving and AppointmentResizing events. I have skipped this requirement in my previous post by mistake. Now I am sending you a small sample project which demonstrates how to implement the desired scenario.

    Please let me know if it works for you. Also, if you have any further questions, feel free to ask.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top