在C#上以环形式构造一个形状

And*_*hin 1 .net c# shape

我需要构造环的方法(сircle从中切割一个较小半径的圆)并将其返回为System.Windows.Shapes.Shape.我可以这样做Path吗?可能存在另一种方式?

Jon*_*eet 7

你能用一个非常粗的笔划但是透明填充的椭圆吗?不可否认,如果您希望环本身的边缘与填充部分的颜色不同,则不起作用......

可替换地,我会开始寻找一个Path包含两个EllipseGeometry在一个元件GeometryGroupFillRuleEvenOddCombineGeometryGeometryCombineModeExclude.例如:

<Path Stroke="Black" StrokeThickness="1" Fill="#CCCCFF">
  <Path.Data>
    <CombinedGeometry GeometryCombineMode="Exclude">
      <CombinedGeometry.Geometry1>
        <EllipseGeometry RadiusX="100" RadiusY="100" Center="125,125" />
      </CombinedGeometry.Geometry1>
      <CombinedGeometry.Geometry2>
        <EllipseGeometry RadiusX="50" RadiusY="50" Center="125,125" />
      </CombinedGeometry.Geometry2>
    </CombinedGeometry>
  </Path.Data>
</Path>
Run Code Online (Sandbox Code Playgroud)

产生这个:

替代文字

我是否正确地说那是你追求的?