下面的例子通過重載Form
窗體的OnPaint()方法繪制GDI圖形
Protected Overrides Sub onpaint(ByVal e As System
Windows
Forms
PaintEventArgs)
注釋
/////////////繪制任意直線
Dim g As Graphics = e
Graphics
Dim mypen As Pen = New Pen(Color
Red
)
g
DrawLine(mypen
)
注釋
/////////////繪制矩形(任意直線構成的封閉圖形)
Dim point
As PointF = New PointF(
F
F)
Dim point
As PointF = New PointF(
F
F)
Dim point
As PointF = New PointF(
F
F)
Dim point
As PointF = New PointF(
F
F)
Dim curvepoints As PointF() = {point
point
point
point
}
g
DrawPolygon(New Pen(Color
Blue
)
curvepoints)
注釋
////////////文本表示
Dim FFamily As FontFamily = New FontFamily(
Arial
)
Dim font As Font = New Font(FFamily
FontStyle
Bold
FontStyle
Italic
GraphicsUnit
Pixel)
Dim text As String =
I love you!
Dim solidbrush As SolidBrush = New SolidBrush(Color
Red)
Dim pr As PointF = New PointF(
)
e
Graphics
DrawString(text
font
solidbrush
pr)
注釋
////////////平面繪制
Dim rec As RectangleF = New RectangleF(
)
g
DrawPie(mypen
rec
)
注釋
///////////封閉圖形
應該是個圓
g
DrawClosedCurve(mypen
curvepoints
Drawing
Drawing
D
FillMode
Alternate)
注釋
///////////大家自己試試看吧
g
DrawArc(mypen
)
g
DrawCurve(mypen
curvepoints)
g
DrawBezier(mypen
)
g
DrawBeziers(mypen
curvepoints)
注釋
//////////這可是一個圓
Dim rec
As RectangleF = New RectangleF(
)
g
DrawEllipse(mypen
rec
)
注釋
//////////這是一個橢圓
Dim rec
As RectangleF = New RectangleF(
)
g
DrawEllipse(mypen
rec
)
End Sub
這些是我自己試驗出來的
當然了
還有好多
我只是開了一個頭
大家要是發現什麼好東東
別忘了通知一下
)
From:http://tw.wingwit.com/Article/program/net/201311/11800.html