Пример #1
0
        private static void DrawAllWeekdayInMonth(MyCalendar calendar, DayOfWeek dayOfWeek, int col)
        {
            var row = 0;

            if (calendar.Calendar[dayOfWeek].First() > 1 &&
                (dayOfWeek < calendar.FirstDay().DayOfWeek&& dayOfWeek != DayOfWeek.Sunday ||
                 calendar.FirstDay().DayOfWeek == DayOfWeek.Sunday))
            {
                DrawDay(row, col, "", Brushes.WhiteSmoke);
                row++;
            }


            foreach (var day in calendar.Calendar[dayOfWeek])
            {
                DrawDay(row, col, day.ToString(),
                        day == calendar.Date.Day ? new SolidBrush(Color.FromArgb(225, 225, 225)) : Brushes.WhiteSmoke);
                row++;
            }


            if (calendar.LastDay().DayOfWeek != DayOfWeek.Sunday && calendar.Calendar[dayOfWeek].Last() < calendar.LastDay().Day&&
                (dayOfWeek > calendar.LastDay().DayOfWeek || dayOfWeek == DayOfWeek.Sunday))
            {
                DrawDay(row, col, "", Brushes.WhiteSmoke);
            }
        }
Пример #2
0
 private static void DrawDays(MyCalendar calendar)
 {
     for (var col = 0; col < calendar.Calendar.Keys.Count; col++)
     {
         DrawAllWeekdayInMonth(calendar, calendar.Calendar.Keys.ElementAt(col), col);
     }
 }
Пример #3
0
 private static void DrawDaysOfWeek(MyCalendar calendar)
 {
     for (var col = 0; col < 7; col++)
     {
         DrawDayOfWeek(col, calendar.Calendar.Keys.ElementAt(col));
     }
 }
Пример #4
0
        private static void DrawDate(MyCalendar calendar)
        {
            var thisDate = new RectangleF(Left, Top, CalendarWidth, DateHeight);

            G.FillRectangle(new SolidBrush(Color.FromArgb(3, 201, 169)), thisDate);
            G.DrawString(calendar.Date.Day.ToString(), new Font("Helvetica", 60), Brushes.White, thisDate, SFormat);
        }
Пример #5
0
        public UICalendar()
        {
            InitializeComponent();
            MyCalendar calendar = new MyCalendar();

            calendar.Location = new Point(0, 0);
            Controls.Add(calendar);
        }
Пример #6
0
        private static void DrawMonth(MyCalendar calendar)
        {
            var thisMonth = new RectangleF(Left, Top + DateHeight, CalendarWidth, MonthHeight);

            G.FillRectangle(Brushes.White, thisMonth);
            G.DrawString(calendar.Date.ToString("MMMM", CultureInfo.GetCultureInfo("en-us")) + ", " + calendar.Date.Year.ToString(),
                         new Font("Helvetica", 30), Brushes.Turquoise, thisMonth, SFormat);
        }
Пример #7
0
 public void DrawCalendar(MyCalendar calendar)
 {
     DrawBackground();
     DrawDate(calendar);
     DrawMonth(calendar);
     DrawDaysOfWeek(calendar);
     DrawDays(calendar);
     Bmp.Save("calendar.png");
 }
Пример #8
0
        static void Main(string[] args)
        {
            var inputDate = new int[3];

            inputDate = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var date = new DateTime(inputDate[2], inputDate[1], inputDate[0]);

            var calendar = new MyCalendar(date);

            var calendarDrawer = new CalendarDrawer();

            calendarDrawer.DrawCalendar(calendar);
        }