Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Timer1.Tick
' Get the Graphics object of the form
Dim graph As Graphics = Graphics.FromHwnd(Handle)
' Generate a random number
Dim rndNumber As Random = New Random(DateTime.Now.Millisecond)
' Create a list of the colors of the .NET Framework
Dim curColor() As Color = _
{ _
Color.AliceBlue, Color.AntiqueWhite, Color.Aqua, _
Color.Aquamarine, Color.Azure, Color.Beige, _
Color.Bisque, Color.Black, Color.BlanchedAlmond, _
Color.Blue, Color.BlueViolet, Color.Brown, _
Color.BurlyWood, Color.CadetBlue, Color.Chartreuse, _
Color.Chocolate, Color.Coral, Color.CornflowerBlue, _
Color.Cornsilk, Color.Crimson, Color.Cyan, _
Color.DarkBlue, Color.DarkCyan, Color.DarkGoldenrod, _
Color.DarkGray, Color.DarkGreen, Color.DarkKhaki, _
Color.DarkMagenta, Color.DarkOliveGreen, _
Color.DarkOrange, Color.DarkOrchid, Color.DarkRed, _
Color.DarkSalmon, Color.DarkSeaGreen, _
Color.DarkSlateBlue, Color.DarkSlateGray, _
Color.DarkTurquoise, Color.DarkViolet, Color.DeepPink, _
Color.DeepSkyBlue, Color.DimGray, Color.DodgerBlue, _
Color.Firebrick, Color.FloralWhite, Color.ForestGreen, _
Color.Fuchsia, Color.Gainsboro, Color.GhostWhite, _
Color.Gold, Color.Goldenrod, Color.Gray, _
Color.Green, Color.GreenYellow, Color.Honeydew, _
Color.HotPink, Color.IndianRed, Color.Indigo, _
Color.Ivory, Color.Khaki, Color.Lavender, _
Color.LavenderBlush, Color.LawnGreen, Color.LemonChiffon, _
Color.LightBlue, Color.LightCoral, Color.LightCyan, _
Color.LightGoldenrodYellow, Color.LightGray, _
Color.LightGreen, Color.LightPink, Color.LightSalmon, _
Color.LightSeaGreen, Color.LightSkyBlue, _
Color.LightSlateGray, Color.LightSteelBlue, _
Color.LightYellow, Color.Lime, Color.LimeGreen, _
Color.Linen, Color.Magenta, Color.Maroon, _
Color.MediumAquamarine, Color.MediumBlue, _
Color.MediumOrchid, Color.MediumPurple, _
Color.MediumSeaGreen, Color.MediumSlateBlue, _
Color.MediumSpringGreen, Color.MediumTurquoise, _
Color.MediumVioletRed, Color.MidnightBlue, _
Color.MintCream, Color.MistyRose, Color.Moccasin, _
Color.NavajoWhite, Color.Navy, Color.OldLace, _
Color.Olive, Color.OliveDrab, Color.Orange, _
Color.OrangeRed, Color.Orchid, Color.PaleGoldenrod, _
Color.PaleGreen, Color.PaleTurquoise, _
Color.PaleVioletRed, Color.PapayaWhip, _
Color.PeachPuff, Color.Peru, Color.Pink, Color.Plum, _
Color.PowderBlue, Color.Purple, Color.Red, _
Color.RosyBrown, Color.RoyalBlue, Color.SaddleBrown, _
Color.Salmon, Color.SandyBrown, Color.SeaGreen, _
Color.SeaShell, Color.Sienna, Color.Silver, _
Color.SkyBlue, Color.SlateBlue, Color.SlateGray, _
Color.Snow, Color.SpringGreen, Color.SteelBlue, _
Color.Tan, Color.Teal, Color.Thistle, Color.Tomato, _
Color.Transparent, Color.Turquoise, Color.Violet, _
Color.Wheat, Color.White, Color.WhiteSmoke, _
Color.Yellow, Color.YellowGreen _
}
' Create a list of 10 rectangles for each row
Dim row1(10) As Rectangle ' = New Rectangle
Dim row2(10) As Rectangle ' = New Rectangle
Dim row3(10) As Rectangle ' = New Rectangle
Dim row4(10) As Rectangle ' = New Rectangle
Dim row5(10) As Rectangle ' = New Rectangle
Dim row6(10) As Rectangle ' = New Rectangle
Dim row7(10) As Rectangle ' = New Rectangle
Dim row8(10) As Rectangle ' = New Rectangle
' Create the rectangles that will be drawn on the screen
For i As Integer = 0 To 9
row1(i) = New Rectangle(i + (i * (Width / 10)), 0, _
(Width - 36) / 10, Height / 8)
row2(i) = New Rectangle(i + (i * (Width / 10)), _
4 + (Height / 8), (Width - 36) / 10, Height / 8)
row3(i) = New Rectangle(i + (i * (Width / 10)), _
8 + (2 * (Height / 8)), (Width - 36) / 10, Height / 8)
row4(i) = New Rectangle(i + (i * (Width / 10)), _
12 + (3 * (Height / 8)), (Width - 36) / 10, Height / 8)
row5(i) = New Rectangle(i + (i * (Width / 10)), _
16 + (4 * (Height / 8)), (Width - 36) / 10, Height / 8)
row6(i) = New Rectangle(i + (i * (Width / 10)), _
20 + (5 * (Height / 8)), (Width - 36) / 10, Height / 8)
row7(i) = New Rectangle(i + (i * (Width / 10)), _
24 + (6 * (Height / 8)), (Width - 36) / 10, Height / 8)
row8(i) = New Rectangle(i + (i * (Width / 10)), _
28 + (7 * (Height / 8)), (Width - 36) / 10, Height / 8)
Next
' Create the last rectangle of each row
Dim row1a As Rectangle = New Rectangle(9 + (9 * (Width / 10)), _
0, ((Width - 36) / 10) - 2, Height / 8)
Dim row2a As Rectangle = New Rectangle(9 + (9 * (Width / 10)), _
4 + (Height / 8), ((Width - 36) / 10) - 2, Height / 8)
Dim row3a As Rectangle = New Rectangle(9 + (9 * (Width / 10)), _
8 + (2 * (Height / 8)), ((Width - 36) / 10) - 2, Height / 8)
Dim row4a As Rectangle = New Rectangle(9 + (9 * (Width / 10)), _
12 + (3 * (Height / 8)), ((Width - 36) / 10) - 2, Height / 8)
Dim row5a As Rectangle = New Rectangle(9 + (9 * (Width / 10)), _
16 + (4 * (Height / 8)), ((Width - 36) / 10) - 2, Height / 8)
Dim row6a As Rectangle = New Rectangle(9 + (9 * (Width / 10)), _
20 + (5 * (Height / 8)), ((Width - 36) / 10) - 2, Height / 8)
Dim row7a As Rectangle = New Rectangle(9 + (9 * (Width / 10)), _
24 + (6 * (Height / 8)), ((Width - 36) / 10) - 2, Height / 8)
Dim row8a As Rectangle = New Rectangle(9 + (9 * (Width / 10)), _
28 + (7 * (Height / 8)), ((Width - 36) / 10) - 2, Height / 8)
' Create a list of the hatch brushes
' of the .NET Framework using random colors
Dim curBrush() As HatchBrush = _
{ _
New HatchBrush(HatchStyle.BackwardDiagonal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Cross, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DarkDownwardDiagonal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DarkHorizontal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DarkUpwardDiagonal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DarkVertical, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DashedDownwardDiagonal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DashedHorizontal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DashedUpwardDiagonal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DashedVertical, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DashedVertical, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DiagonalBrick, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DiagonalCross, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Divot, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DottedDiamond, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.DottedGrid, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.ForwardDiagonal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Horizontal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.HorizontalBrick, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.LargeCheckerBoard, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.LargeConfetti, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.LargeGrid, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.LightDownwardDiagonal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.LightHorizontal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.LightUpwardDiagonal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.LightVertical, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Max, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Min, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.NarrowHorizontal, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.NarrowVertical, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.OutlinedDiamond, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent05, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent10, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent20, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent25, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent30, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent40, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent50, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent60, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent70, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent75, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent80, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent90, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Plaid, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))), _
New HatchBrush(HatchStyle.Percent05, _
curColor(rndNumber.Next(curColor.Length)), _
curColor(rndNumber.Next(curColor.Length))) _
}
' Draw the rectangles to cover the screen
For i As Integer = 0 To 9
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row1(i))
graph.DrawRectangle(New Pen(curBrush(rndNumber.Next(_
curBrush.Length))), row1(i))
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row2(i))
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row2(i))
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row3(i))
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row3(i))
graph.FillRectangle(curBrush(_
rndNumber.Next(curBrush.Length)), row4(i))
graph.DrawRectangle(New Pen(_
curBrush(rndNumber.Next(curBrush.Length))), row4(i))
graph.FillRectangle(curBrush(_
rndNumber.Next(curBrush.Length)), row5(i))
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row5(i))
graph.FillRectangle(curBrush(_
rndNumber.Next(curBrush.Length)), row6(i))
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row6(i))
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row7(i))
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row7(i))
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row8(i))
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row8(i))
Next
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row1a)
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row1a)
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row2a)
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row2a)
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row3a)
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row3a)
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row4a)
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row4a)
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row5a)
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row5a)
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row6a)
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row6a)
graph.FillRectangle(curBrush(_
rndNumber.Next(curBrush.Length)), row7a)
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row7a)
graph.FillRectangle(curBrush(rndNumber.Next(_
curBrush.Length)), row8a)
graph.DrawRectangle(New Pen(curBrush(_
rndNumber.Next(curBrush.Length))), row8a)
End Sub
|