Hello!
I've been wanting to implement a copy function for appointments but I can't get it quite right.
The idea is simple, you have a form with a scheduler, which views multiple resources. When you start dragging and keep the control key pressed, you don't actually move the appointment but you copy it.
My code looks like this:
void
rdSchedule_AppointmentDropping(
object
sender, AppointmentMovingEventArgs e)
{
if
(ModifierKeys == Keys.Control)
{
if
(e.Appointment
is
AmfAppointment)
{
AmfAppointment copiedAppointment = ((AmfAppointment)e.Appointment).Copy();
copiedAppointment.Start = e.NewDate;
this
.rdSchedule.Appointments.Add(copiedAppointment);
e.Cancel =
true
;
}
}
}
rdSchedule is the Scheduler control.
AmfAppointment is my own inheritance of an Appointment and Copy() is a function to duplicate the Appointment.
This only (seems to, still some bugs to work out) work for copying an appointment to the same resources.
When dragging the appointment to another resource nothing happens.
Also; the AppointmentMovingEventArgs has a NewDate but no NewResource (i.e.)? And the e.Appointment.ResourceId is the old ResourceId so I can't get it from there either.
What is the right approach here? And if so how can I make this work for copying between different resources as well?
Thank you!