internal void ArrangeCell(GridCellEditorModel cell) { var pair = cell.Container as Tuple <FrameworkElement, FrameworkElement, FrameworkElement>; if (pair == null || pair.Item2 == null) { return; } RadRect layoutSlot = cell.Column.ApplyLayoutSlotAlignment(cell); var rect = this.Owner.InflateEditCellHorizontally(cell, layoutSlot); rect = this.Owner.InflateEditCellVertically(cell, rect); if (this.Owner.EditRowLayer.EditorLayoutSlots.ContainsKey(cell)) { this.Owner.EditRowLayer.EditorLayoutSlots[cell] = rect; } else { this.Owner.EditRowLayer.EditorLayoutSlots.Add(cell, rect); } pair.Item2.Arrange(rect.ToRect()); if (this.focusFirstEditor) { var control = pair.Item1 as Control; if (control != null && control.IsTabStop) { control.Focus(FocusState.Programmatic); } this.focusFirstEditor = false; } }
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); if ((this.Calendar.GridLinesVisibility & GridLinesVisibility.Horizontal) == GridLinesVisibility.Horizontal) { 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)); } if ((this.Calendar.GridLinesVisibility & GridLinesVisibility.Vertical) == GridLinesVisibility.Vertical) { this.verticalRulerGridLine.Arrange(new RadRect(rect.X, rect.Y, gridLineThickness, rect.Height)); } }
private void UpdateTimerRulerLines(ElementCollection <CalendarGridLine> timeRulerLines) { this.RecycleTimeRulerLines(timeRulerLines); foreach (var gridLine in timeRulerLines) { if (!this.viewPortArea.IntersectsWith(gridLine.layoutSlot)) { continue; } Border border = this.GetTimerRulerLine(gridLine); if (border != null) { this.ApplyTimeRulerStyle(gridLine, border); if (!XamlDecorationLayer.IsStrokeBrushExplicitlySet(border.Style)) { border.BorderBrush = this.Owner.GridLinesBrush; } if (border.BorderBrush != null && !XamlDecorationLayer.IsStrokeThicknessExplicitlySet(border.Style)) { border.BorderThickness = new Thickness(this.Owner.GridLinesThickness); } RadRect layoutSlot = gridLine.layoutSlot; XamlContentLayer.ArrangeUIElement(border, layoutSlot, true); Canvas.SetLeft(border, -this.leftOffset); Canvas.SetZIndex(border, XamlMultiDayViewLayer.DefaultLineZIndex); } } foreach (var recycledLine in this.recycledTimeRulerLines) { recycledLine.Visibility = Visibility.Collapsed; } }
internal void UpdateTodaySlot() { Slot todaySlot = this.Owner.Model.multiDayViewModel.todaySlot; if (this.todaySlotBorder == null) { this.todaySlotBorder = new Border(); this.contentPanel.Children.Add(this.todaySlotBorder); } else { this.todaySlotBorder.ClearValue(Border.VisibilityProperty); this.todaySlotBorder.ClearValue(Border.StyleProperty); this.todaySlotBorder.ClearValue(Canvas.ZIndexProperty); this.todaySlotBorder.ClearValue(Canvas.LeftProperty); } if (this.bufferedViewPortArea.IntersectsWith(todaySlot.layoutSlot)) { MultiDayViewSettings settings = this.Owner.MultiDayViewSettings; Style todaySlotStyle = settings.TodaySlotStyle ?? settings.defaulTodaySlotStyle; if (todaySlotStyle != null) { this.todaySlotBorder.Style = todaySlotStyle; } RadRect layoutSlot = todaySlot.layoutSlot; XamlMultiDayViewLayer.ArrangeUIElement(this.todaySlotBorder, layoutSlot, true); Canvas.SetZIndex(this.todaySlotBorder, XamlMultiDayViewLayer.DefaultTodaySlotZIndex); Canvas.SetLeft(this.todaySlotBorder, layoutSlot.X - this.leftOffset + this.leftHeaderPanel.Width); } else if (this.todaySlotBorder.Visibility == Visibility.Visible) { this.todaySlotBorder.Visibility = Visibility.Collapsed; } }
private void ApplyLayersClipping(RadSize finalSize) { RadRect rect = RadRect.Empty; RadRect frozenRect = RadRect.Empty; double frozenColumnsOffset = 0; var frozenЕlements = this.ColumnPool.GetFrozenDisplayedElements(); var scrollableElements = this.ColumnPool.GetUnfrozenDisplayedElements(); if (frozenЕlements.Any()) { frozenColumnsOffset = frozenЕlements.Last().Value.Last().LayoutSlot.Right; frozenRect = new RadRect(0, this.PhysicalVerticalOffset, frozenColumnsOffset, finalSize.Height); } if (scrollableElements.Any()) { var scrollableViewPortRight = scrollableElements.Last().Value.Last().layoutSlot.Right; rect = new RadRect(this.PhysicalHorizontalOffset + frozenColumnsOffset, this.PhysicalVerticalOffset, scrollableViewPortRight, finalSize.Height); } this.GridView.ApplyLayersClipping(rect, frozenRect); }
public void ArrangeVisuals() { var orientation = this.Owner.Orientation; foreach (var item in this.Owner.Model.ForEachDisplayedElement()) { GeneratedItemModel model = null; this.generatedContainers.TryGetValue(item.ItemInfo.Id, out model); if (model != null && model.Container != null) { RadRect arrangeRect = new RadRect(); var control = model.Container as ItemCheckBoxControl; control.Height = orientation == Orientation.Vertical ? item.LayoutSlot.Height : control.DesiredSize.Height; control.Width = orientation == Orientation.Vertical ? control.DesiredSize.Width : item.LayoutSlot.Width; arrangeRect.Width = orientation == Orientation.Vertical ? control.DesiredSize.Width : item.LayoutSlot.Width; arrangeRect.Height = orientation == Orientation.Vertical ? item.LayoutSlot.Height : control.DesiredSize.Height; var beforeX = item.LayoutSlot.X; var afterX = orientation == Orientation.Vertical ? item.LayoutSlot.Right - control.DesiredSize.Width : item.LayoutSlot.X; var beforeY = item.LayoutSlot.Y; var afterY = orientation == Orientation.Vertical ? item.LayoutSlot.Y : item.LayoutSlot.Bottom - control.DesiredSize.Height; arrangeRect.X = this.Owner.ItemCheckBoxPosition == CheckBoxPosition.BeforeItem ? beforeX : afterX; arrangeRect.Y = this.Owner.ItemCheckBoxPosition == CheckBoxPosition.BeforeItem ? beforeY : afterY; this.Owner.checkBoxLayerCache.ArrangeElement(model.Container as FrameworkElement, arrangeRect); this.VisualLength = orientation == Orientation.Vertical ? arrangeRect.Width : arrangeRect.Height; } var listView = this.Owner; if (!this.itemsAnimated && this.Owner.checkBoxLayerCache.GetGeneratedContainersCount() > 0) { listView.animationSurvice.PlayCheckModeAnimation(listView.childrenPanel, listView.IsCheckModeActive, listView.ItemCheckBoxPosition == CheckBoxPosition.BeforeItem, this.VisualLength); listView.animationSurvice.PlayCheckBoxLayerAnimation(listView.checkBoxLayerCache.VisualElement, listView.IsCheckModeActive, listView.ItemCheckBoxPosition == CheckBoxPosition.BeforeItem, this.VisualLength); this.itemsAnimated = true; } } }
private static bool TryClipToContainerTop(ref RadLine line, RadRect container, double topIntersectionX, double dashPatternLength, double angle) { bool intersectsWithRect = false; if (container.X <= topIntersectionX && topIntersectionX <= container.Right) { if (line.Y1 < line.Y2 && line.Y1 < container.Y) { intersectsWithRect = true; var lengthToAdd = RadMath.GetPointDistance(topIntersectionX, line.X1, container.Y, line.Y1) % dashPatternLength; line.X1 = topIntersectionX + lengthToAdd * Math.Cos(angle); line.Y1 = container.Y - lengthToAdd * Math.Sin(angle); } else if (line.Y2 < line.Y1 && line.Y2 < container.Y) { intersectsWithRect = true; line.X2 = topIntersectionX; line.Y2 = container.Y; } } return(intersectsWithRect); }
private static bool TryClipToContainerBottom(ref RadLine line, RadRect container, double bottomIntersectionX, double dashPatternLength, double angle) { bool intersectsWithRect = false; if (container.X <= bottomIntersectionX && bottomIntersectionX <= container.Right) { if (line.Y1 < line.Y2 && line.Y2 > container.Bottom) { intersectsWithRect = true; line.X2 = bottomIntersectionX; line.Y2 = container.Bottom; } else if (line.Y2 < line.Y1 && line.Y1 > container.Bottom) { intersectsWithRect = true; var lengthToAdd = RadMath.GetPointDistance(bottomIntersectionX, line.X1, container.Bottom, line.Y1) % dashPatternLength; line.X1 = bottomIntersectionX - lengthToAdd * System.Math.Cos(angle); line.Y1 = container.Bottom + lengthToAdd * System.Math.Sin(angle); } } return(intersectsWithRect); }
private static bool TryClipToContainerLeft(ref RadLine line, RadRect container, double leftIntersectionY, double dashPatternLength, double angle) { bool intersectsWithRect = false; if (container.Y <= leftIntersectionY && leftIntersectionY <= container.Bottom) { if (line.X1 < line.X2 && line.X1 < container.X) { intersectsWithRect = true; var lengthToAdd = RadMath.GetPointDistance(container.X, line.X1, leftIntersectionY, line.Y1) % dashPatternLength; line.Y1 = leftIntersectionY + lengthToAdd * Math.Sin(angle); line.X1 = container.X - lengthToAdd * Math.Cos(angle); } else if (line.X2 < line.X1 && line.X2 < container.X) { intersectsWithRect = true; line.Y2 = leftIntersectionY; line.X2 = container.X; } } return(intersectsWithRect); }
private static bool TryClipToContainerRight(ref RadLine line, RadRect container, double rightIntersectionY, double dashPatternLength, double angle) { bool intersectsWithRect = false; if (container.Y <= rightIntersectionY && rightIntersectionY <= container.Bottom) { if (line.X1 < line.X2 && line.X2 > container.Right) { intersectsWithRect = true; line.Y2 = rightIntersectionY; line.X2 = container.Right; } else if (line.X2 < line.X1 && line.X1 > container.Right) { intersectsWithRect = true; var lengthToAdd = RadMath.GetPointDistance(container.Right, line.X1, rightIntersectionY, line.Y1) % dashPatternLength; line.Y1 = rightIntersectionY - lengthToAdd * Math.Sin(angle); line.X1 = container.Right + lengthToAdd * Math.Cos(angle); } } return(intersectsWithRect); }
/// <summary> /// Clips vertical or horizontal grid line to rectangle area. /// </summary> /// <param name="line">The line to be clipped.</param> /// <param name="container">The container.</param> /// <param name="borderOverflow">The border (stroke thickness) of the <paramref name="line"/>.</param> /// <param name="dashPatternLength">The length of the dash pattern of the line stroke.</param> /// <returns>The clipped line.</returns> internal static RadLine ClipGridLine(RadLine line, RadRect container, double borderOverflow, double dashPatternLength) { // extend the container with the element border container.X -= borderOverflow; container.Y -= borderOverflow; container.Width += 2 * borderOverflow; container.Height += 2 * borderOverflow; if (dashPatternLength == 0 || double.IsNaN(dashPatternLength) || double.IsInfinity(dashPatternLength)) { dashPatternLength = 1; } if (line.X1 == line.X2) { if (line.X1 < container.X || line.X1 > container.Right) { return(new RadLine()); } line.Y1 = container.Y - (container.Y - line.Y1) % dashPatternLength; line.Y2 = container.Bottom; } else if (line.Y1 == line.Y2) { if (line.Y1 < container.Y || line.Y1 > container.Bottom) { return(new RadLine()); } line.X1 = container.X - (container.X - line.X1) % dashPatternLength; line.X2 = container.Right; } return(line); }
internal override object ConvertPhysicalUnitsToData(double coordinate, RadRect axisVirtualSize) { int categoriesCount = this.categories.Count; if (!this.isUpdated || categoriesCount == 0) { return(null); } double step = this.CalculateRelativeStep(categoriesCount); double stepOffset = this.actualPlotMode == AxisPlotMode.OnTicks ? 0.5 * step : 0; double relativePosition = this.CalculateRelativePosition(coordinate, axisVirtualSize, stepOffset); int categoryIndex = (int)(relativePosition / step); if (categoryIndex < 0 || categoryIndex > categoriesCount - 1) { return(null); } AxisCategory category = this.categories[categoryIndex]; return(category.KeySource); }
internal RadRect InflateEditRowVertically(GridEditRowModel row, RadRect rect) { // the editrow uses the size of the row behind it(which has already been precalculated in the EditRowHostPanel and takes into acount the gridlines(if any). if (row != null && this.decorationLayerCache != null) { var line = row.ReadOnlyRowInfo.LayoutInfo.Line; var visibleLines = this.Model.RowPool.Layout.VisibleLineCount; var height = 0d; var element = this.Model.RowPool.GetDisplayedElement(line + 1); if (element != null && line != visibleLines - 1 && this.HasHorizontalGridLines && element.ContainerType != typeof(DataGridGroupHeader)) { height += this.GridLinesThickness; } var layoutSlot = this.Model.RowPool.GetDisplayedElement(line).LayoutSlot; var arrangeRect = new RadRect(rect.X, rect.Y, rect.Width, layoutSlot.Height + height); return(arrangeRect); } return(rect); }
internal void ArrangeAppointments() { AppointmentSource appointmentSource = this.Calendar.appointmentSource; if (this.appointmentInfos == null) { this.appointmentInfos = new List <CalendarAppointmentInfo>(); } else { this.appointmentInfos.Clear(); } if (appointmentSource != null) { MultiDayViewSettings settings = this.Calendar.multiDayViewSettings; foreach (var calendarCell in this.CalendarCells) { LinkedList <IAppointment> appointmentsPerCell = appointmentSource.GetAppointments((IAppointment appointment) => { return(calendarCell.Date.Date >= appointment.StartDate.Date && calendarCell.Date.Date <= appointment.EndDate.Date && !(appointment.IsAllDay && settings.ShowAllDayArea)); }); var orderedAppointments = new LinkedList <IAppointment>(appointmentsPerCell.OrderBy(a => a.StartDate)); foreach (var appointment in orderedAppointments) { if ((appointment.StartDate.Date == calendarCell.Date.Date && appointment.StartDate.TimeOfDay > settings.DayEndTime) || (appointment.EndDate.Date == calendarCell.Date.Date && appointment.EndDate.TimeOfDay < settings.DayStartTime)) { continue; } double startY = this.DateToVerticalPosition(calendarCell.Date.Date, appointment.StartDate); DateTime endDate = appointment.EndDate.TimeOfDay > settings.DayEndTime ? appointment.EndDate.Add(TimeSpan.FromTicks(settings.DayEndTime.Ticks - appointment.EndDate.TimeOfDay.Ticks)) : appointment.EndDate; double endY = this.DateToVerticalPosition(calendarCell.Date.Date, endDate); if (startY < endY) { CalendarAppointmentInfo info = new CalendarAppointmentInfo(); info.Date = calendarCell.Date; info.Appointments = orderedAppointments; info.columnIndex = calendarCell.ColumnIndex; info.Brush = appointment.Color; info.cell = calendarCell; info.childAppointment = appointment; info.DetailText = appointment.Description; info.Subject = appointment.Subject; info.IsAllDay = appointment.IsAllDay; DateTime currentAppointmentStartDate = appointment.StartDate; DateTime currentAppointmentEndDate = appointment.EndDate; if (!this.Calendar.multiDayViewSettings.WeekendsVisible) { currentAppointmentStartDate = CalendarMathHelper.SetFirstAvailableBusinessDay(currentAppointmentStartDate, 1); currentAppointmentEndDate = CalendarMathHelper.SetFirstAvailableBusinessDay(currentAppointmentEndDate, -1); } info.hasPreviousDay = currentAppointmentStartDate.Date < calendarCell.Date; info.hasNextDay = currentAppointmentEndDate.Date > calendarCell.Date; int xCoeff = (calendarCell.Date - appointment.StartDate.Date).Days; RadRect layoutSlot = new RadRect(calendarCell.layoutSlot.X - this.timeRulerWidth, startY, calendarCell.layoutSlot.Width, endY - startY); info.layoutSlot = layoutSlot; this.appointmentInfos.Add(info); } } } this.ArrangeIntersectedAppointments(); } }
protected override void ArrangeCalendarHeaders(RadRect viewRect) { this.EnsureCalendarHeaderCells(); this.ArrangeCalendarColumnHeaders(viewRect); }
internal void UpdateAppointments(List <CalendarAppointmentInfo> appointmentInfos) { int index = 0; RadCalendar calendar = this.Owner; foreach (var appointmentInfo in appointmentInfos) { if (!this.bufferedViewPortArea.IntersectsWith(appointmentInfo.layoutSlot)) { continue; } AppointmentControl appointmentControl = this.GetDefaultAppointmentVisual(index); if (appointmentControl != null) { RadRect layoutSlot = appointmentInfo.layoutSlot; layoutSlot.Width -= 3; appointmentControl.Content = appointmentInfo.DetailText; appointmentControl.Header = appointmentInfo.Subject; appointmentControl.Background = appointmentInfo.Brush; if (appointmentInfo.hasPrevDay) { appointmentControl.LeftIndicatorVisibility = Visibility.Visible; } if (appointmentInfo.hasNextDay) { appointmentControl.RightIndicatorVisibility = Visibility.Visible; } appointmentControl.appointmentInfo = appointmentInfo; StyleSelector contentStyleSelector = calendar.AppointmentStyleSelector; if (contentStyleSelector != null) { var style = contentStyleSelector.SelectStyle(appointmentInfo, appointmentControl); if (style != null) { appointmentControl.Style = style; } } else if (appointmentControl.Style != null) { appointmentControl.ClearValue(AppointmentControl.StyleProperty); } AppointmentTemplateSelector templateSelector = calendar.AppointmentTemplateSelector; if (templateSelector != null) { DataTemplate template = templateSelector.SelectTemplate(appointmentInfo, appointmentInfo.cell); if (template != null) { appointmentControl.ContentTemplate = template; } } AppointmentTemplateSelector headerTemplateSelector = calendar.AppointmentHeaderTemplateSelector; if (headerTemplateSelector != null) { DataTemplate template = headerTemplateSelector.SelectTemplate(appointmentInfo, appointmentInfo.cell); if (template != null) { appointmentControl.HeaderTemplate = template; } } XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true); Canvas.SetZIndex(appointmentControl, XamlMultiDayViewLayer.DefaultAppointmentZIndex); Canvas.SetLeft(appointmentControl, layoutSlot.X - this.leftOffset + this.leftHeaderPanel.Width); index++; } } while (index < this.realizedAppointmentDefaultPresenters.Count) { this.realizedAppointmentDefaultPresenters[index].Visibility = Visibility.Collapsed; index++; } }
internal void ArrangeFrozenDecorators() { if (!this.EnableFrozenDecorators || this.generatedFrozenContainers.Count == 0) { this.FrozenContainersLength = 0; return; } var topLeft = new RadPoint(0, 0); foreach (var pair in this.generatedFrozenContainers) { var decorators = pair.Value; var frozenDecorator = decorators.Last(); var frozenDecoratorItemInfo = frozenDecorator.ItemInfo; var frozenGroupLevel = frozenDecoratorItemInfo.Level; var frozenDecoratorDesiredSize = frozenDecorator.DesiredSize; var decoratorPairAfterCurrentFrozenDecorator = this.generatedContainers.FirstOrDefault(kvp => frozenDecoratorItemInfo.Id < kvp.Value.Last().ItemInfo.Id&& kvp.Value.Last().ItemInfo.Level <= frozenDecoratorItemInfo.Level); List <GeneratedItemModel> notFrozenDecorators = decoratorPairAfterCurrentFrozenDecorator.Value; if (notFrozenDecorators != null && notFrozenDecorators.Count > 0) { var lastDecorator = notFrozenDecorators.Last(); var layoutSlot = lastDecorator.LayoutSlot; if (this.IsHorizontal) { var physicalHorizontalOffset = this.Owner.ScrollOffset; if (layoutSlot.X - physicalHorizontalOffset < topLeft.X + frozenDecoratorDesiredSize.Width) { topLeft.X = layoutSlot.X - physicalHorizontalOffset - frozenDecoratorDesiredSize.Width; } } else { var physicalVertivalOffset = this.Owner.ScrollOffset; if (layoutSlot.Y - physicalVertivalOffset < topLeft.Y + frozenDecoratorDesiredSize.Height) { topLeft.Y = layoutSlot.Y - physicalVertivalOffset - frozenDecoratorDesiredSize.Height; } } } // TODO: Get the Pixel VerticalOffset and check the size of the first decorator. // If it doesn't fit - then we need to offset and clip the decorator. double stretchLength = this.IsHorizontal ? this.AvailableSize.Height : this.AvailableSize.Width; double length = this.frozenDecoratorLengthPerLevel[frozenGroupLevel]; var arrangeRect = new RadRect(); foreach (var decorator in decorators) { if (this.IsHorizontal) { arrangeRect = new RadRect(topLeft.X, topLeft.Y, length, stretchLength); this.FrozenContainersLength = arrangeRect.Right; } else { arrangeRect = new RadRect(topLeft.X, topLeft.Y, stretchLength, length); this.FrozenContainersLength = arrangeRect.Bottom; } decorator.LayoutSlot = arrangeRect; this.Owner.Arrange(decorator); } if (this.IsHorizontal) { topLeft.X += arrangeRect.Width; } else { topLeft.Y += arrangeRect.Height; } } }
/// <summary> /// Prepares the <see cref="ContainerVisual"/> used for the visualization of the lines of the CartesianChartGrid by setting its Size, Color and Offset. /// </summary> /// <param name="containerVisual">The <see cref="ContainerVisual"/> that is used by the Composition API.</param> /// <param name="layoutSlot"> A Rectangle in the Euclidean plane geometry used for the Size and Offset of the <see cref="ContainerVisual"/>.</param> /// <param name="orientation"> The orientation of the CharGrid's line.</param> /// <param name="dashArray"> An array of doubles used for positioning of the dashes of the CharGrid's line.</param> protected internal virtual ContainerVisual PrepareCartesianChartGridLineVisual(ContainerVisual containerVisual, RadRect layoutSlot, Orientation orientation, DoubleCollection dashArray) { if (orientation == Orientation.Horizontal) { containerVisual.Offset = new Vector3((float)layoutSlot.X, (float)layoutSlot.Bottom, 0); if (containerVisual.Size.X != layoutSlot.Width || containerVisual.Size.Y != 1) { containerVisual.Size = new Vector2((float)layoutSlot.Width, 1); if (this.dashArrayCache != null) { var oldDashesSize = containerVisual.Children.Count * (this.dashArrayCache[0] + this.dashArrayCache[1]); if (containerVisual.Children.Count > 0 && oldDashesSize < layoutSlot.Width) { this.ArrangeChartGridDashes(containerVisual, orientation, dashArray, (int)oldDashesSize); } } } } else { containerVisual.Offset = new Vector3((float)layoutSlot.X, (float)layoutSlot.Y, 0); if (containerVisual.Size.X != 1 || containerVisual.Size.Y != layoutSlot.Height) { containerVisual.Size = new Vector2(1, (float)layoutSlot.Height); if (this.dashArrayCache != null) { var oldDashesSize = containerVisual.Children.Count * (this.dashArrayCache[0] + this.dashArrayCache[1]); if (containerVisual.Children.Count > 0 && oldDashesSize < layoutSlot.Height) { this.ArrangeChartGridDashes(containerVisual, orientation, dashArray, (int)oldDashesSize); } } } } if (dashArray[0] > 0 && dashArray[1] > 0) { if (containerVisual.Children.Count == 0) { this.ArrangeChartGridDashes(containerVisual, orientation, dashArray); this.dashArrayCache = dashArray; } else if (this.dashArrayCache != null && (this.dashArrayCache[0] != dashArray[0] || this.dashArrayCache[1] != dashArray[1])) { containerVisual.Children.RemoveAll(); this.ArrangeChartGridDashes(containerVisual, orientation, dashArray); this.dashArrayCache = dashArray; } } if (dashArray[0] > 0 && dashArray[1] == 0) { if (containerVisual.Children.Count > 0) { containerVisual.Children.RemoveAll(); } this.SetCompositionColorBrush(containerVisual, new SolidColorBrush(Color.FromArgb(0x23, 0, 0, 0))); } if (dashArray[0] == 0) { if (containerVisual.Children.Count > 0) { containerVisual.Children.RemoveAll(); } this.SetCompositionColorBrush(containerVisual, null); } return(containerVisual); }
/// <summary> /// Prepares the <see cref="ContainerVisual"/> used for the visualization of the Axis's Lines by setting its Size, Color and Offset. /// </summary> /// <param name="axis">The <see cref="CartesianAxis"/> that will be visualized.</param> /// <param name="lineContainer">The <see cref="ContainerVisual"/> that is used by the Composition API.</param> /// <param name="layoutSlot">A Rectangle in the Euclidean plane geometry used for the Size and Offset of the <see cref="ContainerVisual"/>.</param> /// <param name="axisType">The <see cref="AxisType"/> of the Axis's line.</param> protected internal virtual ContainerVisual PrepareCartesianAxisLineVisual(CartesianAxis axis, ContainerVisual lineContainer, RadRect layoutSlot, AxisType axisType = AxisType.First) { if (axisType == AxisType.First) { float antiAliasOffset = axis.model.LineThickness % 2 == 1 ? 0.5f : 0; lineContainer.Offset = axis.VerticalLocation == AxisVerticalLocation.Bottom ? new Vector3((float)layoutSlot.Location.X, (float)layoutSlot.Location.Y - antiAliasOffset, 0) : new Vector3((float)layoutSlot.Location.X, (float)layoutSlot.Bottom - antiAliasOffset, 0); if (lineContainer.Size.X != layoutSlot.Width || lineContainer.Size.Y != ((float)axis.model.LineThickness - antiAliasOffset)) { lineContainer.Size = new Vector2((float)layoutSlot.Width, (float)axis.model.LineThickness - antiAliasOffset); } } else { lineContainer.Offset = axis.HorizontalLocation == AxisHorizontalLocation.Left ? new Vector3((float)layoutSlot.Right, (float)layoutSlot.Location.Y, 0) : new Vector3((float)layoutSlot.X, (float)layoutSlot.Location.Y, 0); if (lineContainer.Size.X != axis.model.LineThickness || lineContainer.Size.Y != layoutSlot.Height) { lineContainer.Size = new Vector2((float)axis.model.LineThickness, (float)layoutSlot.Height); } } this.ChangeBrushesAccordingToAppTheme(); this.SetCompositionColorBrush(lineContainer, this.telerikChartAxisBorderBrush); return(lineContainer); }
/// <summary> /// Prepares the <see cref="ContainerVisual"/> used for the visualization of the ticks by setting its Size, Color and Offset. /// </summary> /// <param name="containerVisual">The <see cref="ContainerVisual"/> that is used by the Composition API.</param> /// <param name="layoutSlot"> A Rectangle in the Euclidean plane geometry used for the Size and Offset of the <see cref="ContainerVisual"/>.</param> protected internal virtual ContainerVisual PrepareTickVisual(ContainerVisual containerVisual, RadRect layoutSlot) { if (containerVisual.Size.X != layoutSlot.Width || containerVisual.Size.Y != layoutSlot.Height) { containerVisual.Size = new Vector2((float)layoutSlot.Width, (float)layoutSlot.Height); } this.ChangeBrushesAccordingToAppTheme(); this.SetCompositionColorBrush(containerVisual, this.telerikChartAxisBorderBrush); containerVisual.Offset = new Vector3((float)layoutSlot.Location.X, (float)layoutSlot.Location.Y, 0); return(containerVisual); }
public static Rect ToRect(this RadRect rect) { return(new Rect(rect.X, rect.Y, rect.Width, rect.Height)); }
private void ArrangeAllDayAppointment(RadRect viewRect) { AppointmentSource appointmentSource = this.Calendar.appointmentSource; if (this.allDayAppointmentInfos == null) { this.allDayAppointmentInfos = new List <CalendarAppointmentInfo>(); } else { this.allDayAppointmentInfos.Clear(); } if (appointmentSource != null) { MultiDayViewSettings settings = this.Calendar.multiDayViewSettings; double appoitmentHeight = settings.AllDayAppointmentMinHeight; foreach (var cell in this.CalendarCells) { LinkedList <IAppointment> appointments = appointmentSource.GetAppointments((IAppointment appointment) => { return(cell.Date.Date >= appointment.StartDate.Date && cell.Date.Date <= appointment.EndDate.Date && appointment.IsAllDay); }); if (appointments.Count > this.allDayAreaRowCount) { this.allDayAreaRowCount = appointments.Count; } var sorterAppointments = appointments.OrderByDescending(a => a.EndDate.Ticks - a.StartDate.Ticks).ToList(); var containedInfos = this.allDayAppointmentInfos.Where(a => sorterAppointments.Contains(a.childAppointment)); double prevBottom = cell.layoutSlot.Y - this.dayViewLayoutSlot.Y; foreach (var appointment in sorterAppointments) { while (true) { int widthCoeff; int xCoeff; DateTime startAppointmentDate = appointment.StartDate; if (this.Calendar.multiDayViewSettings.WeekendsVisible) { widthCoeff = (appointment.EndDate - startAppointmentDate).Days; xCoeff = (cell.Date - startAppointmentDate.Date).Days; } else { widthCoeff = CalendarMathHelper.GetBusinessDaysCount(startAppointmentDate, appointment.EndDate); startAppointmentDate = CalendarMathHelper.SetFirstAvailableBusinessDay(startAppointmentDate, 1); xCoeff = CalendarMathHelper.GetBusinessDaysCount(startAppointmentDate.Date, cell.Date); } RadRect layoutSlot = new RadRect(cell.layoutSlot.X - (xCoeff * this.cellWidth), prevBottom, this.cellWidth + (this.cellWidth * widthCoeff) - this.Calendar.GridLinesThickness / 2, appoitmentHeight); if (containedInfos.FirstOrDefault(a => a.layoutSlot.IntersectsWith(layoutSlot)) == null) { CalendarAppointmentInfo containedInfo = containedInfos.FirstOrDefault(a => a.childAppointment == appointment); if (containedInfo != null) { break; } CalendarAppointmentInfo info = new CalendarAppointmentInfo(); info.Date = cell.Date; info.Appointments = appointments; info.columnIndex = cell.ColumnIndex; info.Brush = appointment.Color; info.cell = cell; info.childAppointment = appointment; info.DetailText = appointment.Description; info.Subject = appointment.Subject; info.IsAllDay = appointment.IsAllDay; info.layoutSlot = layoutSlot; this.allDayAppointmentInfos.Add(info); prevBottom = layoutSlot.Bottom + settings.AllDayAppointmentSpacing; break; } prevBottom = layoutSlot.Bottom + settings.AllDayAppointmentSpacing; } } } int maxVisibleRows = settings.AllDayMaxVisibleRows; this.totalAllDayAreaHeight = this.allDayAreaRowCount > maxVisibleRows ? maxVisibleRows * appoitmentHeight + maxVisibleRows * settings.AllDayAppointmentSpacing + appoitmentHeight / 2 : this.allDayAreaRowCount * appoitmentHeight + this.allDayAreaRowCount * settings.AllDayAppointmentSpacing; if (this.allDayAreaRowCount == 0) { this.totalAllDayAreaHeight = 0; } } }
private static bool TryRunRiseAnimtation(CartesianSeries series, bool useDelay) { RadRect plotAreClip = series.Chart.PlotAreaClip; bool isHorizontalBar = !IsSeriesHorizontal(series); bool isInverse = IsNumericalAxisInverse(series); double centerX = 0; double centerY = 0; if (isHorizontalBar) { centerX = isInverse ? plotAreClip.Right : plotAreClip.X; } else { centerY = isInverse ? plotAreClip.Y : plotAreClip.Bottom; } var scaleTransform = new ScaleTransform(); scaleTransform.ScaleX = isHorizontalBar ? 0 : 1; scaleTransform.ScaleY = isHorizontalBar ? 1 : 0; scaleTransform.CenterX = centerX; scaleTransform.CenterY = centerY; series.RenderTransform = scaleTransform; TimeSpan?beginTime = useDelay ? CalculateBeginTime(series) : null; DoubleAnimation animation = new DoubleAnimation(); animation.From = 0; animation.To = 1; animation.Duration = AnimationDuration; if (beginTime != null) { animation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut, }; } else { animation.EasingFunction = new CircleEase() { EasingMode = EasingMode.EaseOut, }; } Storyboard.SetTarget(animation, series); if (isHorizontalBar) { Storyboard.SetTargetProperty(animation, new PropertyPath(ChartAnimationUtilities.SeriesScaleTransformXProperty)); } else { Storyboard.SetTargetProperty(animation, new PropertyPath(ChartAnimationUtilities.SeriesScaleTransformYProperty)); } Storyboard storyboard = new Storyboard(); storyboard.Children.Add(animation); if (beginTime != null) { storyboard.BeginTime = beginTime; } return(Run(storyboard, series)); }
protected abstract RadRect ArrangeCore(RadRect rect);
private Location GetManipulationDirection(double dy, double dx, double y0, double x0, RadRect rectangle) { var angle = Math.Atan2(dy, dx); var first = Math.Atan2(0 - y0, 0 - x0); var second = Math.Atan2(0 - y0, rectangle.Width - x0); var third = Math.Atan2(rectangle.Height - y0, rectangle.Width - x0); var forth = Math.Atan2(rectangle.Height - y0, 0 - x0); if (angle < first || angle > forth) { return(Location.Right); } else if (angle < second) { return(Location.Top); } else if (angle < third) { return(Location.Left); } else { // first < angle , angle < forth return(Location.Bottom); } }
internal override void UpdateTicksVisibility(RadRect clipRect) { }
public override void ArrangeContent(RadSize adjustedfinalSize, double topOffset) { bool initialized = false; var topLeft = new RadPoint(0, 0); foreach (var pair in this.GetDisplayedElements()) { double largestLength = -1; var decorators = pair.Value; RadRect arrangeRect = new RadRect(); double stackLength = (this.IsHorizontal ? adjustedfinalSize.Height : adjustedfinalSize.Width) / this.StackCount; double itemlength = 0; int elementSequenceNumber = 0; foreach (var decorator in decorators) { elementSequenceNumber = this.layout.ColumnRenderInfo.GetColumnForId(decorator.ItemInfo.Id); var offset = decorator.ItemInfo.Slot != 0 ? this.layout.ColumnRenderInfo.PhysicalOffsetFromSlot(decorator.ItemInfo.Id) : 0; if (!initialized) { initialized = true; if (this.IsHorizontal) { // topLeft.X = offset; } else { topLeft.Y = topOffset; } } if (this.IsHorizontal) { topLeft.X = offset; } else { topLeft.Y = offset; } itemlength = this.layout.PhysicalLengthForSlot(decorator.ItemInfo.Slot); if (this.IsHorizontal) { topLeft.Y = elementSequenceNumber * stackLength; var oppositeLength = decorator.ItemInfo.Item is Telerik.Data.Core.IGroup ? adjustedfinalSize.Height : stackLength; arrangeRect = new RadRect(topLeft.X, topLeft.Y, itemlength, oppositeLength); largestLength = Math.Max(largestLength, arrangeRect.Width); } else { topLeft.X = elementSequenceNumber * stackLength; var oppositeLength = decorator.ItemInfo.Item is Telerik.Data.Core.IGroup ? adjustedfinalSize.Width : stackLength; arrangeRect = new RadRect(topLeft.X, topLeft.Y, oppositeLength, itemlength + topOffset); largestLength = Math.Max(largestLength, arrangeRect.Height); } decorator.LayoutSlot = arrangeRect; this.Owner.Arrange(decorator); // elementSequenceNumber++; } if (this.IsHorizontal) { topLeft.X += largestLength; } else { topLeft.Y += largestLength; } this.ArrangeFrozenDecorators(); } }
protected override void ArrangeLabelMultiline(AxisLabelModel label, RadRect rect) { throw new NotImplementedException(); }
private static bool TryRunDropAnimtation(CartesianSeries series, bool useDelay) { IList <DataPoint> dataPoints = GetDataPoints(series); bool isInverse = IsNumericalAxisInverse(series); double offsetY = isInverse ? double.PositiveInfinity : double.NegativeInfinity; foreach (DataPoint dp in dataPoints) { if (isInverse && dp.IsInPlotRange && dp.LayoutSlot.Center.Y < offsetY) { offsetY = dp.LayoutSlot.Center.Y; } else if (!isInverse && dp.IsInPlotRange && offsetY < dp.LayoutSlot.Center.Y) { offsetY = dp.LayoutSlot.Center.Y; } } if (!IsValidNumber(offsetY)) { return(false); } RadRect plotAreClip = series.Chart.PlotAreaClip; offsetY = (isInverse ? 1 : -1) * (plotAreClip.Height / 2); TranslateTransform transform = new TranslateTransform(); transform.Y = offsetY; series.RenderTransform = transform; TimeSpan?beginTime = useDelay ? CalculateBeginTime(series) : null; series.Opacity = 0; DoubleAnimation transformAnimation = new DoubleAnimation(); transformAnimation.From = offsetY; transformAnimation.To = 0; transformAnimation.Duration = AnimationDuration; transformAnimation.EasingFunction = new CircleEase() { EasingMode = EasingMode.EaseOut, }; Storyboard.SetTargetProperty(transformAnimation, new PropertyPath(ChartAnimationUtilities.SeriesTranslateTransformYProperty)); Storyboard.SetTarget(transformAnimation, series); DoubleAnimation opacityAnimation = new DoubleAnimation(); opacityAnimation.From = 0; opacityAnimation.To = 1; opacityAnimation.Duration = AnimationDuration; opacityAnimation.EasingFunction = new CircleEase() { EasingMode = EasingMode.EaseOut, }; Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(ChartSeries.OpacityProperty)); Storyboard.SetTarget(opacityAnimation, series); Storyboard storyboard = new Storyboard(); storyboard.Children.Add(transformAnimation); storyboard.Children.Add(opacityAnimation); if (beginTime != null) { storyboard.BeginTime = beginTime; } Action completed = () => series.Opacity = 1; bool started = Run(storyboard, series, completed); if (!started) { completed(); } return(started); }
protected override void ArrangeLabelNone(AxisLabelModel label, RadRect rect) { }