Example #1
0
        private bool CheckAllOccurrencesDestinationSlots(Occurrence currentOccurrence, Slot currentDestinationSlot, Occurrence editedOccurrence)
        {
            var currentApp = currentOccurrence.Appointment as Appointment;

            var offsetOfTheOccurrence = currentApp.Start - currentOccurrence.Start;
            var destSlotOfMasterApp   = OffsetSlot(currentDestinationSlot, offsetOfTheOccurrence);


            var occurrences = currentApp.GetOccurrences(scheduleView.VisibleRange.Start, scheduleView.VisibleRange.End);

            destinationSlot = null;
            foreach (var occ in occurrences)
            {
                var occurrenceDestinationSlot = OffsetSlot(destSlotOfMasterApp, occ.Start - currentApp.Start);

                var appsInOccurrenceDestinationSlot = scheduleView.AppointmentsSource
                                                      .OfType <IAppointment>()
                                                      .Where((IAppointment a) => a != occ.Appointment)
                                                      .All((IAppointment a) => !ConflictChecking.AreOverlapping(a, occurrenceDestinationSlot, editedOccurrence));

                if (!appsInOccurrenceDestinationSlot)
                {
                    ShowErrorWindow();
                    return(true);
                }
            }

            return(false);
        }
        public override bool CanDrop(DragDropState state)
        {
            var draggedOccurrence = state.Appointment as Occurrence;

            return(state.DestinationAppointmentsSource
                   .OfType <IAppointment>()
                   .Where((IAppointment a) => !state.DraggedAppointments.Contains(a))
                   .All((IAppointment a) => state.DestinationSlots.All((Slot s) => !ConflictChecking.AreOverlapping(a, s, draggedOccurrence))));
        }