상속: Telerik.UI.Xaml.Controls.Input.Calendar.CalendarNode
예제 #1
0
        internal void EnsureCalendarHeaderCells()
        {
            if (this.calendarHeaderCells == null)
            {
                this.calendarHeaderCells = new ElementCollection <CalendarHeaderCellModel>(this);
            }

            if (this.calendarHeaderCells.Count == 0)
            {
                int itemCount = this.ColumnCount + this.RowCount + (this.BufferItemsCount * 2);
                for (int cellIndex = 0; cellIndex < itemCount; cellIndex++)
                {
                    CalendarHeaderCellModel cell = new CalendarHeaderCellModel();

                    this.calendarHeaderCells.Add(cell);
                }
            }
            else
            {
                foreach (CalendarHeaderCellModel cell in this.calendarHeaderCells)
                {
                    cell.layoutSlot = RadRect.Empty;
                }
            }
        }
예제 #2
0
        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;
            }
        }
예제 #3
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;
            }
        }
예제 #4
0
        public XamlDecorationLayer()
        {
            this.decorationPanel = new Canvas();

            this.recycledContainers = new Queue <Border>();
            this.realizedCalendarCellDecorationPresenters = new Dictionary <CalendarNode, Border>();

            // We need dictionary keys for the additional line decorations we are drawing for the day names and week numbers;
            this.dayNamesLineModel = new CalendarHeaderCellModel()
            {
                Type = CalendarHeaderCellType.DayName
            };
            this.weekNumbersLineModel = new CalendarHeaderCellModel()
            {
                Type = CalendarHeaderCellType.WeekNumber
            };
        }
예제 #5
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;
            }
        }
예제 #6
0
        private void UpdateCalendarHeaderGridLineDecorations()
        {
            if (this.Owner.Model.CalendarHeaderCells == null)
            {
                this.dayNamesLineSlot    = RadRect.Empty;
                this.weekNumbersLineSlot = RadRect.Empty;

                return;
            }

            if (this.Owner.DayNamesVisibility == Visibility.Visible)
            {
                Border dayNamesBottomDecorationLine = this.GetCalendarDecorationVisual(this.dayNamesLineModel, CalendarDecorationType.GridLine);
                if (dayNamesBottomDecorationLine != null)
                {
                    CalendarHeaderCellModel dayNameCell = this.GetFirstDayNameCell();
                    this.dayNamesLineSlot = new RadRect(0d, dayNameCell.LayoutSlot.Bottom - this.Owner.GridLinesThickness, this.Owner.CalendarViewSize.Width, this.Owner.GridLinesThickness);
                    CalendarLayer.ArrangeUIElement(dayNamesBottomDecorationLine, this.dayNamesLineSlot);
                    Canvas.SetZIndex(dayNamesBottomDecorationLine, DefaultGridLineDecorationZIndex);
                }
            }
            else
            {
                this.dayNamesLineSlot = RadRect.Empty;
            }

            if (this.Owner.WeekNumbersVisibility == Visibility.Visible)
            {
                Border weekNumbersRightDecorationLine = this.GetCalendarDecorationVisual(this.weekNumbersLineModel, CalendarDecorationType.GridLine);
                if (weekNumbersRightDecorationLine != null)
                {
                    CalendarHeaderCellModel weekNumberCell = this.GetFirstWeekNumberCell();
                    this.weekNumbersLineSlot = new RadRect(weekNumberCell.LayoutSlot.Right - this.Owner.GridLinesThickness, 0d, this.Owner.GridLinesThickness, this.Owner.CalendarViewSize.Height);
                    CalendarLayer.ArrangeUIElement(weekNumbersRightDecorationLine, this.weekNumbersLineSlot);
                    Canvas.SetZIndex(weekNumbersRightDecorationLine, DefaultGridLineDecorationZIndex);
                }
            }
            else
            {
                this.weekNumbersLineSlot = RadRect.Empty;
            }
        }