#if FRAMEWORK20
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
namespace DevComponents.Schedule.Model
{
///
/// Represents collection of reminders.
///
public class ReminderCollection : Collection
{
#region Constructor
///
/// Initializes a new instance of the ReminderCollection class.
///
///
public ReminderCollection(Appointment parent)
{
_Appointment = parent;
}
CalendarModel _Model = null;
///
/// Initializes a new instance of the ReminderCollection class.
///
///
public ReminderCollection(CalendarModel parentModel)
{
_Model = parentModel;
}
#endregion
#region Internal Implementation
protected override void InsertItem(int index, Reminder item)
{
OnBeforeInsert(index, item);
base.InsertItem(index, item);
}
private void OnBeforeInsert(int index, Reminder item)
{
item.Appointment = _Appointment;
item.ParentCollection = this;
}
protected override void SetItem(int index, Reminder item)
{
OnBeforeSetItem(index, item);
base.SetItem(index, item);
}
private void OnBeforeSetItem(int index, Reminder item)
{
this[index].Appointment = null;
this[index].ParentCollection = null;
item.Appointment = _Appointment;
item.ParentCollection = this;
}
protected override void RemoveItem(int index)
{
OnBeforeRemove(index);
base.RemoveItem(index);
}
private void OnBeforeRemove(int index)
{
this[index].Appointment = null;
this[index].ParentCollection = null;
}
protected override void ClearItems()
{
foreach (Reminder item in this)
{
item.Appointment = null;
}
base.ClearItems();
}
private Appointment _Appointment;
///
/// Gets parent appointment.
///
public Appointment Appointment
{
get { return _Appointment; }
internal set
{
_Appointment = value;
}
}
///
/// Gets parent model if collection is custom reminders collection.
///
public CalendarModel ParentModel
{
get { return _Model; }
internal set { _Model = value; }
}
#endregion
}
}
#endif