【发布时间】:2019-06-05 23:06:01
【问题描述】:
我正在尝试使用一系列弧段在 WPF 中创建自定义形状。形状本质上是一个带有断线的圆形,像这样
虽然我知道我可以使用 Ellipse 并设置破折号数组属性来实现类似的效果,但我需要处理不断变化的厚度和半径,即我必须保持可见段的数量不变,而使用破折号会变得很困难数组属性,因为它相对于笔画粗细。
因此,我尝试创建类似于 SO 问题 here 的自定义形状。该答案中描述的形状仅与绘制单个弧线有关,而我需要绘制一系列中间有间隙的弧线。这就是我正在尝试的
for ( int i = 1; i <= Segments; i++ )
{
var endpoint = PolarToCartesian(sweepAngle * i, Radius);
var drawArcSegment = i % 2 == 0;
if (drawArcSegment)
{
var arcSegment = new ArcSegment
{
Point = endpoint,
Size = new Size(Radius, Radius),
IsLargeArc = false,
SweepDirection = SweepDirection.Clockwise
};
}
else
{
// WHAT TO DO HERE?
// Need to either draw an arc segment that can't be seen but I can't apply
// style properties to an arc segment OR need to move the current point of the
// parent path figure to a new point that is the start of the following segment
}
}
这可能吗?我是否以正确的方式处理这个问题?
【问题讨论】:
标签: wpf custom-controls