#if FRAMEWORK20 using System.Collections.ObjectModel; namespace DevComponents.DotNetBar.Schedule { public class DisplayedOwnerCollection : Collection { #region Private variables private CalendarView _CalendarView; // Assoc CalendarView private bool _IsRangeSet; // Range set flag private bool _SuspendUpdate; #endregion /// /// Constructor /// /// CalendarView public DisplayedOwnerCollection(CalendarView calendarView) { _CalendarView = calendarView; } #region Internal properties /// /// Gets and sets the SuspendUpdate state /// internal bool SuspendUpdate { get { return (_SuspendUpdate); } set { _SuspendUpdate = value; } } #endregion #region AddRange /// /// Adds a range of Owners to the DisplayedOwner collection /// /// Array of Owners to add public void AddRange(string[] items) { int index = Count; try { _IsRangeSet = true; for (int i = 0; i < items.Length; i++) Add(items[i]); } finally { _IsRangeSet = false; _CalendarView.DisplayedOwnersAdded(index); } } #endregion #region RemoveItem /// /// Processes list RemoveItem calls /// /// Index to remove protected override void RemoveItem(int index) { base.RemoveItem(index); if (_SuspendUpdate == false) _CalendarView.DisplayedOwnersRemoved(index, index + 1); } #endregion #region InsertItem /// /// Processes list InsertItem calls /// /// Index to add /// Text to add protected override void InsertItem(int index, string item) { if (string.IsNullOrEmpty(item) == false) { base.InsertItem(index, item); if (_SuspendUpdate == false) { if (_IsRangeSet == false) _CalendarView.DisplayedOwnersAdded(index); } } } #endregion #region SetItem /// /// Processes list SetItem calls (e.g. replace) /// /// Index to replace /// Text to replace protected override void SetItem(int index, string newItem) { base.SetItem(index, newItem); if (_SuspendUpdate == false) _CalendarView.DisplayedOwnersSet(index); } #endregion #region ClearItems /// /// Processes list Clear calls (e.g. remove all) /// protected override void ClearItems() { if (Count > 0) { int n = Count; base.ClearItems(); _CalendarView.DisplayedOwnersRemoved(0, n); } } #endregion } } #endif