Sub Globals
Dim g As Gestures
Dim cvs As Canvas
Dim SeekBarsColors() As Int
SeekBarsColors = Array As Int(Colors.Yellow, Colors.Blue, Colors.red)
Dim back_pnl As Panel
Dim img1 As ImageView
Dim img2 As ImageView
Dim Panel1 As Panel
Dim Panel2 As Panel
Dim lbl1 As Label
Dim lbl2 As Label
Dim lbl_action1 As Label
Dim lbl_action2 As Label
Dim mapped As Int
End Sub
Sub process_globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
g.SetOnTouchListener(back_pnl, "back_pnl_GesturesTouch")
End Sub
Sub back_pnl_GesturesTouch(View As Object, PointerID As Int, Action As Int, x As Float, y As Float) As Boolean
For i = 0 To g.GetPointerCount - 1
Dim x, y As Float
x = g.GetX(i)
y = g.GetY(i)
If x > 0dip AND x < 40dip Then
MoveSlider(0, y)
lbl_action1.Text = Action
If Action = 6 OR Action = 1 Then
MoveSlider(0, 212)
End If
Else If x > 489dip AND x < 533dip Then
MoveSlider(1, y)
lbl_action2.Text = Action
If Action = 6 OR Action = 1 Then
MoveSlider(1, 212)
End If
End If
Next
Return True
End Sub
Sub MoveSlider(SliderNum As Int, y As Float)
Select SliderNum
Case 0
If y >= 423 Then
Return
End If
'return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
If y < 212 Then
mapped = (y - 212) * (255 - 0) / (11 - 212) + 0
Else If y > 212 Then
mapped = (y - 212) * (255 - 0) / (420 - 212) + 0
Else
mapped = 0
End If
img1.Top = y
lbl1.Text = "Y left value: " & y & "Map. value: " & mapped
Panel1.Invalidate
Case 1
If y >= 423 Then
Return
End If
If y < 212 Then
mapped = (y - 212) * (255 - 0) / (11 - 212) + 0
Else If y > 212 Then
mapped = (y - 212) * (255 - 0) / (420 - 212) + 0
Else
mapped = 0
End If
img2.Top = y
lbl2.Text = "Y right value: " & y & "Map. value: " & mapped
Panel2.Invalidate
End Select
End Sub