WPF - IsLargeArc =“false”不再起作用

时间:2014-07-25 13:32:38

标签: c# wpf xaml canvas path

我最近想使用ArcSegment,但IsLargeArc="False"不起作用。下面是带有已编译应用程序图片的示例代码。

图片是:

enter image description here

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="1000" Width="1000">
    <Canvas Height="500" Width="500">
        <Path Stroke="Red" StrokeThickness="3">
            <Path.Data>
                <PathGeometry>
                    <PathFigure StartPoint="50, 50">
                        <ArcSegment Point="300, 50" IsLargeArc="False" Size="50,25" />
                    </PathFigure>
                </PathGeometry>
            </Path.Data>
        </Path>
        <Path Stroke="Green" StrokeThickness="3">
            <Path.Data>
                <PathGeometry>
                    <PathFigure StartPoint="50, 250">
                        <ArcSegment Point="300, 250" IsLargeArc="True" Size="50,25" />
                    </PathFigure>
                </PathGeometry>
            </Path.Data>
        </Path>
    </Canvas>
</Window>

2 个答案:

答案 0 :(得分:3)

直到弧的大小不允许两个不同的渲染选项IsLargeArc不会有任何区别

尝试这个xaml,我只修改了你的xaml中的弧的大小

<Canvas Height="500"
        Width="500">
    <Path Stroke="Red"
          StrokeThickness="3">
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="50, 50">
                    <ArcSegment Point="300, 50"
                                IsLargeArc="False"
                                Size="150,25" />
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>
    <Path Stroke="Green"
          StrokeThickness="3">
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="50, 250">
                    <ArcSegment Point="300, 250"
                                IsLargeArc="True"
                                Size="150,25" />
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>
</Canvas>

结果

result

答案 1 :(得分:0)

也许你还没有完全理解ArcSegment.IsLargeArc Property在链接页面中的作用......

  

对于特定位置,大小和旋转的大多数弧,可以绘制四种不同的弧; IsLargeArcSweepDirection属性指示要使用的弧。

因此,删除Point设置并添加SweepDirection设置,我们可以看到明显的差异:

<Canvas Height="500" Width="500">
    <Path Stroke="Red" StrokeThickness="3">
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="50, 50">
                    <ArcSegment IsLargeArc="False" Size="50,25" SweepDirection="Clockwise" />
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>
    <Path Stroke="Green" StrokeThickness="3">
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="50, 250">
                    <ArcSegment IsLargeArc="True" Size="50,25" SweepDirection="Counterclockwise" />
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>
</Canvas>