private void CreateCircularText(string text) { EllipseGeometry rectangleGeometry = new EllipseGeometry(new Rect(15, 15, 160, 160)); PathGeometry pathGeometry = PathGeometry.CreateFromGeometry(rectangleGeometry); PathFigure pathFigure = pathGeometry.Figures[0]; TextOnPathWarped textOnPathWarped = new TextOnPathWarped(); textOnPathWarped.Text = text; textOnPathWarped.Foreground = Brushes.Black; textOnPathWarped.PathFigure = pathFigure; textOnPathWarped.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; textOnPathWarped.VerticalAlignment = System.Windows.VerticalAlignment.Center; RoundText.Child = textOnPathWarped; }
private void LoopThroughAllFlattenedPathPoints(PathGeometry pathGeometryDst, PathGeometry pathGeometrySrc, TextOnPathWarped.ProcessPoint callback) { for (int i = 0; i < pathGeometrySrc.Figures.Count; i++) { PathFigure pathFigure = pathGeometrySrc.Figures[i]; PathFigure pathFigure2 = pathGeometryDst.Figures[i]; pathFigure2.StartPoint = callback(pathFigure.StartPoint); for (int j = 0; j < pathFigure.Segments.Count; j++) { PathSegment pathSegment = pathFigure.Segments[j]; PathSegment pathSegment2 = pathFigure2.Segments[j]; if (pathSegment is LineSegment) { LineSegment lineSegment = pathSegment as LineSegment; LineSegment lineSegment2 = pathSegment2 as LineSegment; lineSegment2.Point = callback(lineSegment.Point); } else if (pathSegment is PolyLineSegment) { PointCollection points = (pathSegment as PolyLineSegment).Points; PointCollection points2 = (pathSegment2 as PolyLineSegment).Points; for (int k = 0; k < points.Count; k++) { points2[k] = callback(points[k]); } } } } }