#if FRAMEWORK20
using System;
using System.Drawing;
namespace DevComponents.DotNetBar.Schedule
{
    public class DaysOfTheWeek
    {
        #region enums
        public enum eDayType
        {
            Long,       // Long text
            Short,      // Short text
            Single,
            None
        }
        #endregion
        #region Private variables
        private int _DayCount;          // Count of days
        private string[][] _DayText;    // Days of the week text
        private Size[][] _DaySize;      // Days of the week measure
        private bool _NeedsMeasured;    // Text measure flag
        #endregion
        /// 
        /// Constructor
        /// 
        public DaysOfTheWeek()
            : this(DateHelper.GetFirstDayOfWeek(), 7)
        {
        }
        /// 
        /// Constructor
        /// 
        /// Day of the week
        /// Count of days
        public DaysOfTheWeek(DayOfWeek day, int count)
        {
            LoadDays(day, count);
        }
        #region Public properties
        /// 
        /// Gets the DayText string arrays
        /// 
        public string[][] DayText
        {
            get { return (_DayText); }
        }
        /// 
        /// Gets the DaySize Size arrays
        /// 
        public Size[][] DaySize
        {
            get {return (_DaySize); }
        }
        /// 
        /// Day text NeedsMeasured flag
        /// 
        public bool NeedsMeasured
        {
            get { return (_NeedsMeasured); }
            set { _NeedsMeasured = value; }
        }
        #endregion
        #region LoadDays
        /// 
        /// Loads the DayText arrays
        /// 
        /// Starting day of week
        /// Count of days
        public void LoadDays(DayOfWeek day, int count)
        {
            _DayCount = count;
            // Allocate our Day text and Size arrays
            _DayText = new string[3][];
            _DaySize = new Size[3][];
            for (int i = 0; i < 3; i++)
            {
                _DayText[i] = new string[count];
                _DaySize[i] = new Size[count];
            }
            // Loop through each day of the week, getting
            // the long and short text strings for the day
            for (int i = 0; i < _DayCount; i++)
            {
                _DayText[0][i] =
                    ScheduleSettings.GetActiveCulture().DateTimeFormat.GetDayName(day);
                _DayText[1][i] =
                    DateHelper.GetThreeLetterDayOfWeek(day);
                _DayText[2][i] = _DayText[1][i].Substring(0, 1);
                day = DateHelper.GetNextDay(day);
            }
            // Flag that the text will need to be measured
            _NeedsMeasured = true;
        }
        #endregion
        #region MeasureText
        /// 
        /// Measures the day text
        /// 
        /// Graphics
        /// Text font
        public void MeasureText(Graphics g, Font font)
        {
            // Calculate our header text threshold, if
            // we haven't done so already
            if (_NeedsMeasured == true)
            {
                for (int i = 0; i < _DayCount; i++)
                {
                    _DaySize[0][i] =
                        TextDrawing.MeasureString(g, _DayText[0][i], font);
                    _DaySize[1][i] =
                        TextDrawing.MeasureString(g, _DayText[1][i], font);
                    _DaySize[2][i] =
                        TextDrawing.MeasureString(g, _DayText[2][i], font);
                }
                _NeedsMeasured = false;
            }
        }
        #endregion
    }
}
#endif