This is a migrated thread and some comments may be shown as answers.

Occupied Timeslots

3 Answers 71 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 23 Feb 2012, 06:04 PM
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

3 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 27 Feb 2012, 09:27 AM
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 >>
0
Karl
Top achievements
Rank 1
answered on 05 Mar 2012, 02:39 PM
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

0
Ivan Todorov
Telerik team
answered on 08 Mar 2012, 11:59 AM
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 >>
Tags
Scheduler and Reminder
Asked by
Karl
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Karl
Top achievements
Rank 1
Share this question
or