'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Canvas1 As Canvas
Dim Label2 As Label
Dim Panel1 As Panel
Dim button1 As Button
Dim Rect1 As Rect
Dim active,draw As Boolean
Dim x_pos_old,y_pos_old,i As Int
Dim timer1 As Timer
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.loadlayout("layout")
Canvas1.Initialize(Panel1)
Rect1.Initialize(0dip, 0dip, 320dip, 220dip)
draw=False
timer1.Initialize("timer1", 500)
timer1.Enabled = True
End Sub
Sub Activity_Resume
Draw_the_circles
End Sub
Sub Draw_the_circles
timer1.Enabled = False
active=True
DoEvents
Label2.Text =""
Canvas1.DrawRect(Rect1, Colors.rgb(128,128,128), True, 1dip)
button1.Enabled=False
For i = 0 To 50 '50 good for Emulator. Increase for real device
Canvas1.DrawCircle(Rnd(0,320),Rnd(0,220),10, Colors.RGB(0,0,180),False,1)
Panel1.Invalidate
DoEvents
Next
button1.Enabled=True
Label2.Text="Ready"
active = False
timer1.Enabled = True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub button1_click
clear_screen
Draw_the_circles
End Sub
Sub timer1_tick
If draw=True Then
draw=False
clear_screen
Draw_the_circles
End If
End Sub
Sub Panel1_Touch (Action As Int, x As Float, y As Float) As Boolean
If active = False Then ' Do this only if no circles are drawing
Select Action
Case Activity.ACTION_DOWN
x_pos_old=x
y_pos_old=y
Case Activity.ACTION_UP
If x_pos_old-x>150 Then ' Gesture to left
draw=True
End If
If x-x_pos_old>150 Then ' Gesture to right
draw=True
End If
End Select
Else
End If
Return True
End Sub
Sub clear_screen
Canvas1.DrawRect(Rect1, Colors.rgb(128,128,128), True, 1dip)
Panel1.Invalidate
End Sub