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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| private t1 As New Microsoft.VisualBasic.PowerPacks.LineShape
Private t2 As New Microsoft.VisualBasic.PowerPacks.LineShape
Private t3 As New Microsoft.VisualBasic.PowerPacks.LineShape
Private t4 As New Microsoft.VisualBasic.PowerPacks.LineShape
Private f1 As New Microsoft.VisualBasic.PowerPacks.LineShape
Private f2 As New Microsoft.VisualBasic.PowerPacks.LineShape
Private canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Private Sub init()
With t1
.Name = "t1"
.X1 = 100
.X2 = 100
.Y1 = 50
.Y2 = 120
.BorderColor = Color.Blue
End With
With t2
.Name = "t2"
.X1 = 45
.X2 = 67
.Y1 = 50
.Y2 = 120
.BorderColor = Color.Blue
End With
With t3
.Name = "t3"
.X1 = 145
.X2 = 67
.Y1 = 150
.Y2 = 120
.BorderColor = Color.Blue
End With
With t4
.Name = "t4"
.X1 = 245
.X2 = 167
.Y1 = 150
.Y2 = 40
.BorderColor = Color.Blue
End With
With f1
.Name = "f1"
.X1 = 10
.X2 = 100
.Y1 = 70
.Y2 = 120
.BorderColor = Color.Red
End With
With f2
.Name = "f2"
.X1 = 30
.X2 = 120
.Y1 = 70
.Y2 = 220
.BorderColor = Color.Magenta
End With
canvas.Shapes.Add(t1)
canvas.Shapes.Add(t2)
canvas.Shapes.Add(t3)
canvas.Shapes.Add(t4)
canvas.Shapes.Add(f1)
canvas.Shapes.Add(f2)
canvas.Parent = Me
End Sub
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
init()
End Sub
Private Sub Button1_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseClick
' hide all lines with name starts with t
For Each l1 In canvas.Shapes
If DirectCast(l1, Microsoft.VisualBasic.PowerPacks.LineShape).Name.StartsWith("t") Then
DirectCast(l1, Microsoft.VisualBasic.PowerPacks.LineShape).Visible = False
End If
Next
End Sub |