We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set Dragging Time

Thread ID:

Created:

Updated:

Platform:

Replies:

144970 May 31,2019 12:12 AM UTC Jun 3,2019 07:01 AM UTC Xamarin.Forms 3
loading
Tags: SfSchedule
MikeD
Asked On May 31, 2019 12:12 AM UTC

Hello,

   I am trying to set the SFSchedule in my Xamarin.Forms app to be able to drag and drop an appointment.  The drag and drop feature works, however, it moves the appointment in 1 minute increments, I would like to set the increment to 15 minutes however in the AppointmentDragOver event the arg e.DraggingTime is read only.  Any help you can provide would be appreciated.

Subburaj Pandian Veluchamy [Syncfusion]
Replied On May 31, 2019 01:33 PM UTC

Hi MikeD, 
 
Thank you for contacting Syncfusion support. 
 
Based on provided information your requirement of “increasing the appointment dragging time to 15mins in AppointmentDragOver method” can be achieved in sample level by enabling ShowTimeIndicatorproperty schedule in AppointmentDragOver method. InAppointmentDrop method we have set the StartTime and EndTime value based on the drop time of the appointment. We have prepared the simple sample for the same. 
 
Code Snippet: 
      schedule.AppointmentDragOver += Schedule_AppointmentDragOver; 
        private void Schedule_AppointmentDragOver(object sender, AppointmentDragEventArgs e) 
        { 
            schedule.DragDropSettings.ShowTimeIndicator = ((e.DraggingTime.Minute % 15) == 0); 
        } 
  
 
 schedule.AppointmentDrop += SfSchedule_AppointmentDrop; 
 private void SfSchedule_AppointmentDrop(object sender, AppointmentDropEventArgs e) 
        { 
            var time = e.DropTime; 
            var remainder = time.Minute % 15; 
            var appointment = e.Appointment as ScheduleAppointment; 
            var appointmentDuration = appointment.EndTime - appointment.StartTime; 
  
            if (remainder != 0) 
            { 
                e.DropTime = (remainder < 7) ? time.AddMinutes(-remainder) : time.AddMinutes(15 - remainder); 
                appointment.StartTime = e.DropTime; 
                appointment.EndTime = e.DropTime.AddHours(appointmentDuration.Hours); 
            } 
        } 
  
We have attached sample for your reference, 
 
 
Kindly, refer the following User Guide documentation link reading the same, 
 
 
We hope this helps. Please let us know if you need any further assistance. 
 
Regards,  
Subburaj Pandian V  


MikeD
Replied On May 31, 2019 09:18 PM UTC

Thank you, that did it! I modified your code a little to better suit my logic.

        void Schedule_AppointmentDragOver(object sender, AppointmentDragEventArgs e)
        {
                                                          //We are limiting the appointments to increments of 15 minutes for the drag and drop so TimeIndicator only shows 00, 15, 30, 45
            Schedule.DragDropSettings.ShowTimeIndicator = ((e.DraggingTime.Minute % 15) == 0);
        }

        void Schedule_AppointmentDrop(object sender, AppointmentDropEventArgs e)
        {
            ScheduleAppointment appointment = e.Appoin
tment as ScheduleAppointment;
                              //Get the index of the modified appoint in the collection
            int ind = collection.IndexOf(appointment);                
                              //We are limiting the appointments to increments of 15 minutes for the drag and drop
                             int newTime = Convert.ToInt16(Math.Floor(e.DropTime.Minute / 15.0) * 15.0);
            TimeSpan appointmentDuration = appointment.EndTime - appointment.StartTime;
                              //subtract current start time from current start time which makes zero then add newTime (minutes)
            appointment.StartTime = appointment.StartTime.AddMinutes(-appointment.StartTime.Minute + newTime);
            appointment.EndTime = appointment.StartTime + appointmentDuration;
                             //update the collection            
                             collection[ind] = appointment;
        }
 
 

Subburaj Pandian Veluchamy [Syncfusion]
Replied On June 3, 2019 07:01 AM UTC

Hi Michael,

Thank you for the update. We are glad that the given solution meets your requirement. 
 
Please get in touch with us if you would require any further assistance. 
 
Regards,
Subburaj Pandian V 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon