Мне нужно написать какой-нибудь текст на каждом фрагменте PathGeometry на холсте, я знаю, что должен создать TextBlocks и заставить их вращаться, я сделал это, но это не совсем точно !!!
вот код:
var count = 100;
double PIES = Math.PI / count;
Point center = new Point(CanvasPanel.ActualWidth / 2, CanvasPanel.ActualHeight / 2);
double radius = 500;//0.1333 * Math.Min(CanvasPanel.ActualWidth, CanvasPanel.ActualHeight);
for (int i = 0; i <= count; i++)
{
Path path1 = new Path();
PathGeometry pathGeo = new PathGeometry();
PathFigure PathFig = new PathFigure();
double radians = 2 * Math.PI * i / count;
PathFig.StartPoint = center;
PathFig.Segments.Add(new LineSegment(new Point(center.X + radius * Math.Cos(radians + PIES), center.Y - radius * Math.Sin(radians + PIES)), true));
PathFig.Segments.Add(new ArcSegment(new Point(center.X + radius * Math.Cos(radians + 3 * PIES), center.Y - radius * Math.Sin(radians + 3 * PIES)), new Size(500, 500), 1, false, SweepDirection.Counterclockwise, true));
PathFig.Segments.Add(new LineSegment(center, true));
PathFig.IsClosed = true;
PathFig.IsFilled = true;
pathGeo.Figures.Add(PathFig);
pathGeo.FillRule = FillRule.Nonzero;
path1.Data = pathGeo;
path1.Stroke = Brushes.Black;
path1.Fill = Brushes.White;
path1.StrokeThickness = 0.25;
CanvasPanel.Children.Add(path1);
}
for (int i = count; i >= 0; i--)
{
double radians = 2 * Math.PI * i / count;
var text = new TextBlock()
{
Height = 30,
Background = Brushes.Transparent,
Text = "Lorem",
FontFamily = new FontFamily("Verdana"),
FontSize = 15,
RenderTransform = new TranslateTransform
{
X = center.X + 400 * Math.Cos(radians + PIES) - 50,
Y = center.Y - 400 * Math.Sin(radians + PIES) - 50
},
LayoutTransform = i < count / 2 ? new RotateTransform(radians/ (Math.PI / 180)) : new RotateTransform(-1 * radians/ (Math.PI / 180))
};
CanvasPanel.Children.Add(text);
}
В XAML у меня просто есть холст с именем CanvasPanel
Заранее спасибо.