private void GenerateDayElements()
        {
            dayElements = new List <MonthDayElement>();
            for (int i = 0; i < numberOfCellsInGrid; i++)
            {
                int   candidateDayNumber          = i - GetfirstDayGridColumnIndex() + iterationIndexOffset;
                Point dayElementGridCoordinates   = GetGridCoordinatesByIterationIndex(i);
                bool  isDayNumberInDisplayedMonth = IsDayNumberInDisplayedMonth(candidateDayNumber, dayElementGridCoordinates);

                if (isDayNumberInDisplayedMonth)
                {
                    int      year           = Utilities.DisplayedDate.Year;
                    int      month          = Utilities.DisplayedDate.Month;
                    int      day            = candidateDayNumber;
                    DateTime dayElementDate = new DateTime(year, month, day);

                    MonthDayElement monthDayElement = new MonthDayElement(dayElementDate);
                    monthDayElement.SetValue(Grid.ColumnProperty, (int)dayElementGridCoordinates.X);
                    monthDayElement.SetValue(Grid.RowProperty, (int)dayElementGridCoordinates.Y);

                    dayElements.Add(monthDayElement);
                }
                else
                {
                    MonthDayElement monthDayElementBlank = new MonthDayElement();
                    monthDayElementBlank.SetValue(Grid.ColumnProperty, (int)dayElementGridCoordinates.X);
                    monthDayElementBlank.SetValue(Grid.RowProperty, (int)dayElementGridCoordinates.Y);

                    dayElements.Add(monthDayElementBlank);
                }
            }
        }
        private List <Appointment> GetDayAppointments(MonthDayElement dayElement)
        {
            List <Appointment> dayElementAppointments = new List <Appointment>();

            foreach (Appointment appointment in monthAppointmens)
            {
                bool hasReadPermission = appointment.HasReadPermissions(SessionController.CurrenUser);
                bool isOfTheDayElement = IsAppointmentOfDay(appointment, dayElement);

                if (isOfTheDayElement & hasReadPermission)
                {
                    dayElementAppointments.Add(appointment);
                }
            }

            return(dayElementAppointments);
        }
 private void HighLightWeekends()
 {
     foreach (var child in BodyGrid.Children)
     {
         if (IsDayElement(child))
         {
             MonthDayElement dayElementChild  = child as MonthDayElement;
             int             childColumnIndex = (int)dayElementChild.GetValue(Grid.ColumnProperty);
             if (IsInWeekendColumn(childColumnIndex))
             {
                 dayElementChild.Foreground = highlightColor;
             }
         }
         else if (IsWeekDayNameElement(child))
         {
             TextBlock textBlockDayNameElement = child as TextBlock;
             int       childrenColumnIndex     = (int)textBlockDayNameElement.GetValue(Grid.ColumnProperty);
             if (IsInWeekendColumn(childrenColumnIndex))
             {
                 textBlockDayNameElement.Foreground = highlightColor;
             }
         }
     }
 }
        private static bool IsAppointmentOfDay(Appointment appointment, MonthDayElement dayElement)
        {
            bool areTheSameDate = appointment.Start.Date == dayElement.Date.Date;

            return(areTheSameDate);
        }