简体   繁体   English

在WPF / C中绘制一个半圆/半圆#

[英]Draw a semicircle / half circle in WPF / C#

I need to draw a semicircle / half circle in WPF. 我需要在WPF中绘制一个半圆/半圆。 Any idea how to do that? 知道怎么做吗? Thanks for any hint! 谢谢你的提示!

ArcSegment would be a good place to start. ArcSegment将是一个很好的起点。

And here is a good example of how to use it in code. 是一个如何在代码中使用它的一个很好的例子。

Since the original link is dead, here's how I was able to draw an arc: 由于原始链接已死,以下是我能够绘制弧线的方法:

<Canvas>
    <Path Stroke="Gray">
        <Path.Data>
            <PathGeometry>
                <PathGeometry.Figures>
                    <PathFigureCollection>
                        <PathFigure StartPoint="0,20">
                            <PathFigure.Segments>
                                <PathSegmentCollection>
                                    <ArcSegment Size="20, 20"
                                    IsLargeArc="True"
                                    SweepDirection="CounterClockwise"
                                    Point="40,20" />
                                </PathSegmentCollection>
                            </PathFigure.Segments>
                        </PathFigure>
                    </PathFigureCollection>
                </PathGeometry.Figures>
            </PathGeometry>
        </Path.Data>
    </Path>
</Canvas>

That produces the following image (with added markings for some of the variables) 这会产生以下图像(为某些变量添加了标记)

在此输入图像描述

The XAML above is a modified version of the XAML found here: 上面的XAML是此处的XAML的修改版本:

https://www.c-sharpcorner.com/UploadFile/mahesh/drawing-arc-using-arcsegment-in-xaml/ https://www.c-sharpcorner.com/UploadFile/mahesh/drawing-arc-using-arcsegment-in-xaml/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM