private void ArrangeCalendarColumnHeaders(RadRect viewRect, ref int itemIndex)
        {
            if (!this.Calendar.AreDayNamesVisible)
            {
                return;
            }

            double previousRight  = viewRect.X;
            double cellWidth      = viewRect.Width / this.ColumnCount;
            double cellHeight     = viewRect.Y;
            int    firstDayOfWeek = (int)this.Calendar.Culture.DateTimeFormat.FirstDayOfWeek;

            for (int columnIndex = 0; columnIndex < this.ColumnCount; columnIndex++)
            {
                CalendarHeaderCellModel calendarCell = this.calendarHeaderCells[itemIndex];
                calendarCell.Type  = CalendarHeaderCellType.DayName;
                calendarCell.Label = this.GetFormattedDayName(columnIndex, firstDayOfWeek);

                double horizontalDifference = columnIndex * cellWidth - previousRight + viewRect.X;
                calendarCell.Arrange(new RadRect(previousRight, 0d, cellWidth + horizontalDifference, cellHeight));

                this.SnapToGridLines(calendarCell, -1, columnIndex);

                itemIndex++;
                previousRight = calendarCell.layoutSlot.Right;
            }
        }
Esempio n. 2
0
        private void ArrangeCalendarRowHeaders(RadRect viewRect, int itemIndex)
        {
            if (!this.Calendar.AreWeekNumbersVisible)
            {
                return;
            }

            double           previousBottom      = viewRect.Y;
            double           cellWidth           = viewRect.X;
            double           cellHeight          = viewRect.Height / this.RowCount;
            DayOfWeek        firstDayOfWeekToUse = this.Calendar.GetFirstDayOfWeek();
            CalendarWeekRule weekRuleToUse       = this.Calendar.GetCalendarWeekRule();

            DateTime weekNumberDate = new DateTime(this.Calendar.DisplayDate.Year, this.Calendar.DisplayDate.Month, 1);
            int      daysDifference = firstDayOfWeekToUse - weekNumberDate.DayOfWeek;

            if (daysDifference == 0)
            {
                weekNumberDate = weekNumberDate.AddDays(-7);
            }

            if (daysDifference <= 0)
            {
                daysDifference += 7;
            }

            int weekNumber;

            for (int rowIndex = 0; rowIndex < this.RowCount; rowIndex++)
            {
                CalendarHeaderCellModel calendarCell = this.calendarHeaderCells[itemIndex];
                calendarCell.Type = CalendarHeaderCellType.WeekNumber;

                weekNumber = this.Calendar.Culture.Calendar.GetWeekOfYear(weekNumberDate, weekRuleToUse, firstDayOfWeekToUse);

                if (weekNumberDate.AddDays(daysDifference - 1).Year > weekNumberDate.Year && weekRuleToUse == CalendarWeekRule.FirstDay)
                {
                    weekNumber = 1;
                }

                calendarCell.Label = string.Format(this.Calendar.Culture, this.Calendar.WeekNumberFormat, weekNumber);

                double verticalDifference = rowIndex * cellHeight - previousBottom + viewRect.Y;
                calendarCell.Arrange(new RadRect(0d, previousBottom, cellWidth, cellHeight + verticalDifference));

                this.SnapToGridLines(calendarCell, rowIndex, -1);

                itemIndex++;
                weekNumberDate = weekNumberDate.AddDays(7);
                previousBottom = calendarCell.layoutSlot.Bottom;
            }
        }
Esempio n. 3
0
        private void ArrangeCalendarColumnHeaders(RadRect viewRect, ref int itemIndex)
        {
            CalendarModel model = this.Calendar;

            if (!model.AreDayNamesVisible)
            {
                return;
            }

            double previousRight  = viewRect.X;
            double cellWidth      = viewRect.Width / (this.ColumnCount + (this.BufferItemsCount * 2));
            double cellHeight     = viewRect.Y;
            int    firstDayOfWeek = (int)model.Culture.DateTimeFormat.FirstDayOfWeek;

            for (int columnIndex = 0; columnIndex < this.ColumnCount + (this.BufferItemsCount * 2); columnIndex++)
            {
                CalendarHeaderCellModel calendarCell = this.calendarHeaderCells[itemIndex];
                calendarCell.Type = CalendarHeaderCellType.DayName;

                string label = string.Empty;
                if (model.DisplayMode != CalendarDisplayMode.MultiDayView)
                {
                    int dayNameIndex = (firstDayOfWeek + columnIndex) % this.ColumnCount;
                    label = this.GetFormattedDayName(dayNameIndex);
                }
                else
                {
                    CalendarCellModel cellOfHeader = this.CalendarCells.FirstOrDefault(a => a.ColumnIndex == columnIndex);
                    if (cellOfHeader != null)
                    {
                        label = this.GetFormattedDayName((int)cellOfHeader.Date.DayOfWeek);
                    }
                }

                calendarCell.Label = label;

                double horizontalDifference = columnIndex * cellWidth - previousRight + viewRect.X;
                calendarCell.Arrange(new RadRect(previousRight, 0d, cellWidth + horizontalDifference, cellHeight));

                this.SnapToGridLines(calendarCell, -1, columnIndex);

                itemIndex++;
                previousRight = calendarCell.layoutSlot.Right;
            }
        }