コード例 #1
0
ファイル: CalendarWeek.cs プロジェクト: ssickles/archive
        public CalendarWeek(int Year, int Month, int WeekNumber)
        {
            _year = Year;
            _month = Month;
            _week = WeekNumber;

            _days = new List<CalendarDay>();

            DateTime startDate = new DateTime(Year, Month, 1);
            DayOfWeek firstDay = startDate.DayOfWeek;
            for (int i = 0; i < 7; i++)
            {
                DateTime newDate = startDate.AddDays(((WeekNumber - 1) * 7) - (int)firstDay + i);
                CalendarDay day = new CalendarDay(newDate.Year, newDate.Month, newDate.Day);
                _days.Add(day);
            }
        }
コード例 #2
0
ファイル: CalendarControl.cs プロジェクト: ssickles/archive
 private void InitCalendarDays()
 {
     switch (CalendarMode)
     {
         case CalendarControlMode.Day:
             _day = new CalendarDay(_currentDate.Year, _currentDate.Month, _currentDate.Day);
             break;
         case CalendarControlMode.Week:
             _week = new CalendarWeek(_currentDate.Year, _currentDate.Month, WeekFromDay(_currentDate.Year, _currentDate.Month, _currentDate.Day));
             break;
         case CalendarControlMode.Month:
             int weeksInMonth = WeeksInMonth(_currentDate.Year, _currentDate.Month);
             _weeks = new List<CalendarWeek>();
             for (int i = 1; i <= weeksInMonth; i++)
             {
                 _weeks.Add(new CalendarWeek(_currentDate.Year, _currentDate.Month, i));
             }
             break;
     }
 }