#if FRAMEWORK20 using System; using System.Collections.Generic; namespace DevComponents.DotNetBar.Schedule { public class CalendarViewCollection where T : BaseView { #region Private variables private CalendarView _CalendarView; // Assoc CalendarView private List _Views = new List(); // BaseView items #endregion /// /// Constructor /// /// CalendarView public CalendarViewCollection(CalendarView calendarView) { _CalendarView = calendarView; } #region Public properties /// /// Gets the count of items in the collection /// public int Count { get { return (_Views.Count); } } /// /// Gets the view at the given index /// /// Index /// Requested view public T this[int index] { get { return (GetView(index)); } } /// /// Gets the view for the given DisplayedOwner /// /// DisplayedOwner /// Requested view public T this[string key] { get { return (GetView(FindDisplayedOwner(key))); } } /// /// Locates the view index from the given /// DisplayedOwner text /// /// DisplayedOwner /// View index, or -1 if not found private int FindDisplayedOwner(string key) { for (int i = 0; i < _CalendarView.DisplayedOwners.Count; i++) { if (_CalendarView.DisplayedOwners[i].Equals(key)) return (i); } return (-1); } /// /// Returns the given view at the specified index. /// /// This routine will initiate the creation /// of the view if it has not previously been created. /// /// Index /// Requested view private T GetView(int index) { if (index >= 0 && index < _Views.Count) { if (_Views[index] == null) { Type type = typeof(T); _Views[index] = (T)_CalendarView.NewView(type, index); } return (_Views[index]); } return (default(T)); } #endregion #region Internal properties /// /// Gets the collection view list /// internal List Views { get { return (_Views); } } #endregion } } #endif