gr = CreateGraphics()
midPoint = New Point(Me.Width \ 2, 10)
Dim strText As String = "Score Board"
Dim fnt As New Font("Microsoft Sans Serif", 30, _
FontStyle.Bold, GraphicsUnit.Point)
Dim strSize As New SizeF(gr.MeasureString(strText, fnt))
Dim ptfGradientStart As New _
PointF(intCurrentGradientShift, 0)
Dim ptfGradientEnd As New PointF(0, intCurrentGradientRow)
lbrTitle = New LinearGradientBrush(ptfGradientStart, _
ptfGradientEnd, Color.SteelBlue, Color.Brown)
startPoint = New PointF(midPoint.X – _
CInt(strSize.Width / 2), midPoint.Y)
gr.DrawString(strText, fnt, lbrTitle, startPoint)
ptfGradientStart = New PointF(0, intCurrentGradientShift)
ptfGradientEnd = New PointF(intCurrentGradientRow, 0)
lbrTitle = New LinearGradientBrush(ptfGradientEnd, _
ptfGradientStart, Color.MediumSlateBlue, _
Color.GhostWhite)
gr.DrawString(strText, fnt, lbrTitle, startPoint.X – 2, _
startPoint.Y + 2)
intCurrentGradientShift += intGradiantStep
If intCurrentGradientShift = 400 Then
intGradiantStep = -5
ElseIf intCurrentGradientShift = -400 Then
intGradiantStep = 5
End If
End Sub
Ниже формы Form2 дважды щёлкаем по значку второго таймера Timer. Появляется шаблон метода, который после записи нашего кода принимает следующий вид.
Листинг 21.14. Метод-обработчик события Tick.
Private Sub Timer2_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Timer2.Tick
'showScore()
Dim g As Graphics = CreateGraphics()
Dim fnt As New Font("Courier New", 20, FontStyle.Bold, _
GraphicsUnit.Point)
Dim startPoint As PointF = New PointF(20, 80)
Dim nextPoint As PointF = _
New PointF(startPoint.X + colW1, 80)
Dim ptfGradientStart As New PointF(intCurrentGradientRow, _
startPoint.X)
Dim ptfGradientEnd As New PointF(nextPoint.Y, _
intCurrentGradientRow)
lbrBoard = New LinearGradientBrush(ptfGradientStart, _
ptfGradientEnd, Color.GreenYellow, Color.SlateGray)
Dim PlayerNames As String = "Name" + Chr(13) + Chr(10)
Dim PlayerScores As String = "Score" + Chr(13) + Chr(10)
For i As Integer = 0 To 9
PlayerNames += CType(ArrPlayer(i), Player).PlayerName _
+ Chr(13) + Chr(10)