internal Tuple <object, object> ConvertPointToData(RadPoint coordinates, AxisModel firstAxis, AxisModel secondAxis) { object firstValue = null; object secondValue = null; if (this.view != null) { RadRect plotArea = this.plotArea.layoutSlot; double panOffsetX = this.view.PlotOriginX * plotArea.Width; double panOffsetY = this.view.PlotOriginY * plotArea.Height; RadRect plotAreaVirtualSize = new RadRect(plotArea.X, plotArea.Y, plotArea.Width * this.view.ZoomWidth, plotArea.Height * this.view.ZoomHeight); if (firstAxis != null && this.FirstAxes.Contains(firstAxis) && firstAxis.isUpdated) { firstValue = firstAxis.ConvertPhysicalUnitsToData(coordinates.X - panOffsetX, plotAreaVirtualSize); } if (secondAxis != null && this.SecondAxes.Contains(secondAxis) && secondAxis.isUpdated) { secondValue = secondAxis.ConvertPhysicalUnitsToData(coordinates.Y - panOffsetY, plotAreaVirtualSize); } } return(new Tuple <object, object>(firstValue, secondValue)); }
internal void ScrollIndexIntoView(ScrollIntoViewOperation <int> operation) { var index = operation.RequestedItem; var frozenContainersLength = Math.Max(0, this.RowPool.FrozenContainersLength); var itemLength = this.rowLayout.RenderInfo.ValueForIndex(index); var offsetToScroll = this.rowLayout.RenderInfo.OffsetFromIndex(index) - itemLength; if (DoubleArithmetics.IsLessThan(operation.InitialScrollOffset + frozenContainersLength, offsetToScroll)) { if (index > 0) { offsetToScroll -= this.View.ViewportHeight; offsetToScroll += itemLength; } } else if (DoubleArithmetics.IsLessThanOrEqual(offsetToScroll, operation.InitialScrollOffset + frozenContainersLength)) { offsetToScroll -= frozenContainersLength; } var scrollPosition = new RadPoint(this.PhysicalHorizontalOffset, Math.Max(0, offsetToScroll)); this.GridView.SetScrollPosition(scrollPosition, true, true); }
internal RadPoint ConvertDataToPoint(Tuple <object, object> data, AxisModel firstAxis, AxisModel secondAxis) { RadPoint coordinates = new RadPoint(double.NaN, double.NaN); if (this.view != null) { RadRect plotArea = this.plotArea.layoutSlot; RadRect plotAreaVirtualSize = new RadRect(plotArea.X, plotArea.Y, plotArea.Width * this.view.ZoomWidth, plotArea.Height * this.view.ZoomHeight); if (firstAxis != null && this.FirstAxes.Contains(firstAxis) && firstAxis.isUpdated) { AxisPlotInfo plotInfo = firstAxis.CreatePlotInfo(data.Item1); if (plotInfo != null) { coordinates.X = plotInfo.CenterX(plotAreaVirtualSize); } } if (secondAxis != null && this.SecondAxes.Contains(secondAxis) && secondAxis.isUpdated) { AxisPlotInfo plotInfo = secondAxis.CreatePlotInfo(data.Item2); if (plotInfo != null) { coordinates.Y = plotInfo.CenterY(plotAreaVirtualSize); } } } return(coordinates); }
protected override RadRect ArrangeCore(RadRect rect) { double radius = rect.Width / 2; RadPoint center = rect.Center; double normalizedValue1, normalizedValue2; var annotationPresenter = this.presenter as PolarAxisPlotBandAnnotation; NumericalAxisPlotInfo polarPlot1 = this.firstPlotInfo as NumericalAxisPlotInfo; NumericalAxisPlotInfo polarPlot2 = this.secondPlotInfo as NumericalAxisPlotInfo; normalizedValue1 = polarPlot1.NormalizedValue; normalizedValue2 = polarPlot2.NormalizedValue; if (annotationPresenter != null && annotationPresenter.ClipToPlotArea) { if (normalizedValue1 > 1 && normalizedValue2 > 1) { // annotation should not be visualized this.circle1 = new RadCircle(); this.circle2 = new RadCircle(); return(new RadRect()); } else { normalizedValue1 = Math.Min(1, polarPlot1.NormalizedValue); normalizedValue2 = Math.Min(1, polarPlot2.NormalizedValue); } } this.circle1 = new RadCircle(center, normalizedValue1 * radius); this.circle2 = new RadCircle(center, normalizedValue2 * radius); return(rect); }
protected override RadRect ArrangeCore(RadRect rect) { double radius = rect.Width / 2; RadPoint center = rect.Center; AxisPlotInfo anglePlot = this.plotInfo; double angle = 0d; NumericalAxisPlotInfo numericalAnglePlot = anglePlot as NumericalAxisPlotInfo; if (numericalAnglePlot != null) { angle = numericalAnglePlot.ConvertToAngle(); } else { CategoricalAxisPlotInfo categoricalAnglePlot = anglePlot as CategoricalAxisPlotInfo; if (categoricalAnglePlot != null) { angle = categoricalAnglePlot.ConvertToAngle(this.GetChartArea <PolarChartAreaModel>()); } } RadPoint arcPoint = RadMath.GetArcPoint(angle, center, radius); this.radialLine = new RadPolarVector() { Point = arcPoint, Angle = angle, Center = center }; return(new RadRect(center, arcPoint)); }
protected override RadRect ArrangeCore(RadRect rect) { double radius = rect.Width / 2; RadPoint center = rect.Center; NumericalAxisPlotInfo polarPlot = this.firstPlotInfo as NumericalAxisPlotInfo; double pointRadius = polarPlot.NormalizedValue * radius; AxisPlotInfo anglePlot = this.secondPlotInfo; this.angle = 0d; NumericalAxisPlotInfo numericalAnglePlot = anglePlot as NumericalAxisPlotInfo; if (numericalAnglePlot != null) { this.angle = numericalAnglePlot.ConvertToAngle(); } else { CategoricalAxisPlotInfo categoricalAnglePlot = anglePlot as CategoricalAxisPlotInfo; if (categoricalAnglePlot != null) { this.angle = categoricalAnglePlot.ConvertToAngle(this.GetChartArea <PolarChartAreaModel>()); } } RadPoint arcPosition = RadMath.GetArcPoint(this.angle, center, pointRadius); RadSize desiredSize = this.Measure(); return(new RadRect(arcPosition.X, arcPosition.Y, desiredSize.Width, desiredSize.Height)); }
internal GridCellModel GetCellFromPoint(RadPoint point) { if (!this.IsOperational || this.IsOverEditor(point)) { return(null); } var row = this.GetRowFromPoint(point); if (row == null) { return(null); } var frozenPoint = new RadPoint(point.X - this.Owner.ScrollViewer.HorizontalOffset, point.Y); foreach (var cell in this.Owner.Model.ForEachFrozenRowCell(row)) { if (cell.layoutSlot.Contains(frozenPoint.X, frozenPoint.Y)) { return(cell); } } foreach (var cell in this.Owner.Model.ForEachRowCell(row)) { if (cell.layoutSlot.Contains(point.X, point.Y)) { return(cell); } } return(null); }
private void UpdateLabels(RadSize availableSize) { RadRect availableRect = new RadRect(availableSize.Width, availableSize.Height); RadRect ellipseRect = RadRect.ToSquare(availableRect, false); ellipseRect = RadRect.CenterRect(ellipseRect, availableRect); double radius = ellipseRect.Width / 2; RadPoint center = ellipseRect.Center; RadPoint arcPosition; foreach (AxisLabelModel label in this.owner.labels) { if (!label.isVisible) { continue; } double angle = this.owner.IsInverse ? 360 - (double)label.normalizedPosition * 360 : (double)label.normalizedPosition * 360; arcPosition = RadMath.GetArcPoint(angle, center, radius); this.UpdateMargins(ellipseRect, label.desiredSize, arcPosition); } double offset = this.owner.LineThickness + this.owner.MajorTickLength; this.margins.Left += offset; this.margins.Top += offset; this.margins.Right += offset; this.margins.Bottom += offset; }
private static RadRect CalculatePlotAreaRect(RadRect availableRect, AxisStack leftStack, AxisStack topStack, AxisStack rightStack, AxisStack bottomStack) { RadPoint topLeft = new RadPoint(); double finalLeftRectWidth = leftStack.desiredWidth + leftStack.desiredMargin.Left + leftStack.desiredMargin.Right; double maxLeftMargin = Math.Max(topStack.desiredMargin.Left, bottomStack.desiredMargin.Left); topLeft.X = Math.Max(finalLeftRectWidth, maxLeftMargin); double finalTopRectHeight = topStack.desiredHeight + topStack.desiredMargin.Top + topStack.desiredMargin.Bottom; double maxTopMargin = Math.Max(leftStack.desiredMargin.Top, rightStack.desiredMargin.Top); topLeft.Y = Math.Max(finalTopRectHeight, maxTopMargin); RadPoint bottomRight = new RadPoint(); double finalRightRectWidth = rightStack.desiredWidth + rightStack.desiredMargin.Left + rightStack.desiredMargin.Right; double maxRightMargin = Math.Max(topStack.desiredMargin.Right, bottomStack.desiredMargin.Right); bottomRight.X = availableRect.Width - Math.Max(finalRightRectWidth, maxRightMargin); double finalBottomRectHeight = bottomStack.desiredHeight + bottomStack.desiredMargin.Top + bottomStack.desiredMargin.Bottom; double maxBottomMargin = Math.Max(leftStack.desiredMargin.Bottom, rightStack.desiredMargin.Bottom); bottomRight.Y = availableRect.Height - Math.Max(finalBottomRectHeight, maxBottomMargin); RadRect plotAreaRect = new RadRect(topLeft, bottomRight); return(RadRect.Round(plotAreaRect)); }
public ChartAnnotationLabelUpdateContext(RadRect layoutSlot) { this.LayoutSlot = layoutSlot; this.Location = layoutSlot.Location; this.Definition = null; }
private void UpdateMargins(RadRect availableRect, RadSize labelSize, RadPoint arcPosition) { double left = arcPosition.X - labelSize.Width; if (left < availableRect.X) { this.margins.Left = Math.Max(this.margins.Left, availableRect.X - left); } double top = arcPosition.Y - labelSize.Height; if (top < availableRect.Y) { this.margins.Top = Math.Max(this.margins.Top, availableRect.Y - top); } double right = arcPosition.X + labelSize.Width; if (right > availableRect.Right) { this.margins.Right = Math.Max(this.margins.Right, right - availableRect.Right); } double bottom = arcPosition.Y + labelSize.Height; if (bottom > availableRect.Bottom) { this.margins.Bottom = Math.Max(this.margins.Bottom, bottom - availableRect.Bottom); } }
/// <summary> /// Initializes a new instance of the <see cref="RadLine" /> struct. /// </summary> /// <param name="point1">The point1.</param> /// <param name="point2">The point2.</param> public RadLine(RadPoint point1, RadPoint point2) { this.X1 = point1.X; this.Y1 = point1.Y; this.X2 = point2.X; this.Y2 = point2.Y; }
protected override RadRect ArrangeCore(RadRect rect) { IChartView view = this.GetChartArea().view; RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight); RadPoint point1, point2; double panOffsetX = view.PlotOriginX * rect.Width; double panOffsetY = view.PlotOriginY * rect.Height; if (this.axis.type == AxisType.First) { point1 = new RadPoint(panOffsetX + this.firstPlotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Y + panOffsetY); point2 = new RadPoint(panOffsetX + this.secondPlotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Bottom + panOffsetY); } else { point1 = new RadPoint(plotAreaVirtualSize.X + panOffsetX, panOffsetY + this.firstPlotInfo.CenterY(plotAreaVirtualSize)); point2 = new RadPoint(plotAreaVirtualSize.Right + panOffsetX, panOffsetY + this.secondPlotInfo.CenterY(plotAreaVirtualSize)); } var arrangeRect = new RadRect(point1, point2); this.originalLayoutSlot = arrangeRect; return(AnnotationHelper.ClipRectangle(arrangeRect, rect, this.StrokeThickness * 2, this.DashPatternLength * this.StrokeThickness)); }
protected override RadRect ArrangeCore(RadRect rect) { IChartView view = this.GetChartArea().view; RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight); RadPoint point1, point2; double panOffsetX = view.PlotOriginX * rect.Width; double panOffsetY = view.PlotOriginY * rect.Height; if (this.axis.type == AxisType.First) { point1 = new RadPoint(panOffsetX + this.plotInfo.CenterX(plotAreaVirtualSize), plotAreaVirtualSize.Y + panOffsetY); point2 = new RadPoint(point1.X, plotAreaVirtualSize.Bottom + panOffsetY); } else { point1 = new RadPoint(plotAreaVirtualSize.X + panOffsetX, panOffsetY + this.plotInfo.CenterY(plotAreaVirtualSize)); point2 = new RadPoint(plotAreaVirtualSize.Right + panOffsetX, point1.Y); } this.line = new RadLine(point1, point2); this.originalLayoutSlot = new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2)); this.line = AnnotationHelper.ClipGridLine(this.line, rect, this.StrokeThickness * 2, this.DashPatternLength * this.StrokeThickness); this.line = RadLine.Round(this.line); return(new RadRect(new RadPoint(this.line.X1, this.line.Y1), new RadPoint(this.line.X2, this.line.Y2))); }
public override void ArrangeContent(RadSize adjustedfinalSize, double topOffset) { bool initialized = false; var topLeft = new RadPoint(0, 0); int elementSequenceNumber = 0; foreach (var pair in this.GetDisplayedElements()) { var decorators = pair.Value; RadRect arrangeRect = new RadRect(); double length = this.IsHorizontal ? adjustedfinalSize.Height : adjustedfinalSize.Width; double itemEnd = 0; foreach (var decorator in decorators) { if (!initialized || elementSequenceNumber != decorator.ItemInfo.Slot) { initialized = true; var offset = decorator.ItemInfo.Slot != 0 ? this.layout.PhysicalOffsetFromSlot(decorator.ItemInfo.Slot - 1) : 0; elementSequenceNumber = decorator.ItemInfo.Slot; if (this.IsHorizontal) { topLeft.X = offset; } else { topLeft.Y = offset + topOffset; } } itemEnd = this.layout.PhysicalOffsetFromSlot(decorator.ItemInfo.Slot); if (this.IsHorizontal) { arrangeRect = new RadRect(topLeft.X, topLeft.Y, itemEnd - topLeft.X, length); } else { arrangeRect = new RadRect(topLeft.X, topLeft.Y, length, itemEnd - topLeft.Y + topOffset); } decorator.LayoutSlot = arrangeRect; this.Owner.Arrange(decorator); } if (this.IsHorizontal) { topLeft.X += arrangeRect.Width; } else { topLeft.Y += arrangeRect.Height; } elementSequenceNumber++; } this.ArrangeFrozenDecorators(); }
protected override RadRect ArrangeCore(RadRect rect) { this.radius = rect.Width / 2; RadPoint center = rect.Center; AxisPlotInfo anglePlot1 = this.firstPlotInfo; double angle1 = 0d; NumericalAxisPlotInfo numericalAnglePlot1 = anglePlot1 as NumericalAxisPlotInfo; if (numericalAnglePlot1 != null) { angle1 = numericalAnglePlot1.ConvertToAngle(); } else { CategoricalAxisPlotInfo categoricalAnglePlot1 = anglePlot1 as CategoricalAxisPlotInfo; if (categoricalAnglePlot1 != null) { angle1 = categoricalAnglePlot1.ConvertToAngle(this.GetChartArea <PolarChartAreaModel>()); } } RadPoint arcPoint1 = RadMath.GetArcPoint(angle1, center, this.radius); this.polarVector1 = new RadPolarVector() { Point = arcPoint1, Angle = angle1, Center = center }; AxisPlotInfo anglePlot2 = this.secondPlotInfo; double angle2 = 0d; NumericalAxisPlotInfo numericalAnglePlot2 = anglePlot2 as NumericalAxisPlotInfo; if (numericalAnglePlot2 != null) { angle2 = numericalAnglePlot2.ConvertToAngle(); } else { CategoricalAxisPlotInfo categoricalAnglePlot2 = anglePlot2 as CategoricalAxisPlotInfo; if (categoricalAnglePlot2 != null) { angle2 = categoricalAnglePlot2.ConvertToAngle(this.GetChartArea <PolarChartAreaModel>()); } } RadPoint arcPoint2 = RadMath.GetArcPoint(angle2, center, this.radius); this.polarVector2 = new RadPolarVector() { Point = arcPoint2, Angle = angle2, Center = center }; return(rect); }
internal static RadPoint GetArcPoint(double angle, RadPoint center, double radius) { double angleInRad = angle * RadMath.DegToRadFactor; double x = center.X + (Math.Cos(angleInRad) * radius); double y = center.Y - (Math.Sin(angleInRad) * radius); return(new RadPoint(x, y)); }
internal void UpdateEditRow(ItemInfo info, RadPoint startPosition, bool hasFrozenColumns) { this.renderInfo.Update(0, startPosition.Y); if (!this.initialized) { this.initialized = true; var editRow = this.GetDecorator(new RowGenerationContext(info, false)); editRow.ItemInfo = new ItemInfo { Item = info.Item, Slot = 1 }; editRow.ReadOnlyRowInfo = info; this.EditRow = editRow; var frozenEditRow = this.GetFrozenDecorator(new RowGenerationContext(info, true)); frozenEditRow.ItemInfo = new ItemInfo { Item = info.Item, Slot = 1 }; frozenEditRow.ReadOnlyRowInfo = info; this.FrozenEditRow = frozenEditRow; } this.generator.PrepareContainerForItem(this.EditRow); var size = this.table.Measure(this.EditRow); var height = this.table.GenerateCellsForRow(1, size.Height, this.EditRow); // var frozenHeight = this.table.GenerateCellsForRow(1, frozenSize.Height, this.FrozenEditRow); // var updatedHeight = Math.Max(height, frozenHeight); var updatedHeight = height; this.renderInfo.Update(1, updatedHeight); this.EditRow.DesiredSize = new RadSize(size.Width, updatedHeight); this.EditRow.layoutSlot = new RadRect(startPosition.X, startPosition.Y, this.EditRow.DesiredSize.Width, this.EditRow.DesiredSize.Height); this.generator.PrepareContainerForItem(this.FrozenEditRow); var frozenSize = this.table.Measure(this.FrozenEditRow); this.FrozenEditRow.DesiredSize = new RadSize(size.Width, updatedHeight); this.FrozenEditRow.layoutSlot = new RadRect(startPosition.X, startPosition.Y, this.FrozenEditRow.DesiredSize.Width, this.FrozenEditRow.DesiredSize.Height); if (!hasFrozenColumns) { this.generator.MakeHidden(this.FrozenEditRow); } this.displayedElement = new KeyValuePair <int, List <GridRowModel> >(1, new List <GridRowModel> { this.EditRow, this.FrozenEditRow }); }
protected override RadRect ArrangeCore(RadRect rect) { double radius = rect.Width / 2; RadPoint center = rect.Center; NumericalAxisPlotInfo polarPlot = this.plotInfo as NumericalAxisPlotInfo; double pointRadius = polarPlot.NormalizedValue * radius; this.polarLine = new RadCircle(center, pointRadius); return(this.polarLine.Bounds); }
/// <summary> /// Converts the specified data point coordinates to physical coordinates (in pixels) using the specified chart axes. /// </summary> /// <param name="data">The data point coordinates according to the specified chart axes.</param> /// <param name="horizontalAxis">The horizontal axis.</param> /// <param name="verticalAxis">The vertical axis.</param> public Point ConvertDataToPoint(Tuple <object, object> data, Axis horizontalAxis, Axis verticalAxis) { if (data == null || horizontalAxis == null || verticalAxis == null) { return(new Point(double.NaN, double.NaN)); } RadPoint coordinates = (this.chartArea as CartesianChartAreaModel).ConvertDataToPoint(data, horizontalAxis.model, verticalAxis.model); return(coordinates.ToPoint()); }
/// <summary> /// Converts the specified data point coordinates to physical coordinates (in pixels) using the primary chart axes (if any). /// </summary> /// <param name="data">The data point coordinates according to the primary chart axes (if any).</param> public Point ConvertDataToPoint(Tuple <object, object> data) { if (data == null) { return(new Point(double.NaN, double.NaN)); } RadPoint coordinates = (this.chartArea as CartesianChartAreaModel).ConvertDataToPoint(data); return(coordinates.ToPoint()); }
internal RadSize OnArrange(RadSize finalSize) { if (!this.isHorizontal) { // The CellsController will handle rows and cells arrange // this.ArrangeFrozenDecorators(); return(finalSize); } bool initialized = false; var topLeft = new RadPoint(0, 0); int elementSequenceNumber = 0; foreach (var pair in this.GetDisplayedElements()) { var decorators = pair.Value; RadRect arrangeRect = new RadRect(); double length = this.GetElementArrangeLength(pair.Key); foreach (var decorator in decorators) { if (!initialized || elementSequenceNumber != decorator.ItemInfo.Slot) { initialized = true; topLeft.X = decorator.ItemInfo.Slot != 0 ? this.RenderInfo.OffsetFromIndex(decorator.ItemInfo.Slot - 1) : 0; elementSequenceNumber = decorator.ItemInfo.Slot; } int level = decorator.ItemInfo.LayoutInfo.Level; int indent = 0; double indentOffset = indent * 20; double offset = 0; int temp = level; while (temp > 0) { offset += this.columnWidth[--temp]; } // the code is executed for Horizontal pool arrangeRect = new RadRect(topLeft.X, topLeft.Y + offset + indentOffset, length, this.columnWidth[level] - indentOffset); decorator.layoutSlot = arrangeRect; this.owner.Arrange(decorator); } topLeft.X += arrangeRect.Width; elementSequenceNumber++; } return(finalSize); }
/// <summary> /// Converts the specified physical coordinates in pixels to data using the specified chart axes. /// </summary> /// <param name="coordinates">The physical coordinates.</param> /// <param name="horizontalAxis">The horizontal axis.</param> /// <param name="verticalAxis">The vertical axis.</param> public Tuple <object, object> ConvertPointToData(Point coordinates, Axis horizontalAxis, Axis verticalAxis) { if (horizontalAxis == null || verticalAxis == null || this.chartArea == null) { return(new Tuple <object, object>(null, null)); } RadPoint point = new RadPoint(coordinates.X, coordinates.Y); var chartArea = this.chartArea as CartesianChartAreaModel; return(chartArea.ConvertPointToData(point, horizontalAxis.model, verticalAxis.model)); }
protected override RadRect ArrangeCore(RadRect rect) { IChartView view = this.GetChartArea().view; RadRect plotAreaVirtualSize = new RadRect(rect.X, rect.Y, rect.Width * view.ZoomWidth, rect.Height * view.ZoomHeight); double panOffsetX = view.PlotOriginX * rect.Width; double panOffsetY = view.PlotOriginY * rect.Height; RadPoint centerPoint = new RadPoint(panOffsetX + this.firstPlotInfo.CenterX(plotAreaVirtualSize), panOffsetY + this.secondPlotInfo.CenterY(plotAreaVirtualSize)); RadSize desiredSize = this.Measure(); return(new RadRect(centerPoint.X, centerPoint.Y, desiredSize.Width, desiredSize.Height)); }
public static Geometry RenderArc(DoughnutSegmentData context) { PathFigure figure = new PathFigure(); figure.IsClosed = true; figure.IsFilled = true; RadPoint startPoint = RadMath.GetArcPoint(context.StartAngle, context.Center, context.Radius1); figure.StartPoint = startPoint.ToPoint(); ArcSegment firstArc = new ArcSegment(); firstArc.Size = new Size(context.Radius1, context.Radius1); firstArc.IsLargeArc = context.SweepAngle > 180 || context.SweepAngle < -180; var angle = context.StartAngle; if (context.SweepDirection == SweepDirection.Clockwise) { angle += context.SweepAngle; } else { angle -= context.SweepAngle; } firstArc.SweepDirection = context.SweepAngle > 0 ? context.SweepDirection : context.SweepDirection ^ SweepDirection.Clockwise; firstArc.Point = RadMath.GetArcPoint(angle, context.Center, context.Radius1).ToPoint(); figure.Segments.Add(firstArc); LineSegment firstLine = new LineSegment(); firstLine.Point = RadMath.GetArcPoint(angle, context.Center, context.Radius2).ToPoint(); figure.Segments.Add(firstLine); ArcSegment secondArc = new ArcSegment(); secondArc.Size = new Size(context.Radius2, context.Radius2); secondArc.IsLargeArc = context.SweepAngle > 180 || context.SweepAngle < -180; secondArc.SweepDirection = context.SweepAngle > 0 ? context.SweepDirection ^ SweepDirection.Clockwise : context.SweepDirection; secondArc.Point = RadMath.GetArcPoint(context.StartAngle, context.Center, context.Radius2).ToPoint(); figure.Segments.Add(secondArc); PathGeometry geometry = new PathGeometry(); geometry.Figures.Add(figure); return(geometry); }
private static PathGeometry RenderArc(RadialSegment segment) { var layoutSlot = segment.LayoutSlot; var centerPoint = new RadPoint(layoutSlot.OuterRadius, layoutSlot.OuterRadius); PathFigure figure = new PathFigure(); figure.IsClosed = true; figure.IsFilled = true; // Change the geometry if selected double outerRadius = layoutSlot.OuterRadius; RadPoint startPoint = GetArcPoint(layoutSlot.StartAngle, centerPoint, outerRadius); figure.StartPoint = new Point(startPoint.X, startPoint.Y); ArcSegment firstArc = new ArcSegment(); firstArc.Size = new Size(outerRadius, outerRadius); firstArc.IsLargeArc = layoutSlot.SweepAngle > 180; firstArc.SweepDirection = SweepDirection.Counterclockwise; var firstArcPoint = GetArcPoint(layoutSlot.StartAngle + layoutSlot.SweepAngle, centerPoint, outerRadius); firstArc.Point = new Point(firstArcPoint.X, firstArcPoint.Y); figure.Segments.Add(firstArc); LineSegment firstLine = new LineSegment(); var firstLinePoint = GetArcPoint(layoutSlot.StartAngle + layoutSlot.SweepAngle, centerPoint, layoutSlot.InnerRadius); firstLine.Point = new Point(firstLinePoint.X, firstLinePoint.Y); figure.Segments.Add(firstLine); ArcSegment secondArc = new ArcSegment(); secondArc.Size = new Size(layoutSlot.InnerRadius, layoutSlot.InnerRadius); secondArc.IsLargeArc = layoutSlot.SweepAngle > 180; secondArc.SweepDirection = SweepDirection.Clockwise; var secondArcPoint = GetArcPoint(layoutSlot.StartAngle, centerPoint, layoutSlot.InnerRadius); secondArc.Point = new Point(secondArcPoint.X, secondArcPoint.Y); figure.Segments.Add(secondArc); PathGeometry geometry = new PathGeometry(); geometry.Figures.Add(figure); return(geometry); }
private PathGeometry RenderArrow() { if (this.LayoutSlot == null) { return(null); } this.LayoutSlot.StartAngle = this.Segment.LayoutSlot.StartAngle; this.LayoutSlot.SweepAngle = this.Segment.LayoutSlot.SweepAngle; this.LayoutSlot.InnerRadius = this.Segment.LayoutSlot.OuterRadius; var centerPoint = new RadPoint(this.layoutSlot.InnerRadius, this.layoutSlot.InnerRadius); PathFigure figure = new PathFigure(); figure.IsClosed = true; figure.IsFilled = true; double arrowSize = this.layoutSlot.SweepAngle * (this.arrowThicknessFactorCache / 3.0); double outerRadius = this.layoutSlot.InnerRadius + 1; double startAngle = this.layoutSlot.StartAngle + (this.layoutSlot.SweepAngle / 2) - arrowSize; double endAngle = (this.layoutSlot.StartAngle + this.layoutSlot.SweepAngle) - (this.layoutSlot.SweepAngle / 2) + arrowSize; RadPoint startPoint = GetArcPoint(startAngle, centerPoint, outerRadius); figure.StartPoint = new Point(startPoint.X, startPoint.Y); ArcSegment firstArc = new ArcSegment(); firstArc.Size = new Size(outerRadius, outerRadius); firstArc.IsLargeArc = this.layoutSlot.SweepAngle > 180; firstArc.SweepDirection = SweepDirection.Counterclockwise; var firstArcPoint = GetArcPoint(endAngle, centerPoint, outerRadius); firstArc.Point = new Point(firstArcPoint.X, firstArcPoint.Y); figure.Segments.Add(firstArc); LineSegment firstLine = new LineSegment(); var firstLinePoint = GetArcPoint((startAngle + endAngle) / 2, centerPoint, this.layoutSlot.InnerRadius - arrowSize * 2); firstLine.Point = new Point(firstLinePoint.X, firstLinePoint.Y); figure.Segments.Add(firstLine); PathGeometry geometry = new PathGeometry(); geometry.Figures.Add(figure); return(geometry); }
private void ArrangeArrowGlyph() { this.arrowGlyph.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var centerPoint = new RadPoint(this.Model.LayoutSlot.OuterRadius - 1, this.Model.LayoutSlot.OuterRadius - 1); var middleRadius = (this.Model.LayoutSlot.OuterRadius - this.Model.LayoutSlot.InnerRadius) / 2 + this.Model.LayoutSlot.InnerRadius + this.arrowGlyph.ActualHeight / 2; var atangAngle = Math.Atan(this.arrowGlyph.ActualWidth / middleRadius) * 180 / Math.PI; var itemCenterAngle = (this.Model.LayoutSlot.SweepAngle / 2 + this.model.LayoutSlot.StartAngle) + atangAngle / 2; RadPoint startPoint = GetArcPoint(itemCenterAngle, centerPoint, middleRadius); this.arrowGlyph.Margin = new Thickness(startPoint.X, startPoint.Y, 0, 0); }
private static void UpdateDataPointsInSelectionRectangle(RadCartesianChart chart) { Point fromPosition = GetFromPosition(chart); Point toPosition = GetToPosition(chart); Rect rect = new Rect(fromPosition, toPosition); foreach (CategoricalSeries series in chart.Series) { foreach (CategoricalDataPoint dp in series.DataPoints) { RadPoint point = dp.LayoutSlot.Center; dp.IsSelected = rect.Contains(new Point(point.X, point.Y)); } } }
internal override void UpdateAxisLine(ChartLayoutContext context) { PolarChartAreaModel chartArea = this.chart.chartArea as PolarChartAreaModel; double angle = chartArea.NormalizeAngle(0); RadPoint center = chartArea.plotArea.layoutSlot.Center; RadPoint point = RadMath.GetArcPoint(angle, center, chartArea.plotArea.layoutSlot.Width / 2); double antiAliasOffset = this.model.LineThickness % 2 == 1 ? 0.5 : 0; this.line.X1 = center.X; this.line.Y1 = center.Y - antiAliasOffset; this.line.X2 = point.X; this.line.Y2 = point.Y - antiAliasOffset; base.UpdateAxisLine(context); }