如何使PolyLineSegment的角落圆滑?

时间:2017-10-10 14:45:22

标签: c# wpf geometry

我想创建一个不规则形状的窗口。我做了类似于我最终要创造的东西,但我想要圆角的东西。我在某处读到PolyLineSegment不可能,你能告诉我如何创建它吗?我应该使用什么对象/对象集合?

    <Window   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 mc:Ignorable="d" 
                 d:DesignHeight="250" d:DesignWidth="400"
                 AllowsTransparency="True"
                 OpacityMask="White"
                 WindowStyle="None"
                 Background="Transparent"
                 >
      <Canvas>
        <Path Height="250"
              Stroke="Gray"
              StrokeThickness="2"
              Name="UIPath"

              >
          <Path.Fill>
            <SolidColorBrush Color="Aqua">
            </SolidColorBrush>
          </Path.Fill>
          <Path.Data>
            <PathGeometry>
              <PathFigureCollection>
                <PathFigure StartPoint="0,0"
                            IsClosed="True">
                  <PolyLineSegment IsSmoothJoin="True" Points="400,000"  />

                  <PolyLineSegment IsSmoothJoin="True"
                                   Points="400,200" />
                  <PolyLineSegment IsSmoothJoin="True"
                                   Points="180,200" />

                  <PolyLineSegment IsSmoothJoin="True"
                                   Points="200,250" />
                  <PolyLineSegment IsSmoothJoin="True"
                                   Points="100,200" />

                  <PolyLineSegment IsSmoothJoin="True"
                                   Points="00,200"  />

                </PathFigure>
              </PathFigureCollection>
            </PathGeometry>
          </Path.Data>
          <Path.ContextMenu>
            <ContextMenu>
              <MenuItem Header="Minimize"
                        Name="mnuInvokeMinimize"  />
              <MenuItem Header="Maximize"
                        Name="mnuInvokeMaximize" />
              <MenuItem Header="Restore Down"
                        Name="mnuInvokeRestore" />
              <MenuItem Header="Close"
                        Name="mnuInvokeClose" />
            </ContextMenu>
          </Path.ContextMenu>
          <Path.RenderTransform>
            <TransformGroup x:Name="pathTfg">
              <ScaleTransform ScaleX="1"
                              ScaleY="1" />
              <TranslateTransform />
            </TransformGroup>
          </Path.RenderTransform>
        </Path>
      </Canvas>
    </Window>

1 个答案:

答案 0 :(得分:1)

您可以使用带有圆角的CombinedGeometry的{​​{1}}和剩余部分的RectangleGeometry

PathGeometry