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); } }
private static void DrawDays(MyCalendar calendar) { for (var col = 0; col < calendar.Calendar.Keys.Count; col++) { DrawAllWeekdayInMonth(calendar, calendar.Calendar.Keys.ElementAt(col), col); } }
private static void DrawDaysOfWeek(MyCalendar calendar) { for (var col = 0; col < 7; col++) { DrawDayOfWeek(col, calendar.Calendar.Keys.ElementAt(col)); } }
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); }
public UICalendar() { InitializeComponent(); MyCalendar calendar = new MyCalendar(); calendar.Location = new Point(0, 0); Controls.Add(calendar); }
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); }
public void DrawCalendar(MyCalendar calendar) { DrawBackground(); DrawDate(calendar); DrawMonth(calendar); DrawDaysOfWeek(calendar); DrawDays(calendar); Bmp.Save("calendar.png"); }
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); }