【问题标题】:WPF - IsLargeArc="false" doesn't work anymoreWPF - IsLargeArc="false" 不再起作用
【发布时间】:2014-09-17 09:08:49
【问题描述】:

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

图片是:

<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>

【问题讨论】:

标签: c# wpf xaml canvas path


【解决方案1】:

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

试试这个 xaml,我刚刚在你的 xaml 中修改了 arc 的大小

<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>

结果

【讨论】:

    【解决方案2】:

    也许你不完全理解 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-20
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-30
      • 1970-01-01
      相关资源
      最近更新 更多