2020年5月6日 星期三

vb.net 自動在PictureBox畫形狀 [Draw in PictureBox]


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint

        Dim x As Integer = 10, y As Integer = 10

        Dim wid As Integer = 150, hgt As Integer = 75

        Dim g As Graphics = e.Graphics

        g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality

        g.FillRectangle(Brushes.AliceBlue, x, y, wid, hgt)

        g.DrawRectangle(Pens.Black, x, y, wid, hgt)


        y += hgt + 10

        g.FillEllipse(Brushes.LightGoldenrodYellow, x, y, wid, hgt)

        g.DrawEllipse(Pens.Black, x, y, wid, hgt)

        y += hgt + 10

        g.DrawLine(Pens.Black, x, y, x + wid, y + hgt)


        y = 10

        x += wid + 10

        g.DrawArc(Pens.Black, x, y, wid, hgt, -30, 270)

        y += hgt + 10

        g.DrawPie(Pens.Black, x, y, wid, hgt, -30, 270)

        y += hgt + 10


        Dim big_font As New Font("Comic Sans MS", 60, FontStyle.Bold, GraphicsUnit.Pixel)

        'g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit

        g.DrawString("Hello!", big_font, Brushes.Black, x, y)

    End Sub

沒有留言:

張貼留言