'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 bmp, bmp1 As Bitmap
Dim Panel1 As Panel
Dim Label1 As Label
Dim Canvas1 As Canvas ' Canvas to draw resized image to
Dim DestRect As Rect ' Size of Fullscreen
Dim tb_cube As ToggleButton
Dim sd_cube As StateListDrawable
Dim bd_cube_0, bd_cube_1 As BitmapDrawable
Dim timer1 As Timer
Dim mediaPlayer1 As MediaPlayer
Dim cube_checked As Boolean
'tb_cube.Initialize("") 'no events will be caught
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
bmp.Initialize(File.DirAssets, "CircMenuMap32bit.png")
' Recalc for new Activity-Dimensions
Dim facWidth As Float
Dim facHeight As Float
facWidth = Activity.Width / bmp.Width
facHeight = Activity.Height / bmp.Height
Log(facWidth & " / " & facHeight)
' initialize BitmapDrawable ToggleButton
tb_cube.Initialize("tb_cubeBitmap")
Activity.AddView(tb_cube, 313 * facWidth, 214* facHeight, 80*facWidth, 75*facHeight )
tb_cube.TextOff = ""
tb_cube.TextOn = ""
bd_cube_0.Initialize(LoadBitmap(File.DirAssets, "bt_cube_0.png"))
bd_cube_1.Initialize(LoadBitmap(File.DirAssets, "bt_cube_1.png"))
sd_cube.Initialize
Dim states(2) As Int
states(0) = sd_cube.state_unchecked
states(1) = -sd_cube.state_checked
sd_cube.addState2(states, bd_cube_0)
Dim states(1) As Int
states(0) = sd_cube.state_checked
sd_cube.addState2(states, bd_cube_1)
tb_cube.Background = sd_cube
' Define FullScreen Rect
DestRect.Initialize(0,0,Activity.Width, Activity.Height)
' Create empty Fullsize-Bitmap
bmp1.InitializeMutable(Activity.Width, Activity.Height)
' Init Canvas with size of new Bitmap
Canvas1.Initialize2(bmp1)
' Draw orginal Bitmap as new Resized Bitmap on Canvas
' Thats where the resizing takes place
Canvas1.DrawBitmap(bmp, Null, DestRect)
' Resize Panel to Fullscreen
' Panel is where the normal images is drawn onto
Panel1.Width = -1
Panel1.Height = -1
mediaPlayer1.Initialize()
'mediaPlayer1.Load(File.DirAssets, "hahaha.mp3")
timer1.Initialize("timer1", 5000)
cube_checked = False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
If action = activity.ACTION_DOWN Then
Dim c As Int
c = bmp1.GetPixel(x,y)
Select c
Case Colors.RGB(255,0,0)
label1.Text = "Clicked on Recycle"
Case Colors.RGB(255,255,0)
label1.Text ="Clicked on Film roll"
Case Colors.RGB(0,255,0)
label1.Text ="Clicked on Rubik cube"
Case Colors.RGB(0,255,255)
label1.Text ="Clicked on Old Radio"
Case Colors.RGB(0,0,255)
label1.Text ="Clicked on Record player"
Case Colors.RGB(255,0,255)
label1.Text ="Clicked on Box with stuff"
Case Colors.RGB(255,192,192)
label1.Text ="Clicked on Old TV"
Case Colors.RGB(255,255,192)
label1.Text ="Clicked on Folder with pictures"
Case Colors.RGB(192,255,192)
label1.Text ="Clicked on Ladybug"
If cube_checked = False Then
cube_checked = True
Else
cube_checked = False
End If
tb_cubeBitmap_CheckedChange(cube_checked)
Case Colors.RGB(255,255,255)
label1.Text ="Clicked on Big Button"
Case Else
label1.Text =""
End Select
Return
End If
End Sub
Sub tb_cubeBitmap_CheckedChange(Checked As Boolean)
Activity.Title = Checked
label1.Text ="Clicked on Toggle Rubik cube"
If Checked = True Then
tb_cube.Checked = True
cube_checked = True
timer1.Enabled = True
mediaPlayer1.Load(File.DirAssets, "hahaha.mp3")
mediaPlayer1.Play
Else
timer1.Enabled = False
tb_cube.Checked = False
cube_checked = False
mediaPlayer1.Stop
End If
End Sub
' When the timer is through
Sub timer1_Tick
tb_cube.Checked = False
cube_checked = False
mediaPlayer1.Stop
End Sub