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); }
void CheckColumnExists(AppointmentColumn column) { if (!_appointmentBook.ContainsKey(column)) { throw new SoftwareException("Column '{0}' does not exist", column.Name); } }
public ColumnViewModel( string name, AppointmentViewModel[] appointments, AppointmentColumn columnDataObject) { Name = name; Appointments = appointments; ColumnDataObject = columnDataObject; }
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; }
public virtual AppointmentColumn NewColumn(string name, object userObject) { var column = new AppointmentColumn { Name = name, UserObject = userObject }; _appointmentBook.Add(column, new List <Appointment>()); return(column); }
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); }
protected void FireAppointmentDoubleClick(AppointmentColumn column, Appointment appointment) { OnAppointmentDoubleClicked(column, appointment); if (AppointmentDoubleClicked != null) { AppointmentDoubleClicked( new AppointmentEvent { Source = this, Appointment = appointment, SourceColumn = column } ); } }
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); } }
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()); }
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]); } }
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); } }
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); } }
protected void OnFreeRegionSelected(AppointmentColumn column, DateTime startTime, DateTime endTime) { }
public bool IsColumnCompatible(AppointmentColumn column, Appointment appointment) { return(true); }
protected override bool OnAppointmentDropStarting(AppointmentColumn originalColumn, AppointmentColumn targetColumn, Appointment appointment, DateTime startTime, DateTime endTime) { return(true); }
protected virtual void DeleteAppointment(AppointmentColumn column, Appointment appointment) { DataSource.DeleteAppointment(column, appointment); RefreshFromDataSource(); }
protected virtual void OnAppointmentDrop(AppointmentColumn originalColumn, AppointmentColumn targetColumn, Appointment appointment, DateTime startTime, DateTime endTime) { RescheduleAppointment(appointment, originalColumn, targetColumn, startTime, endTime); }
protected virtual bool OnAppointmentDragStarting(AppointmentColumn column, Appointment appointment) { return(true); }
protected virtual void OnAppointmentDrag(AppointmentColumn column, Appointment appointment) { }
protected virtual bool OnAppointmentRescheduled(AppointmentColumn column, Appointment appointment, DateTime newTime, DateTime endTime, out string errorMessage) { errorMessage = null; return(true); }
protected virtual bool OnAppointmentDragging(Appointment appointment, AppointmentColumn overColumn, DateTime startTime, DateTime endTime) { return(IsTimeAvailable(overColumn, appointment, startTime, endTime)); }
protected virtual void OnAppointmentResizingStart(AppointmentColumn column, Appointment appointment) { }
protected virtual void OnAppointmentResizing(AppointmentColumn column, Appointment appointment, DateTime newTime, DateTime endTime) { }
protected void OnAppointmentDeselected(AppointmentColumn column, Appointment appointment) { }
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)); }
protected virtual bool IsTimeAvailable(AppointmentColumn column, Appointment appointment, DateTime startTime, DateTime endTime) { return(DataSource.IsTimeAvailable(column, appointment, startTime, endTime)); }
protected virtual void RescheduleAppointment(Appointment appointment, AppointmentColumn sourceColumn, AppointmentColumn destColumn, DateTime newStartTime, DateTime newEndTime) { DataSource.Reschedule(appointment, sourceColumn, destColumn, newStartTime, newEndTime); RefreshFromDataSource(); }
internal bool ContainsColumn(AppointmentColumn column) { return(_visibleColumns.Any(vc => vc.ColumnDataObject == column)); }
protected void OnAppointmentDoubleClicked(AppointmentColumn column, Appointment appointment) { }