New to Telerik UI for WinForms? Start a free 30-day trial

Stores date intervals for Scheduler views and routes mutations through optional change callbacks. Single-item insertions are ordered by start date and reject intersections with existing intervals.

Definition

Constructors

Initializes an empty interval collection without a change handler.

C#
public DateTimeIntervalCollection()

Initializes the collection with the specified intervals, rejecting any interval that intersects one already added.

C#
public DateTimeIntervalCollection(IEnumerable<DateTimeInterval> intervals)
Parameters:intervalsIEnumerable<DateTimeInterval>

The intervals to add; null is treated as an empty sequence.

Exceptions: InvalidOperationException

An input interval intersects an earlier interval in the sequence.

Initializes an empty interval collection that delegates change approval and notifications to a handler.

C#
public DateTimeIntervalCollection(IListChangeHandler<DateTimeInterval> listChangeHandler)
Parameters:listChangeHandlerIListChangeHandler<DateTimeInterval>

The handler used before and after accepted changes.

Fields

Stores the handler that can cancel changes and receive post-change notifications.

C#
protected IListChangeHandler<DateTimeInterval> listChangeHandler

Methods

Adds an interval from midnight on the start date through the last second of the end date.

C#
public virtual DateTimeInterval Add(DateTime startDate, DateTime endTime)
Parameters:startDateDateTime

The date on which the interval begins.

endTimeDateTime

The date whose day supplies the interval's inclusive end boundary.

Returns:

DateTimeInterval

The created interval; the change handler may cancel its insertion.

Adds an interval beginning at midnight on startDate with a duration of dayCount days minus one second.

C#
public virtual DateTimeInterval Add(DateTime startDate, int dayCount)
Parameters:startDateDateTime

The date on which the interval begins.

dayCountint

The number of days used to calculate the interval duration.

Returns:

DateTimeInterval

The created interval; the change handler may cancel its insertion.

Adds intervals in input order after checking each one for intersections with intervals already in the collection. It does not sort the range or check for intersections between items in the input sequence. The input sequence is enumerated twice and must be repeatable.

C#
public virtual void AddRange(IEnumerable<DateTimeInterval> intervalCollection)
Parameters:intervalCollectionIEnumerable<DateTimeInterval>

The repeatable sequence of intervals to add.

Exceptions: ArgumentNullException

intervalCollection is null.

InvalidOperationException

An input interval intersects an interval already in the collection.

Begins a nestable update batch that suppresses the public CollectionChanged event until the outer batch ends. The configured handler still receives a callback for each accepted change.

C#
public void BeginUpdate()

Removes all intervals unless the change handler cancels the operation.

C#
protected override void ClearItems()

Overrides: Collection<DateTimeInterval>.ClearItems()

Determines whether any interval in the collection contains the specified date. Interval endpoints are included.

C#
public virtual bool Contains(DateTime date)
Parameters:dateDateTime

The date to search for.

Returns:

bool

true if the date is contained; otherwise, false.

Ends one update batch and requests a reset notification when the outermost batch ends.

C#
public void EndUpdate()

Ends one update batch and optionally sends a reset notification when the outermost batch ends.

C#
public void EndUpdate(bool notify)
Parameters:notifybool

true to notify the handler and collection listeners; otherwise, suppress notification.

Inserts an interval in ascending order by its start date.

C#
protected void InsertInterval(DateTimeInterval interval)
Parameters:intervalDateTimeInterval

The interval to insert.

Validates and inserts an interval by start date; the requested collection index does not determine its final position.

C#
protected override void InsertItem(int index, DateTimeInterval item)
Parameters:indexint

The requested insertion index.

itemDateTimeInterval

The interval to insert.

Exceptions: InvalidOperationException

The interval intersects an existing interval.

Overrides: Collection<DateTimeInterval>.InsertItem(int, DateTimeInterval)

Determines whether any interval in the collection intersects the specified interval.

C#
public virtual bool IntersectsWith(DateTimeInterval dateTimeInterval)
Parameters:dateTimeIntervalDateTimeInterval

The interval to compare with the collection.

Returns:

bool

true if an intersection is found; otherwise, false.

Notifies the handler after a change and raises CollectionChanged outside an update batch.

C#
protected virtual void OnCollectionChanged(ListChangedEventArgs<DateTimeInterval> args)
Parameters:argsListChangedEventArgs<DateTimeInterval>

The applied change.

Gives the configured handler an opportunity to cancel a proposed change.

C#
protected virtual bool OnCollectionChanging(ListChangedEventArgs<DateTimeInterval> args)
Parameters:argsListChangedEventArgs<DateTimeInterval>

The proposed change.

Returns:

bool

true when the collection may apply the change; otherwise, false.

Removes the interval at the specified index unless the change handler cancels the operation.

C#
protected override void RemoveItem(int index)
Parameters:indexint

The zero-based index of the interval to remove.

Overrides: Collection<DateTimeInterval>.RemoveItem(int)

Rejects replacement of an interval at a collection index.

C#
protected override void SetItem(int index, DateTimeInterval item)
Parameters:indexint

The index of the interval to replace.

itemDateTimeInterval

The replacement interval.

Exceptions: InvalidOperationException

Indexed replacement is unsupported; add intervals through the collection's Add methods.

Overrides: Collection<DateTimeInterval>.SetItem(int, DateTimeInterval)

Events

Occurs after a collection change, or once with a reset notification when an update batch ends.

C#
public event EventHandler<ListChangedEventArgs<DateTimeInterval>> CollectionChanged