AC.AvalonControlsLibrary.Controls.DatePicker.ReBindListOfDays C# (CSharp) Метод

ReBindListOfDays() приватный метод

private ReBindListOfDays ( ) : void
Результат void
        void ReBindListOfDays()
        {
            if (datesList != null)
            {
                //Please note that the DateHelper.GetDaysOfMonth gets the days from a cache so it will not have a performance hit to call it everytime
                int numberOfDaysFromPreviousMonth =
                    (int)DateHelper.GetDayOfWeek(currentlyViewedYear, currentlyViewedMonth, 1);

                DayCell[] newDaysTemp = dateHelper.GetDaysOfMonth(currentlyViewedMonth, currentlyViewedYear, MinDate, MaxDate);
                //get the last day of the month and determine the number of days to show from next month
                int numberOfDaysFromNextMonth = 6 - (int)DateHelper.GetDayOfWeek(currentlyViewedYear, currentlyViewedMonth, newDaysTemp[newDaysTemp.Length - 1].DayNumber);
                DayCell[] newDays = new DayCell[newDaysTemp.Length + numberOfDaysFromNextMonth];
                int monthToGetNext;
                int yearTogetNext;
                //get the next month
                DateHelper.MoveMonthForward(currentlyViewedMonth, currentlyViewedYear, out monthToGetNext, out yearTogetNext);
                //get the data for next month
                DayCell[] nextDays = dateHelper.GetDaysOfMonth(monthToGetNext, yearTogetNext, MinDate, MaxDate);//get the next month
                newDaysTemp.CopyTo(newDays, 0);//copy the new days array
                Array.Copy(nextDays, 0, newDays, newDaysTemp.Length, newDays.Length - newDaysTemp.Length);

                DayCell[] listOfDays = new DayCell[numberOfDaysFromPreviousMonth + newDays.Length];
                int monthToGetPrevious;
                int yearTogetPrevious;
                //move one month back
                DateHelper.MoveMonthBack(currentlyViewedMonth, currentlyViewedYear, out monthToGetPrevious, out yearTogetPrevious);
                DayCell[] oldDays = dateHelper.GetDaysOfMonth(monthToGetPrevious, yearTogetPrevious, MinDate, MaxDate);//get the previous month
                Array.Copy(oldDays, oldDays.Length - numberOfDaysFromPreviousMonth, listOfDays, 0, numberOfDaysFromPreviousMonth);
                Array.Copy(newDays, 0, listOfDays, numberOfDaysFromPreviousMonth, newDays.Length);

                //set the item source to the days to show
                datesList.ItemsSource = listOfDays;

                foreach (var day in listOfDays)
                {
                    if (day.YearNumber == CurrentlySelectedDate.Year &&
                        day.MonthNumber == CurrentlySelectedDate.Month &&
                        day.DayNumber == CurrentlySelectedDate.Day)
                    {
                        datesList.SelectedItem = day;
                    }
                }
            }
        }