如何:合并文本行

线条连接是由两个线条的端点相交或重叠而形成的公共区域。 GDI+ 提供三种线条连接样式:斜接、平接和圆接。 线条联接样式是类的属性 Pen 。 为对象指定线条联接样式时,该联接样式 Pen 将应用于使用该笔绘制的任何 GraphicsPath 对象中的所有连接线。

下图显示了斜线联接示例的结果。

显示联接行的插图。

示例:

可以使用类的属性Pen指定线条联接样式LineJoin。 该示例演示水平线和垂直线之间的斜线联接。 在以下代码中,分配给LineJoin该属性的值Bevel是枚举的成员LineJoin。 枚举中的其他成员包括 LineJoinMiterRound

GraphicsPath path = new GraphicsPath();
Pen penJoin = new Pen(Color.FromArgb(255, 0, 0, 255), 8);

path.StartFigure();
path.AddLine(new Point(50, 200), new Point(100, 200));
path.AddLine(new Point(100, 200), new Point(100, 250));

penJoin.LineJoin = LineJoin.Bevel;
e.Graphics.DrawPath(penJoin, path);

Dim path As New GraphicsPath()
Dim penJoin As New Pen(Color.FromArgb(255, 0, 0, 255), 8)

path.StartFigure()
path.AddLine(New Point(50, 200), New Point(100, 200))
path.AddLine(New Point(100, 200), New Point(100, 250))

penJoin.LineJoin = LineJoin.Bevel
e.Graphics.DrawPath(penJoin, path)

编译代码

前面的示例设计用于 Windows 窗体,它需要 PaintEventArgse,这是 Paint 事件处理程序的参数。

另请参阅