Private Sub Timer1Tick(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
|