帮朋友做的vb.net的代码
1
Public Class Form1
2
Dim gfxobj As System.Drawing.Graphics
3
Dim count As Integer
4
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
5
Handles MyBase.Load
6
gfxobj = pnlDraw.CreateGraphics()
7
Timer1.Enabled = False
8
lblSpeed.Text = "Current Fill Speed = " & trbSpeed.Value & " ms"
9
count = 0
10
End Sub
11
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
12
If Not gfxobj Is Nothing Then
13
gfxobj.Dispose()
14
End If
15
gfxobj = pnlDraw.CreateGraphics()
16
gfxobj.Clear(pnlDraw.BackColor)
17
End Sub
18
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
19
Dim newBrush As Brush
20
newBrush = New SolidBrush(Color.Blue)
21
If count < 180 Then
22
gfxobj.FillRectangle(newBrush, 31, 298 - count, 98, 1)
23
count = count + 1
24
Else
25
Timer1.Enabled = False
26
StopWaterFall()
27
End If
28
End Sub
29
Private Sub trbSpeed_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trbSpeed.Scroll
30
Timer1.Interval = trbSpeed.Value
31
lblSpeed.Text = "Current Fill Speed = " & trbSpeed.Value & " ms"
32
End Sub
33
Sub DrawBeaker()
34
Dim newPen = New Pen(Color.White, 2)
35
gfxobj.DrawLine(newPen, 30, 300, 130, 300)
36
gfxobj.DrawLine(newPen, 30, 100, 30, 300)
37
gfxobj.DrawLine(newPen, 130, 100, 130, 300)
38
End Sub
39
Sub DrawWaterFall()
40
Dim newBrush As Brush
41
newBrush = New SolidBrush(Color.Blue)
42
gfxobj.FillRectangle(newBrush, 66, 48, 23, 251)
43
End Sub
44
Sub CleanWaterFall()
45
Dim newBrush As Brush
46
newBrush = New SolidBrush(Color.Black)
47
gfxobj.FillRectangle(newBrush, 66, 48, 23, 251)
48
End Sub
49
Sub StopWaterFall()
50
Dim newBrush As Brush
51
newBrush = New SolidBrush(Color.Black)
52
gfxobj.FillRectangle(newBrush, 66, 48, 23, 71)
53
End Sub
54
Sub CleanWater()
55
Dim newBrush As Brush
56
newBrush = New SolidBrush(Color.Black)
57
gfxobj.FillRectangle(newBrush, 31, 118, 98, 181)
58
End Sub
59
Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click
60
DrawBeaker()
61
CleanWater()
62
DrawWaterFall()
63
count = 0
64
Me.Timer1.Enabled = True
65
End Sub
66
End Class
67
Public Class Form12
Dim gfxobj As System.Drawing.Graphics3
Dim count As Integer4
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _5
Handles MyBase.Load6
gfxobj = pnlDraw.CreateGraphics()7
Timer1.Enabled = False8
lblSpeed.Text = "Current Fill Speed = " & trbSpeed.Value & " ms"9
count = 010
End Sub11
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize12
If Not gfxobj Is Nothing Then13
gfxobj.Dispose()14
End If15
gfxobj = pnlDraw.CreateGraphics()16
gfxobj.Clear(pnlDraw.BackColor)17
End Sub18
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick19
Dim newBrush As Brush20
newBrush = New SolidBrush(Color.Blue)21
If count < 180 Then22
gfxobj.FillRectangle(newBrush, 31, 298 - count, 98, 1)23
count = count + 124
Else25
Timer1.Enabled = False26
StopWaterFall()27
End If28
End Sub29
Private Sub trbSpeed_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trbSpeed.Scroll30
Timer1.Interval = trbSpeed.Value31
lblSpeed.Text = "Current Fill Speed = " & trbSpeed.Value & " ms"32
End Sub33
Sub DrawBeaker()34
Dim newPen = New Pen(Color.White, 2)35
gfxobj.DrawLine(newPen, 30, 300, 130, 300)36
gfxobj.DrawLine(newPen, 30, 100, 30, 300)37
gfxobj.DrawLine(newPen, 130, 100, 130, 300)38
End Sub39
Sub DrawWaterFall()40
Dim newBrush As Brush41
newBrush = New SolidBrush(Color.Blue)42
gfxobj.FillRectangle(newBrush, 66, 48, 23, 251)43
End Sub44
Sub CleanWaterFall()45
Dim newBrush As Brush46
newBrush = New SolidBrush(Color.Black)47
gfxobj.FillRectangle(newBrush, 66, 48, 23, 251)48
End Sub49
Sub StopWaterFall()50
Dim newBrush As Brush51
newBrush = New SolidBrush(Color.Black)52
gfxobj.FillRectangle(newBrush, 66, 48, 23, 71)53
End Sub54
Sub CleanWater()55
Dim newBrush As Brush56
newBrush = New SolidBrush(Color.Black)57
gfxobj.FillRectangle(newBrush, 31, 118, 98, 181)58
End Sub59
Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click60
DrawBeaker()61
CleanWater()62
DrawWaterFall()63
count = 064
Me.Timer1.Enabled = True65
End Sub66
End Class67



浙公网安备 33010602011771号