Пример #1
0
        public Appointment NewAppointment(AppointmentColumn column, string id, DateTime startTime, DateTime endTime, string subject, string locationPart1, string locationPart2, string notes, Color color, object userObject)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            var appointment = new Appointment {
                ID            = id,
                StartTime     = startTime,
                EndTime       = endTime,
                Subject       = subject,
                LocationPart1 = locationPart1,
                LocationPart2 = locationPart2,
                Notes         = notes,
                Color         = color,
                UserObject    = userObject
            };

            if (column is UnallocatedColumn)
            {
                _unallocatedAppointments.Add(appointment);
            }
            else
            {
                CheckColumnExists(column);
                _appointmentBook[column].Add(appointment);
            }
            return(appointment);
        }
Пример #2
0
 void CheckColumnExists(AppointmentColumn column)
 {
     if (!_appointmentBook.ContainsKey(column))
     {
         throw new SoftwareException("Column '{0}' does not exist", column.Name);
     }
 }
Пример #3
0
 public ColumnViewModel(
     string name,
     AppointmentViewModel[] appointments,
     AppointmentColumn columnDataObject)
 {
     Name             = name;
     Appointments     = appointments;
     ColumnDataObject = columnDataObject;
 }
Пример #4
0
        public virtual void Reschedule(Appointment appointment, AppointmentColumn sourceColumn, AppointmentColumn destColumn, DateTime newStartTime, DateTime newEndTime)
        {
            if (appointment == null)
            {
                throw new ArgumentNullException("appointment");
            }
            if (sourceColumn == null)
            {
                throw new ArgumentNullException("sourceColumn");
            }
            if (destColumn == null)
            {
                throw new ArgumentNullException("destColumn");
            }

            var sourceColumnIsUnallocated = sourceColumn is UnallocatedColumn;
            var destColumnIsUnallocated   = destColumn is UnallocatedColumn;

            // Moved columns:
            //	Column to Column
            //	Column to UnallocatedColumn
            //	UnallocatedColumn to Column

            if (sourceColumnIsUnallocated && destColumnIsUnallocated)
            {
                throw new NotSupportedException("Dragging/resizing an appointment from an unallocated book to an unallocated book is not supported");
            }
            else if (!sourceColumnIsUnallocated && !destColumnIsUnallocated)
            {
                if (sourceColumn != destColumn)
                {
                    // Column to Column
                    CheckColumnExists(sourceColumn);
                    CheckColumnExists(destColumn);
                    _appointmentBook[sourceColumn].Remove(appointment);
                    _appointmentBook[destColumn].Add(appointment);
                }
            }
            else if (!sourceColumnIsUnallocated)
            {
                //	Column to UnallocatedColumn
                CheckColumnExists(sourceColumn);
                _appointmentBook[sourceColumn].Remove(appointment);
                _unallocatedAppointments.Add(appointment);
            }
            else
            {
                //	UnallocatedColumn to Column
                CheckColumnExists(destColumn);
                _unallocatedAppointments.Remove(appointment);
                _appointmentBook[destColumn].Add(appointment);
            }

            appointment.StartTime = newStartTime;
            appointment.EndTime   = newEndTime;
        }
Пример #5
0
        public virtual AppointmentColumn NewColumn(string name, object userObject)
        {
            var column = new AppointmentColumn {
                Name       = name,
                UserObject = userObject
            };

            _appointmentBook.Add(column, new List <Appointment>());
            return(column);
        }
Пример #6
0
        protected virtual bool OnAppointmentDropStarting(AppointmentColumn originalColumn, AppointmentColumn targetColumn, Appointment appointment, DateTime startTime, DateTime endTime)
        {
            // Check 1 - start is less than or equal to finish
            // REMOVED Check 2 - appointment starts and finishes on same day (or midnight of next day)
            // Check 3 - no appointments overlap period
            var check1 = startTime <= endTime;
            //var check2 = startTime.Day == endTime.Day || endTime == startTime.Add(TimeSpan.FromDays(1)).ToMidnight();
            var check3 = IsTimeAvailable(targetColumn, appointment, startTime, endTime);

            return(check1 && true && check3);
        }
Пример #7
0
 protected void FireAppointmentDoubleClick(AppointmentColumn column, Appointment appointment)
 {
     OnAppointmentDoubleClicked(column, appointment);
     if (AppointmentDoubleClicked != null)
     {
         AppointmentDoubleClicked(
             new AppointmentEvent {
             Source       = this,
             Appointment  = appointment,
             SourceColumn = column
         }
             );
     }
 }
Пример #8
0
 protected void FireAppointmentDeselectoed(AppointmentColumn column, Appointment appointment)
 {
     try {
         OnAppointmentDeselected(column, appointment);
         if (AppointmentDeselected != null)
         {
             AppointmentDeselected(new AppointmentEvent {
                 Source = this, SourceColumn = column, Appointment = appointment
             });
         }
     } catch (Exception error) {
         ExceptionDialog.Show(this, error);
     }
 }
Пример #9
0
        public bool IsTimeAvailable(AppointmentColumn column, Appointment appointment, DateTime startTime, DateTime endTime)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            CheckColumnExists(column);
            var overlappingAppointments =
                _appointmentBook[column]
                .Where(a => startTime <a.EndTime && endTime> a.StartTime)
                .Except(appointment);

            return(!overlappingAppointments.Any());
        }
Пример #10
0
        public IEnumerable <Appointment> GetAppointments(AppointmentColumn column)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            if (column is UnallocatedColumn)
            {
                return(_unallocatedAppointments);
            }
            else
            {
                CheckColumnExists(column);
                return(_appointmentBook[column]);
            }
        }
Пример #11
0
        public virtual void DeleteAppointment(AppointmentColumn column, Appointment appointment)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            if (column is UnallocatedColumn)
            {
                _unallocatedAppointments.Remove(appointment);
            }
            else
            {
                CheckColumnExists(column);
                _appointmentBook[column].Remove(appointment);
            }
        }
Пример #12
0
 protected void FireFreeRegionSelected(AppointmentColumn column, DateTime startTime, DateTime endTime)
 {
     try {
         OnFreeRegionSelected(column, startTime, endTime);
         if (AppointmentBookFreeRegionSelected != null)
         {
             foreach (EventHandlerEx <AppointmentBookFreeRegionSelected> handler in AppointmentBookFreeRegionSelected.GetInvocationList())
             {
                 var eventArg = new AppointmentBookFreeRegionSelected {
                     Source    = this,
                     Column    = column,
                     StartTime = startTime,
                     EndTime   = endTime
                 };
                 handler.Invoke(eventArg);
             }
         }
     } catch (Exception error) {
         ExceptionDialog.Show(this, error);
     }
 }
Пример #13
0
 protected void OnFreeRegionSelected(AppointmentColumn column, DateTime startTime, DateTime endTime)
 {
 }
Пример #14
0
 public bool IsColumnCompatible(AppointmentColumn column, Appointment appointment)
 {
     return(true);
 }
Пример #15
0
 protected override bool OnAppointmentDropStarting(AppointmentColumn originalColumn, AppointmentColumn targetColumn, Appointment appointment, DateTime startTime, DateTime endTime)
 {
     return(true);
 }
Пример #16
0
 protected virtual void DeleteAppointment(AppointmentColumn column, Appointment appointment)
 {
     DataSource.DeleteAppointment(column, appointment);
     RefreshFromDataSource();
 }
Пример #17
0
 protected virtual void OnAppointmentDrop(AppointmentColumn originalColumn, AppointmentColumn targetColumn, Appointment appointment, DateTime startTime, DateTime endTime)
 {
     RescheduleAppointment(appointment, originalColumn, targetColumn, startTime, endTime);
 }
Пример #18
0
 protected virtual bool OnAppointmentDragStarting(AppointmentColumn column, Appointment appointment)
 {
     return(true);
 }
Пример #19
0
 protected virtual void OnAppointmentDrag(AppointmentColumn column, Appointment appointment)
 {
 }
Пример #20
0
 protected virtual bool OnAppointmentRescheduled(AppointmentColumn column, Appointment appointment, DateTime newTime, DateTime endTime, out string errorMessage)
 {
     errorMessage = null;
     return(true);
 }
Пример #21
0
 protected virtual bool OnAppointmentDragging(Appointment appointment, AppointmentColumn overColumn, DateTime startTime, DateTime endTime)
 {
     return(IsTimeAvailable(overColumn, appointment, startTime, endTime));
 }
Пример #22
0
 protected virtual void OnAppointmentResizingStart(AppointmentColumn column, Appointment appointment)
 {
 }
Пример #23
0
 protected virtual void OnAppointmentResizing(AppointmentColumn column, Appointment appointment, DateTime newTime, DateTime endTime)
 {
 }
Пример #24
0
 protected void OnAppointmentDeselected(AppointmentColumn column, Appointment appointment)
 {
 }
Пример #25
0
 protected override bool IsTimeAvailable(AppointmentColumn column, Appointment appointment, DateTime startTime, DateTime endTime)
 {
     return(true);
 }
 protected virtual ColumnViewModel Convert(AppointmentColumn column, IEnumerable <AppointmentViewModel> appointmentViewModels)
 {
     return(new ColumnViewModel(column.Name, appointmentViewModels.ToArray(), column));
 }
Пример #27
0
 protected virtual bool IsTimeAvailable(AppointmentColumn column, Appointment appointment, DateTime startTime, DateTime endTime)
 {
     return(DataSource.IsTimeAvailable(column, appointment, startTime, endTime));
 }
Пример #28
0
 protected virtual void RescheduleAppointment(Appointment appointment, AppointmentColumn sourceColumn, AppointmentColumn destColumn, DateTime newStartTime, DateTime newEndTime)
 {
     DataSource.Reschedule(appointment, sourceColumn, destColumn, newStartTime, newEndTime);
     RefreshFromDataSource();
 }
Пример #29
0
 internal bool ContainsColumn(AppointmentColumn column)
 {
     return(_visibleColumns.Any(vc => vc.ColumnDataObject == column));
 }
Пример #30
0
 protected void OnAppointmentDoubleClicked(AppointmentColumn column, Appointment appointment)
 {
 }