public static void Draw(SKSurface surface, SKImageInfo info, CalendarMonthModel calendarMonth) { var canvas = surface.Canvas; canvas.Clear(SKColors.White); var gridSize = calendarMonth.GridSize; var dateTime = new DateTime(calendarMonth.Year, calendarMonth.Month, 1); var date = dateTime.AddDays(-dateTime.Day + 1); using (var textPaint = new SKPaint()) { using (var paint = new SKPaint()) { using (var path = new SKPath()) { foreach (var calendarDay in calendarMonth.Days) { if (calendarMonth.HighlightedDays?.Count() > 0) { foreach (var highlightDay in calendarMonth.HighlightedDays) { if (highlightDay.Day == calendarDay.DateTime.Day && calendarDay.DateTime.Month == calendarMonth.Month) { calendarDay.Type = highlightDay.Type; } } } DrawCalendarDay(canvas, textPaint, paint, path, calendarDay, calendarMonth.Month == calendarDay.DateTime.Month); } } } } canvas.Flush(); }
public void Draw(SKSurface surface, SKImageInfo info) { var highlightedDays = this.HighlightedDates.TakeWhile(date => { if (date.Year == Date.Year && date.Month == Date.Month) { return(true); } return(false); }).Select(date => date.Day); Model = CalendarMonthModel.Create(this.Date.Year, this.Date.Month, highlightedDays, info.Width, info.Height); CalendarMonthRenderer.Draw(surface, info, Model); }
public static void Draw(SKSurface surface, SKImageInfo info, CalendarMonthModel calendarMonth) { var canvas = surface.Canvas; canvas.Clear(SKColors.White); var gridSize = calendarMonth.GridSize; var dateTime = new DateTime(calendarMonth.Year, calendarMonth.Month, 1); var date = dateTime.AddDays(-dateTime.Day + 1); using (var textPaint = new SKPaint()) { using (var paint = new SKPaint()) { using (var path = new SKPath()) { DrawText(canvas, textPaint, text: date.ToString("Y"), x: info.Width / 2, y: gridSize, fontSize: gridSize / 4); foreach (var calendarDay in calendarMonth.Days) { foreach (var highlightDay in calendarMonth.HighlightedDays) { if (highlightDay == calendarDay.DateTime.Day) { calendarDay.IsHighlighted = true; } } DrawCalendarDay(canvas, textPaint, paint, path, calendarDay); } } } } canvas.Flush(); }
public CalendarMonthControl() { Date = DateTime.Now; HighlightedDates = new DateTime[] { }; Model = CalendarMonthModel.Create(this.Date.Year, this.Date.Month, new int[] { }, 0, 0); }