private void EnsureTimeRulerLines() { if (this.timerRulerLines == null || this.timerRulerLines.Count == 0) { if (this.timerRulerLines == null) { this.timerRulerLines = new ElementCollection <CalendarGridLine>(this); } int step = this.timeRulerItems.Count; for (int timeRulerLine = 0; timeRulerLine < step - 1; timeRulerLine++) { CalendarGridLine rulerLine = new CalendarGridLine(); rulerLine.IsHorizontal = true; this.timerRulerLines.Add(rulerLine); } } else { foreach (CalendarGridLine rulerLine in this.timerRulerLines) { rulerLine.layoutSlot = RadRect.Empty; } } }
private void ArrangeCalendarDecorations(RadRect rect) { this.EnsureCalendarDecorations(); double cellWidth = rect.Width / this.ColumnCount; double cellHeight = rect.Height / this.RowCount; double gridLineThickness = this.Calendar.GridLinesThickness; int gridLineHalfThickness = (int)(gridLineThickness / 2); if ((this.Calendar.GridLinesVisibility & GridLinesVisibility.Horizontal) == GridLinesVisibility.Horizontal) { for (int rowIndex = 1; rowIndex < this.RowCount; rowIndex++) { CalendarGridLine gridLine = this.GetDecorationByRowIndex(rowIndex); gridLine.IsHorizontal = true; // NOTE: We are not respecting rect.X / rect.Width values here for design purposes: // If week numbers are visible the horizontal gridline should start rendering from the week number panel and not the calendar view. gridLine.Arrange(new RadRect(this.layoutSlot.X, rect.Y + rowIndex * cellHeight - gridLineHalfThickness, this.layoutSlot.Width, gridLineThickness)); } } if ((this.Calendar.GridLinesVisibility & GridLinesVisibility.Vertical) == GridLinesVisibility.Vertical) { for (int columnIndex = 1; columnIndex < this.ColumnCount; columnIndex++) { CalendarGridLine gridLine = this.GetDecorationByColumnIndex(columnIndex); gridLine.IsHorizontal = false; gridLine.Arrange(new RadRect(rect.X + columnIndex * cellWidth - gridLineHalfThickness, rect.Y, gridLineThickness, rect.Height)); } } }
private void ArrangeMultiDayViewCalendarDecorations(RadRect rect) { if (this.horizontalLowerAllDayAreaRulerGridLine == null && this.verticalRulerGridLine == null && this.horizontalUpperAllDayAreaRulerGridLine == null) { this.horizontalLowerAllDayAreaRulerGridLine = new CalendarGridLine(); this.horizontalLowerAllDayAreaRulerGridLine.root = this.root; this.horizontalLowerAllDayAreaRulerGridLine.IsHorizontal = true; this.horizontalUpperAllDayAreaRulerGridLine = new CalendarGridLine(); this.horizontalUpperAllDayAreaRulerGridLine.root = this.root; this.horizontalUpperAllDayAreaRulerGridLine.IsHorizontal = true; this.horizontalTopHeaderRulerGridLine = new CalendarGridLine(); this.horizontalTopHeaderRulerGridLine.root = this.root; this.horizontalTopHeaderRulerGridLine.IsHorizontal = true; this.verticalRulerGridLine = new CalendarGridLine(); this.verticalRulerGridLine.root = this.root; } double cellHeight = rect.Height / this.SpecificColumnCount; double gridLineThickness = this.Calendar.GridLinesThickness; int gridLineHalfThickness = (int)(gridLineThickness / 2); this.horizontalTopHeaderRulerGridLine.Arrange(new RadRect(this.layoutSlot.X, rect.Y, this.layoutSlot.Width, gridLineThickness)); this.horizontalUpperAllDayAreaRulerGridLine.Arrange(new RadRect(this.layoutSlot.X, rect.Y + cellHeight, this.layoutSlot.Width, gridLineThickness)); this.horizontalLowerAllDayAreaRulerGridLine.Arrange(new RadRect(this.layoutSlot.X, rect.Y + cellHeight + this.totalAllDayAreaHeight + gridLineThickness / 2, this.layoutSlot.Width, 0)); this.verticalRulerGridLine.Arrange(new RadRect(rect.X, rect.Y, gridLineThickness, rect.Height)); }
private void LayoutLowerAllDayAreaHorizontalBorder(CalendarGridLine horizontalAllDayLowerLine) { MultiDayViewSettings settings = this.Owner.MultiDayViewSettings; Style allDayAreaBorderStyle = settings.AllDayAreaBorderStyle ?? settings.defaultAllDayAreaBorderStyle; if (allDayAreaBorderStyle != null) { this.horizontalLowerGridLineBorder.Style = allDayAreaBorderStyle; } if (!XamlDecorationLayer.IsStrokeBrushExplicitlySet(this.horizontalLowerGridLineBorder.Style)) { this.horizontalLowerGridLineBorder.BorderBrush = this.Owner.GridLinesBrush; } if (this.horizontalLowerGridLineBorder.BorderBrush != null && !XamlDecorationLayer.IsStrokeThicknessExplicitlySet(this.horizontalLowerGridLineBorder.Style)) { this.horizontalLowerGridLineBorder.BorderThickness = new Thickness(this.Owner.GridLinesThickness); } RadRect layoutSlot = horizontalAllDayLowerLine.layoutSlot; layoutSlot.Height = this.horizontalLowerGridLineBorder.BorderThickness.Left; XamlMultiDayViewLayer.ArrangeUIElement(this.horizontalLowerGridLineBorder, layoutSlot, true); }
internal virtual void EnsureCalendarDecorations() { if (this.calendarDecorations == null || this.calendarDecorations.Count == 0) { if (this.calendarDecorations == null) { this.calendarDecorations = new ElementCollection <CalendarGridLine>(this); } // we are generating models only for the inner horizontal and vertical gridlnes as // first / last horizontal and vertical grid lines are drawn by RadCalendar border elements. int decorationCount = this.RowCount + this.ColumnCount - 2 + (this.BufferItemsCount * 2); for (int decorationIndex = 0; decorationIndex < decorationCount; decorationIndex++) { CalendarGridLine gridLine = new CalendarGridLine(); this.calendarDecorations.Add(gridLine); } } else { foreach (CalendarGridLine gridLine in this.calendarDecorations) { gridLine.layoutSlot = RadRect.Empty; } } }
internal void UpdateTimeRulerDecorations(CalendarMultiDayViewModel model, bool areDayNamesVisible) { CalendarGridLine horizontalAllDayLowerLine = model.horizontalLowerAllDayAreaRulerGridLine; CalendarGridLine horizontalAllDayUpperLine = model.horizontalUpperAllDayAreaRulerGridLine; CalendarGridLine horizontalTopHeaderLine = model.horizontalTopHeaderRulerGridLine; CalendarGridLine verticalLine = model.verticalRulerGridLine; if (this.horizontalLowerGridLineBorder == null) { this.horizontalLowerGridLineBorder = new Border(); this.topLeftHeaderPanel.Children.Add(this.horizontalLowerGridLineBorder); } if (this.horizontaUpperGridLineBorder == null) { this.horizontaUpperGridLineBorder = new Border(); this.topLeftHeaderPanel.Children.Add(this.horizontaUpperGridLineBorder); } if (this.horizontaTopHeaderGridLineBorder == null) { this.horizontaTopHeaderGridLineBorder = new Border(); this.topLeftHeaderPanel.Children.Add(this.horizontaTopHeaderGridLineBorder); } if (areDayNamesVisible && this.horizontaTopHeaderGridLineBorder.Visibility == Visibility.Collapsed) { this.horizontaTopHeaderGridLineBorder.Visibility = Visibility.Visible; } else if (!areDayNamesVisible && this.horizontaTopHeaderGridLineBorder.Visibility == Visibility.Visible) { this.horizontaTopHeaderGridLineBorder.Visibility = Visibility.Collapsed; } if (this.verticalGridLineBorder == null) { this.verticalGridLineBorder = new Border(); this.topLeftHeaderPanel.Children.Add(this.verticalGridLineBorder); } this.LayoutTopAllDayAreaHorizontalBorder(horizontalAllDayUpperLine); this.LayoutLowerAllDayAreaHorizontalBorder(horizontalAllDayLowerLine); this.LayoutTopHeaderHorizontalBorder(horizontalTopHeaderLine); this.LayoutVerticalHeaderBorder(verticalLine); }
private void LayoutTopAllDayAreaHorizontalBorder(CalendarGridLine horizontalAllDayUpperLine) { this.ApplyTimeRulerStyle(horizontalAllDayUpperLine, this.horizontaUpperGridLineBorder); if (!XamlDecorationLayer.IsStrokeBrushExplicitlySet(this.horizontaUpperGridLineBorder.Style)) { this.horizontaUpperGridLineBorder.BorderBrush = this.Owner.GridLinesBrush; } if (this.horizontaUpperGridLineBorder.BorderBrush != null && !XamlDecorationLayer.IsStrokeThicknessExplicitlySet(this.horizontaUpperGridLineBorder.Style)) { this.horizontaUpperGridLineBorder.BorderThickness = new Thickness(this.Owner.GridLinesThickness); } RadRect layoutSlot = horizontalAllDayUpperLine.layoutSlot; XamlMultiDayViewLayer.ArrangeUIElement(this.horizontaUpperGridLineBorder, layoutSlot, true); }
private void LayoutVerticalHeaderBorder(CalendarGridLine verticalLine) { this.ApplyTimeRulerStyle(verticalLine, this.verticalGridLineBorder); if (!XamlDecorationLayer.IsStrokeBrushExplicitlySet(this.verticalGridLineBorder.Style)) { this.verticalGridLineBorder.BorderBrush = this.Owner.GridLinesBrush; } if (this.verticalGridLineBorder.BorderBrush != null && !XamlDecorationLayer.IsStrokeThicknessExplicitlySet(this.verticalGridLineBorder.Style)) { this.verticalGridLineBorder.BorderThickness = new Thickness(this.Owner.GridLinesThickness); } RadRect layoutSlot = verticalLine.layoutSlot; XamlMultiDayViewLayer.ArrangeUIElement(this.verticalGridLineBorder, layoutSlot, true); }
private void SnapToBottomGridLine(CalendarNode calendarCell, int rowIndex) { if (rowIndex >= this.RowCount - 1 || rowIndex < 0) { return; } CalendarGridLine gridLine = this.GetDecorationByRowIndex(rowIndex + 1); if (!gridLine.layoutSlot.IsSizeValid()) { return; } double difference = gridLine.layoutSlot.Y - calendarCell.layoutSlot.Bottom; calendarCell.layoutSlot.Height += difference; }
private void SnapToRightGridLine(CalendarNode calendarCell, int columnIndex) { if (columnIndex >= this.ColumnCount - 1 || columnIndex < 0) { return; } CalendarGridLine gridLine = this.GetDecorationByColumnIndex(columnIndex + 1); if (!gridLine.layoutSlot.IsSizeValid()) { return; } double difference = gridLine.layoutSlot.X - calendarCell.layoutSlot.Right; calendarCell.layoutSlot.Width += difference; }
private void SnapToLeftGridLine(CalendarNode calendarCell, int columnIndex) { if (columnIndex <= 0 || columnIndex >= (this.ColumnCount + (this.BufferItemsCount * 2))) { return; } CalendarGridLine gridLine = this.GetDecorationByColumnIndex(columnIndex); if (!gridLine.layoutSlot.IsSizeValid()) { return; } double difference = gridLine.layoutSlot.Right - calendarCell.layoutSlot.X; calendarCell.layoutSlot.X += difference; calendarCell.layoutSlot.Width -= difference; }
private void ArrangeTimerRulerLines(RadRect viewRect) { var calendar = this.Calendar; double heightCoeff = (double)calendar.multiDayViewSettings.TimerRulerTickLength.Ticks / (double)TimeSpan.FromHours(1).Ticks; int tileLinesInterval = calendar.multiDayViewSettings.TimeLinesSpacing; double timeItemHeight = tileLinesInterval * heightCoeff; double gridLineThickness = calendar.GridLinesThickness; int gridLineHalfThickness = (int)(gridLineThickness / 2); for (int hourIndex = 1; hourIndex <= this.timerRulerLines.Count; hourIndex++) { CalendarGridLine timeLine = this.timerRulerLines[hourIndex - 1]; if ((calendar.GridLinesVisibility & GridLinesVisibility.Horizontal) == GridLinesVisibility.Horizontal) { timeLine.Arrange(new RadRect(viewRect.X, viewRect.Y + hourIndex * timeItemHeight - gridLineHalfThickness, viewRect.Width, gridLineThickness)); } } }
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); } } }
private void ArrangeCurrentTimeIndicator(RadRect viewRect) { if (this.currentTimeIndicator == null) { this.currentTimeIndicator = new CalendarGridLine(); this.currentTimeIndicator.IsHorizontal = true; this.currentTimeIndicator.root = this.root; } MultiDayViewSettings settings = this.Calendar.multiDayViewSettings; DateTime currentDate = DateTime.Now; if (currentDate.TimeOfDay >= settings.DayStartTime && currentDate.TimeOfDay <= settings.DayEndTime) { double verticalPosition = this.DateToVerticalPosition(currentDate, currentDate); this.currentTimeIndicator.Arrange(new RadRect(this.layoutSlot.X, verticalPosition, viewRect.Width, CalendarMultiDayViewModel.DefaultCurrentTimeIndicatorHeight)); } else { this.currentTimeIndicator.layoutSlot = RadRect.Empty; } }
private Border GetTimerRulerLine(CalendarGridLine line) { Border visual; if (this.recycledTimeRulerLines.Count > 0) { visual = this.recycledTimeRulerLines.Dequeue(); visual.ClearValue(Border.VisibilityProperty); visual.ClearValue(Border.StyleProperty); visual.ClearValue(Border.BorderThicknessProperty); visual.ClearValue(Canvas.ZIndexProperty); visual.ClearValue(Canvas.LeftProperty); } else { visual = this.CreateBorderVisual(); } this.realizedTimerRulerLinePresenters.Add(line, visual); return(visual); }