1
我正在WPF中使用不同的段类型(弧,贝塞尔,线段)绘制区域形状,并希望阻止它们创建复杂的区域形状。这就是说边缘重叠的形状。有没有好的方法来检查段在WPF中的PathFigure中是否重叠?
我正在使用由转换器生成的PathGeometry
,但在转换器完成后,XAML看起来像下面的XAML。
在没有重叠:
<Path x:Name="PolygonPath" Fill="Blue" Opacity="75">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="50,50" IsClosed="True" IsFilled="True">
<PathFigure.Segments>
<QuadraticBezierSegment Point1="100,0" Point2="200,50"/>
<LineSegment Point="250,50"/>
<LineSegment Point="250,200"/>
<QuadraticBezierSegment Point1="100,350" Point2="50,50"/>
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
随着重叠(应使测试失败):
<Path x:Name="PolygonPath" Fill="Blue" Opacity="75">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="50,50" IsClosed="True" IsFilled="True">
<PathFigure.Segments>
<QuadraticBezierSegment Point1="100,0" Point2="200,60"/>
<LineSegment Point="0,60"/>
<LineSegment Point="250,200"/>
<QuadraticBezierSegment Point1="100,350" Point2="50,50"/>
</PathFigure.Segments>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
在上述情况下,第二和第三线段<LineSegment Point="0,60"/>
和<LineSegment Point="250,200"/>
重叠的最后一个段<QuadraticBezierSegment Point1="100,350" Point2="50,50"/>
。
有没有一种方法我缺少测试路径是否与WPF中的任何点相交?
这是个不错的解决方案,但如果有多个数字它仅适用。我正在与一个有多个细分市场的人物合作。我会试着进一步澄清我的问题。谢谢。 – 2011-03-16 13:58:30