在表单上绘制复杂的形状。 (。净)

时间:2011-03-17 01:25:09

标签: vb.net drawing

我有一个类似于以下内容的控件: Controls

我需要在所有额外的结束空间中添加略微圆形的末端。我不知道如何添加这些。它应该类似于this page.上的圆形末端(顶部)

谢谢!

1 个答案:

答案 0 :(得分:1)

迟了几年......但这可能是你问题的答案。

Public Sub DrawRoundedRectangle(ByVal objGraphics As Graphics, _
                                ByVal m_intxAxis As Integer, _
                                ByVal m_intyAxis As Integer, _
                                ByVal m_intWidth As Integer, _
                                ByVal m_intHeight As Integer, _
                                ByVal m_diameter As Integer)



   'Dim g As Graphics
    Dim BaseRect As New RectangleF(m_intxAxis, m_intyAxis, m_intWidth, 
                                  m_intHeight)
    Dim ArcRect As New RectangleF(BaseRect.Location,
                              New SizeF(m_diameter, m_diameter))
    'top left Arc
    objGraphics.DrawArc(Pens.Black, ArcRect, 180, 90)
    objGraphics.DrawLine(Pens.Black, m_intxAxis + CInt(m_diameter / 2), 
                         m_intyAxis, 
                         m_intxAxis + m_intWidth - CInt(m_diameter / 2), 
                         m_intyAxis)

    ' top right arc
    ArcRect.X = BaseRect.Right - m_diameter
    objGraphics.DrawArc(Pens.Black, ArcRect, 270, 90)
    objGraphics.DrawLine(Pens.Black, m_intxAxis + m_intWidth, 
                         m_intyAxis + CInt(m_diameter / 2), 
                         m_intxAxis + m_intWidth, 
                         m_intyAxis + m_intHeight - CInt(m_diameter / 2))

    ' bottom right arc
    ArcRect.Y = BaseRect.Bottom - m_diameter
    objGraphics.DrawArc(Pens.Black, ArcRect, 0, 90)
    objGraphics.DrawLine(Pens.Black, m_intxAxis + CInt(m_diameter / 2), 
                         m_intyAxis + m_intHeight, 
                         m_intxAxis + m_intWidth - CInt(m_diameter / 2), 
                         m_intyAxis + m_intHeight)

    ' bottom left arc
    ArcRect.X = BaseRect.Left
    objGraphics.DrawArc(Pens.Black, ArcRect, 90, 90)
    objGraphics.DrawLine(Pens.Black, 
                         m_intxAxis, m_intyAxis + CInt(m_diameter / 2), 
                         m_intxAxis, 
                         m_intyAxis + m_intHeight - CInt(m_diameter / 2))

End Sub

提供代码中的参数来绘制矩形,然后离开!