Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
        private string GetFormattedDayName(int dayNameIndex)
        {
            CalendarModel model = this.Calendar;

            if (model.DayNameFormat == CalendarDayNameFormat.FullName)
            {
                return(model.Culture.DateTimeFormat.DayNames[dayNameIndex]);
            }
            else if (model.DayNameFormat == CalendarDayNameFormat.FirstLetter)
            {
                string dayName = model.Culture.DateTimeFormat.DayNames[dayNameIndex];
                return(dayName.Substring(0, 1));
            }
            else
            {
                return(model.Culture.DateTimeFormat.AbbreviatedDayNames[dayNameIndex]);
            }
        }
Ejemplo n.º 3
0
        private void ArrangeTimerRuler(RadRect viewRect)
        {
            CalendarModel        model       = this.Calendar;
            MultiDayViewSettings settings    = model.multiDayViewSettings;
            DateTime             currentDate = model.DisplayDate.Date;

            double   timeWidth     = this.dayViewLayoutSlot.X - viewRect.X;
            TimeSpan timeSlotTime  = settings.DayStartTime;
            string   textToMeasure = string.Format(this.Calendar.Culture, this.Calendar.TimeFormat, currentDate.Add(timeSlotTime));
            RadSize  timeTextSize  = model.View.MeasureContent(null, textToMeasure);

            this.halfTextHeight = timeTextSize.Height / 2;

            double previousBottom = viewRect.Y - this.halfTextHeight;

            string labelText = string.Empty;
            double heightCoeff;
            double timeItemHeight;
            double oneHourTicks = (double)TimeSpan.FromHours(1).Ticks;

            for (int hourIndex = 0; hourIndex < this.timeRulerItems.Count; hourIndex++)
            {
                CalendarTimeRulerItem timerRulerItem = this.timeRulerItems[hourIndex];
                timerRulerItem.StartTime = timeSlotTime;
                timerRulerItem.Label     = labelText;

                timeSlotTime = timeSlotTime.Add(TimeSpan.FromTicks(settings.TimerRulerTickLength.Ticks));
                if (timeSlotTime > settings.DayEndTime)
                {
                    timeSlotTime = settings.DayEndTime;
                }

                timerRulerItem.EndTime = timeSlotTime;

                heightCoeff    = (timerRulerItem.EndTime - timerRulerItem.StartTime).Ticks / oneHourTicks;
                timeItemHeight = settings.TimeLinesSpacing * heightCoeff;

                timerRulerItem.Arrange(new RadRect(0f, previousBottom, timeWidth, timeItemHeight + this.halfTextHeight));
                previousBottom = timerRulerItem.layoutSlot.Bottom - this.halfTextHeight;

                labelText = string.Format(this.Calendar.Culture, this.Calendar.TimeFormat, currentDate.Add(timeSlotTime));
            }
        }
Ejemplo n.º 4
0
        private RadRect GetCalendarViewRect(RadRect availableRect)
        {
            double        dayNamesPanelHeight = 0d;
            CalendarModel calendar            = this.Calendar;

            if (calendar.AreDayNamesVisible)
            {
                dayNamesPanelHeight = calendar.View.MeasureContent(CalendarHeaderCellType.DayName, calendar.Culture.DateTimeFormat.AbbreviatedDayNames[0]).Height;
            }

            double panelWidth = 0d;

            if (calendar.DisplayMode == CalendarDisplayMode.MonthView && calendar.AreWeekNumbersVisible)
            {
                string stringToMeasure = string.Format(calendar.Culture, calendar.WeekNumberFormat, WeekNumberMeasureString);
                panelWidth = calendar.View.MeasureContent(CalendarHeaderCellType.WeekNumber, stringToMeasure).Width;
            }
            else if (calendar.DisplayMode == CalendarDisplayMode.MultiDayView)
            {
                MultiDayViewSettings settings = this.Calendar.multiDayViewSettings;
                TimeSpan             endTime  = settings.DayEndTime;
                string stringToMeasure        = string.Format(this.Calendar.Culture, this.Calendar.TimeFormat, calendar.DisplayDate.Date.Add(endTime));
                panelWidth = calendar.View.MeasureContent(null, stringToMeasure).Width;

                if (!string.IsNullOrEmpty(settings.AllDayAreaText))
                {
                    stringToMeasure = MultiDayViewSettings.DefaultAllDayText;
                    double allDayWidth = calendar.View.MeasureContent(null, stringToMeasure).Width;
                    if (allDayWidth > panelWidth)
                    {
                        panelWidth = allDayWidth;
                    }
                }
            }

            double width  = Math.Max(availableRect.Width - panelWidth, 0d);
            double height = Math.Max(availableRect.Height - dayNamesPanelHeight, 0d);

            return(new RadRect(panelWidth, dayNamesPanelHeight, width, height));
        }
Ejemplo n.º 5
0
        internal void UpdateCurrentTimeIndicator()
        {
            CalendarModel    model = this.Owner.Model;
            CalendarGridLine currentTimeIndicator = model.CurrentTimeIndicator;

            if (currentTimeIndicator != null)
            {
                if (this.viewPortArea.IntersectsWith(currentTimeIndicator.layoutSlot) && currentTimeIndicator.layoutSlot.IsSizeValid())
                {
                    if (this.currentTimeIndicatorBorder == null)
                    {
                        this.currentTimeIndicatorBorder = new Border();
                        this.AddVisualChild(this.currentTimeIndicatorBorder);
                        Canvas.SetZIndex(this.currentTimeIndicatorBorder, XamlMultiDayViewLayer.DefaultCurrentTimeIndicatorZIndex);
                    }
                    else if (this.currentTimeIndicatorBorder.Visibility == Visibility.Collapsed)
                    {
                        this.currentTimeIndicatorBorder.Visibility = Visibility.Visible;
                        Canvas.SetZIndex(this.currentTimeIndicatorBorder, XamlMultiDayViewLayer.DefaultCurrentTimeIndicatorZIndex);
                    }

                    MultiDayViewSettings settings   = model.multiDayViewSettings;
                    Style currentTimeIndicatorStyle = settings.CurrentTimeIndicatorStyle ?? settings.defaultCurrentTimeIndicatorStyle;
                    if (currentTimeIndicatorStyle != null)
                    {
                        this.currentTimeIndicatorBorder.Style = currentTimeIndicatorStyle;
                    }

                    Canvas.SetLeft(this.currentTimeIndicatorBorder, -this.leftOffset);
                    Canvas.SetTop(this.currentTimeIndicatorBorder, currentTimeIndicator.layoutSlot.Y);
                    this.currentTimeIndicatorBorder.Width = currentTimeIndicator.layoutSlot.Width;
                }
                else if (this.currentTimeIndicatorBorder?.Visibility == Visibility.Visible)
                {
                    this.currentTimeIndicatorBorder.Visibility = Visibility.Collapsed;
                    this.currentTimeIndicatorBorder.ClearValue(Canvas.ZIndexProperty);
                    this.currentTimeIndicatorBorder.ClearValue(Border.StyleProperty);
                }
            }
        }