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
| Private _MyColor As Color() = {Color.Blue, Color.Green, Color.DodgerBlue, Color.Red, Color.Yellow}
Private Sub DrawColorText(g As Graphics, r As Rectangle, _info As String, FondSize As Integer, _FondStyle As FontStyle)
Dim MyFont As Font = GetFont(My.Resources.DS_DIGIB, FondSize, _FondStyle)
Dim jour As String() = _info.Split(New Char() {":", " ", "/"}, StringSplitOptions.RemoveEmptyEntries)
TextRenderer.DrawText(g, _info, MyFont, New Point(0, 0), Me.ForeColor)
If (Me.Text.Length <= 0) Then Return
For i As Integer = 0 To jour.Length - 1
Dim keyWidth As Integer = TextRenderer.MeasureText(jour(i), MyFont).Width
Dim IndexOffset As Integer = _info.IndexOf(jour(i))
While IndexOffset >= 0
Dim StrFront As String = Text.Substring(0, IndexOffset)
If StrFront.Length > 0 Then
Dim strWidth As Integer = TextRenderer.MeasureText(StrFront & jour(i), MyFont).Width
TextRenderer.DrawText(g, jour(i), MyFont, New Point((strWidth - keyWidth), 0), _MyColor(i))
Else
TextRenderer.DrawText(g, jour(i), MyFont, New Point(0, 0), _MyColor(i))
End If
IndexOffset += jour(i).Length
If IndexOffset >= _info.Length Then Exit While
Dim StrBehind As String = _info.Substring(IndexOffset)
If StrBehind.Length <= 0 Then Exit While
Dim index2 As Integer = StrBehind.IndexOf(jour(i))
If index2 < 0 Then Exit While
IndexOffset += index2
End While
Next |
Partager