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

Scheduler custom dialogs

2 Answers 66 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 19 Jul 2019, 12:55 PM

Hello,

I am currently implementing the RadScheduler control where I have already replaced the AppointmentEditDialog and the EditRecurrenceDialog.

Could you point me in the right direction how to replace the message-dialog when you move/resize a single item of a recurrence appointment?

(See attached image)

 

Best regards

Patrick Vossen

 

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 Jul 2019, 11:46 AM
Hello, Patrick, 

The AppointmentDraggingBehavior shows the message box illustrated in the attached screenshot. If you need to customize it, it is necessary to create a derivative of the AppointmentDraggingBehavior and override its ValidateOccurrenceDropTarget method. You can find below the default implementation of the method and how to replace the default drag drop behavior:

public RadForm1()
{
    InitializeComponent();
 
    this.radScheduler1.Appointments.Add(new Appointment(DateTime.Now, TimeSpan.FromHours(1), "Test"));
    radScheduler1.Appointments[0].RecurrenceRule = new HourlyRecurrenceRule(DateTime.Now, 3, 4);
 
    this.radScheduler1.SchedulerElement.DragDropBehavior = new CustomAppointmentDraggingBehavior(this.radScheduler1.SchedulerElement);
}
 
public class CustomAppointmentDraggingBehavior : AppointmentDraggingBehavior
{
    public CustomAppointmentDraggingBehavior(SchedulerVisualElement activeOwner) : base(activeOwner)
    {
    }
 
    protected override bool ValidateOccurrenceDropTarget(DateTime targetStartDate, DateTime targetEndDate, bool allDay)
    {
        IEvent dragged = this.ActiveFeedback.AssociatedAppointment;
        IEvent master = dragged.MasterEvent;
 
        if (master == null)
        {
            return true;
        }
 
        bool isException = master.Exceptions.Contains(dragged);
        DateTime originalOccurrenceDate = (dragged.RecurrenceId ?? dragged.Start);
 
        foreach (IEvent occurrence in OccurrenceEnumerator.GetOccurrences(master,
            this.Scheduler.ActiveView.StartDate, this.Scheduler.ActiveView.EndDate.AddDays(1), false))
        {
            if (occurrence.Start != originalOccurrenceDate && occurrence.Start.Date == targetStartDate.Date &&
                !(master.RecurrenceRule is HourlyRecurrenceRule) && !
                (master.RecurrenceRule is MinutelyRecurrenceRule))
            {
                if (this.ShowOccurrenceValidationMessages)
                {
                    RadMessageBox.SetThemeName(this.Scheduler.ThemeName);
                    RadMessageBox.Show(RadSchedulerLocalizationProvider.CurrentProvider.GetLocalizedString(
                        RadSchedulerStringId.RecurrenceDragDropValidationSameDateText),
                        String.Empty, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                }
                return false;
            }
            else if (
            ((originalOccurrenceDate < occurrence.Start && occurrence.Start < targetStartDate) ||
             (originalOccurrenceDate > occurrence.Start && occurrence.Start > targetStartDate)))
            {
                if (this.ShowOccurrenceValidationMessages)
                {
                    RadMessageBox.SetThemeName(this.Scheduler.ThemeName);
                    RadMessageBox.Show(RadSchedulerLocalizationProvider.CurrentProvider.GetLocalizedString(
                        RadSchedulerStringId.RecurrenceDragDropValidationSkipOccurrenceText),
                        String.Empty, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                }
                return false;
            }
        }
 
        foreach (IEvent occurrence in master.Exceptions)
        {
            if (occurrence == dragged)
            {
                continue;
            }
 
            if (occurrence.Start != originalOccurrenceDate && occurrence.Start.Date == targetStartDate.Date &&
                !(master.RecurrenceRule is HourlyRecurrenceRule) && !
                (master.RecurrenceRule is MinutelyRecurrenceRule))
            {
                if (this.ShowOccurrenceValidationMessages)
                {
                    RadMessageBox.SetThemeName(this.Scheduler.ThemeName);
                    RadMessageBox.Show(RadSchedulerLocalizationProvider.CurrentProvider.GetLocalizedString(
                        RadSchedulerStringId.RecurrenceDragDropValidationSameDateText),
                        String.Empty, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                }
                return false;
            }
            else if (
            ((originalOccurrenceDate < occurrence.Start && occurrence.Start < targetStartDate) ||
             (originalOccurrenceDate > occurrence.Start && occurrence.Start > targetStartDate)))
            {
                if (this.ShowOccurrenceValidationMessages)
                {
                    RadMessageBox.SetThemeName(this.Scheduler.ThemeName);
                    RadMessageBox.Show(RadSchedulerLocalizationProvider.CurrentProvider.GetLocalizedString(
                        RadSchedulerStringId.RecurrenceDragDropValidationSkipOccurrenceText),
                        String.Empty, MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                }
                return false;
            }
        }
 
        if (isException || !this.ShowCreateExceptionDialog)
        {
            return true;
        }
 
        RadMessageBox.SetThemeName(this.Scheduler.ThemeName);
 
        return RadMessageBox.Show(
            RadSchedulerLocalizationProvider.CurrentProvider.GetLocalizedString(
                RadSchedulerStringId.RecurrenceDragDropCreateExceptionDialogText),
            String.Empty, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes;
    }
}

The RadMessageBox shown at the bottom of the method is the one you need. Feel free to replace it with any dialog that you have constructed. 
 
I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Patrick
Top achievements
Rank 1
answered on 24 Jul 2019, 08:33 AM

Hi Dess,

Thanks 4 the solution.

I am going to apply the mentioned solution.

Grtz Patrick

Tags
Scheduler and Reminder
Asked by
Patrick
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or