#Region Project Attributes
#ApplicationLabel: WheelPicker
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\LibRes
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim t As Timer
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.
Private wp1 As WheelPicker
Private wp2 As WheelPicker
Dim mydaylist As List
Dim mymonthlist As List
Dim wp1position As Int = 3
Dim wp2position As Int = 7
Private Panel1 As Panel
Private Button1 As Button
Dim fm As FontoMetrics
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
t.Initialize("t", 2000)
wp1.Initialize("wp1")
fm.Initialize
' wp2.Initialize("wp2")
' Activity.AddView(wp2, 10%x, 50%y, 80%x, 40%y)
' Panel1.Initialize("")
' wp1.Initialize("wp1")
Activity.AddView(wp1, 5%x, 5%y, 70%x, 70%x)
' Panel1.AddView(wp1, Panel1.Left , Panel1.Top , Panel1.Width * 0.5, Panel1.Height * 0.5)
' Panel1.Color = Colors.Blue
wp1.Curved = True
wp1.Cyclic = True
wp1.CurtainColor = Colors.ARGB(50, 100, 100, 100)
wp1.Curtain = True
wp1.SelectedItemTextColor = Colors.Red
wp1.ItemTextColor = Colors.Black
wp1.Atmospheric = False
wp1.ItemAlign = 0 '0 = center, 1 = left, 2 = right
wp1.ItemTextSize = 35
wp1.SelectedItemPosition = wp1position 'it will start at Thursday
wp1.VisibleItemCount = 5
wp1.SameWidth = True 'not sure what this is supposed to do
wp1.Indicator = True
wp1.IndicatorColor = Colors.Yellow
wp1.IndicatorSize = 9
wp1.ItemSpace = 20
wp1.Typeface = fm.pacifico
mydaylist.Initialize
For j = 0 To 200
mydaylist.Add("" & j)
Next
'mydaylist.AddAll(Array As String("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
wp1.Data = mydaylist
' wp2.Curved = True
' wp2.Cyclic = True
' wp2.CurtainColor = Colors.ARGB(100, 255, 0, 0)
' wp2.Curtain = True
' wp2.ItemTextColor = Colors.Yellow
' wp2.Atmospheric = True
' wp2.ItemAlign = 0 '0 = center, 1 = left, 2 = right
' wp2.ItemTextSize = 40
' wp2.SelectedItemPosition = wp2position 'it will start at August
' wp2.SelectedItemTextColor = Colors.Cyan
' wp2.VisibleItemCount = 6
' wp2.SameWidth = True 'not sure what this is supposed to do
' wp2.Indicator = True
' wp2.IndicatorColor = Colors.Cyan
' wp2.IndicatorSize = 7
'
' mymonthlist.Initialize
' mymonthlist.AddAll(Array As String("January", "February", "March", "April", "May", "June", "July", _
' "August", "September", "October", "November", "December"))
' wp2.Data = mymonthlist
End Sub
Sub Activity_Resume
't.Enabled = True
End Sub
Sub Activity_Pause (UserClosed As Boolean)
't.Enabled = False
End Sub
Sub wp1_item_selected(position As Int)
Log("wp1 position = " & position & " value = " & mydaylist.Get(position))
End Sub
'Sub wp2_item_selected(position As Int)
'
' Log("wp2 position = " & position & " value = " & mymonthlist.Get(position))
'
'End Sub
Sub t_tick
wp2.SelectedItemPosition = Rnd(0,12)
End Sub
Sub wp1_index_changed (currentindex As Int)
'YOU NEED TO ADD CODE HERE TO TEST FOR AN OVERSCROLL WHEN CYCLIC IS SET TO FALSE
'eg if currentindex = 0 at present and the immediate next value is for eg 6 then the user is dragging down too far
'eg if currentindex = 6 at present and the immediate next value is for eg 0 the the used is dragging up too far
'correct scrolling sequence should be currentindex values changing from 0 to number of items -1 or from number of items -1 to 0
'HOPE YOU FOLLOW WHAT I AM TRYING TO EXPLAIN HERE
If wp1position <> currentindex Then
Log("wp1 current index = " & currentindex)
wp1position = currentindex
End If
End Sub
Sub wp1_index_clicked(position As Int)
Log("clicked and position = " & position)
Wait(100)
End Sub
'Sub wp2_index_changed (currentindex As Int)
'
' If wp2position <> currentindex Then
' Log("wp2 current index = " & currentindex)
' wp2position = currentindex
' End If
'
'End Sub
Sub Button1_Click
For i = 0 To 1 'RUN THIS TWICE WHEN YOU CHANGE THE CONTENT - IT IS A FIX FOR NOW BUT HAVE NOT
'MANAGED TO TRAP WHY IT DOES NOT WORK WHEN IT IS EXECUTED ONLY ONCE
mydaylist.Clear
mydaylist.AddAll(Array As String("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
wp1.Curved = True
wp1.Cyclic = True
'wp1.CurtainColor = Colors.ARGB(50, 255, 255, 255)
wp1.Curtain = True
wp1.SelectedItemTextColor = Colors.Yellow
wp1.ItemTextColor = Colors.Red
wp1.Atmospheric = True
wp1.ItemAlign = 0 '0 = center, 1 = left, 2 = right
wp1.ItemTextSize = 40
wp1.VisibleItemCount = 3
wp1.SameWidth = True 'not sure what this is supposed to do
wp1.Indicator = True
wp1.IndicatorColor = Colors.Green
wp1.IndicatorSize = 3
wp1.Typeface = fm.pacifico
wp1.Data = mydaylist
wp1.SelectedItemPosition = 1 'it will start at Tuesday
wp1.Invalidate
Next
End Sub
Sub Wait(MilliSekunden As Int)
Dim Ti As Long
Ti = DateTime.Now + MilliSekunden
Do While DateTime.Now < Ti
DoEvents
Loop
End Sub