#if FRAMEWORK20 using System; using System.Collections.Generic; using System.Text; using System.Collections.ObjectModel; using System.ComponentModel; using System.Globalization; namespace DevComponents.Schedule.Model { /// /// Represents the calendar month. /// public class Month { #region Private Variables private int _Year = 0, _Month = 0; private ReadOnlyCollection _ReadOnlyDays = null; private List _Days = null; private CalendarModel _CalendarModel = null; #endregion #region Internal Implementation /// /// Initializes a new instance of the Month class. /// /// /// public Month(CalendarModel calendar, int year, int month) { _CalendarModel = calendar; _Year = year; _Month = month; } /// /// Gets collection of days in this month. /// public ReadOnlyCollection Days { get { if (_ReadOnlyDays == null) CreateDayCollection(); return _ReadOnlyDays; } } private void CreateDayCollection() { Calendar cal = _CalendarModel.GetCalendar(); int daysCount = cal.GetDaysInMonth(_Year, _Month); _Days = new List(daysCount); for (int i = 0; i < daysCount; i++) { Day day = new Day(new DateTime(_Year, _Month, i + 1), _CalendarModel); _Days.Add(day); } _ReadOnlyDays = new ReadOnlyCollection(_Days); } /// /// Gets the month year. /// [Browsable(false)] public int Year { get { return _Year; } } /// /// Gets the month. /// [Browsable(false)] public int MonthOfYear { get { return _Month; } } /// /// Gets the Calendar this day is part of. /// [Browsable(false)] public CalendarModel CalendarModel { get { return _CalendarModel; } internal set { _CalendarModel = value; } } internal void InvalidateAppointments() { if (_Days == null) return; foreach (Day day in _Days) { day.InvalidateAppointments(); } } internal void InvalidateAppointments(int day) { if (_Days == null) return; _Days[day - 1].InvalidateAppointments(); } #endregion } } #endif