'Draws the text at the given position. For alignment use one of following values "LEFT", "CENTER", "RIGHT".
Sub DrawText (Text As String, x As Double, y As Double, Font As B4XFont, Color As Int, Alignment As Object)
ArgList.Initialize2(Array("DrawText", Text, x, y, Font, Color, Alignment))
CommitCommand(ArgList)
End Sub
Private Sub CommitCommand(Args As List)
' Try
If mAutoInvalidate Then
ParseCommand(Args)
Else
DrawList.Add(Args)
End If
' Catch
' Log("ERROR: " & LastException)
' End Try
End Sub
Private Sub ParseCommand(Args As List)
count = count + 1
' Log("ParseCommand: " & cmd & " ARGS: " & Args)
' Try
Dim cmd As String = Args.Get(0) ' The command name
Select cmd
Case "Clear"
Dim rect As B4XRect
rect.Initialize(0, 0, pnl.Width, pnl.Height)
cvs.DrawRect(rect, Args.Get(1), True, 0)
Case "DrawText"
cvs.DrawText(Args.Get(1), Args.Get(2), Args.Get(3), Args.Get(4), Args.Get(5), "LEFT")
End Select
End Sub
Private Sub ExecuteDrawList(cmdList As List)
' For cnt = 0 To cmdList.Size-1 ' For all draw commands
' ParseCommand(cmdList.Get(cnt))
' Next
For Each o As Object In cmdList ' For all draw commands
ParseCommand(o)
Next
DrawList.Clear ' Finally clear the list
End Sub
'Commits the drawings.
' If AutoInvalidate is False this must be called for the drawings to be updated.
Sub Invalidate
If mAutoInvalidate = False Then
' Log("(" & DateTime.Now & ") - Repaint")
ExecuteDrawList(DrawList)
End If
End Sub