private void PaintAllEvents(DateTime dt)
 {
     if (controls.ContainsKey(dt.Date))
     {
         MonthDay mD = controls[dt.Date];
         mD.Events = EventsToShow.Where(e => e.Start.Date == dt.Date).ToList();
     }
 }
 private void PaintAllDayEvents()
 {
     foreach (DateTime dt in controls.Keys)
     {
         if (controls.ContainsKey(dt.Date))
         {
             MonthDay mD = controls[dt.Date];
             mD.Events = EventsToShow.Where(e => e.Start.Date <= dt.Date && e.End.Date >= dt.Date).ToList();
         }
     }
 }
        private void PaintMonth()
        {
            DateTime dt           = CurrentMonth;
            int      currentMonth = dt.Month;

            while (dt.DayOfWeek != DayOfWeek.Monday)
            {
                dt = dt.AddDays(-1);
            }

            EventsGrid.Children.Clear();
            EventsGrid.RowDefinitions.Clear();
            controls.Clear();

            // Start painting
            int currentRow = -1;

            firstDay = dt;
            while ((dt.Month <= currentMonth && dt.Year == CurrentMonth.Year) ||
                   (dt.Year < CurrentMonth.Year) ||
                   dt.DayOfWeek != DayOfWeek.Monday)
            {
                if (dt.DayOfWeek == DayOfWeek.Monday)
                {
                    RowDefinition rd = new RowDefinition();
                    EventsGrid.RowDefinitions.Add(rd);
                    currentRow++;
                }
                MonthDay uc = new MonthDay(dt, currentMonth == dt.Month);
                Grid.SetRow(uc, currentRow);
                Grid.SetColumn(uc, DayOfWeekToInt(dt.DayOfWeek));
                EventsGrid.Children.Add(uc);

                uc.OnScheduleDoubleClick += ((object sender, DateTime e) =>
                {
                    OnScheduleDoubleClick(sender, e);
                });

                uc.OnEventDoubleClick += ((object sender, Event e) =>
                {
                    OnEventDoubleClick(sender, e);
                });

                controls.Add(dt.Date, uc);
                dt = dt.AddDays(1);
            }
            lastDay = dt;
        }