Sub pnl_Touch (viewtag As Object, action As Int, X As Float, Y As Float, motionevent As Object) As Boolean
If action = 0 Then 'ACTION_DOWN
startAngle = ATan2(X - radius, Y - radius)
Else If action = 2 Then 'ACTION_MOVE
Dim angle As Float = ATan2(X - radius, Y - radius)
currentAngle = currentAngle - angle + startAngle
Dim delta As Int = (startAngle - angle) * 180 / cPI
If delta > 180 Then
delta = delta - 360
Else If delta < -180 Then
delta = delta + 360
End If
If (currentAngle * 180 / cPI < 0.0) Then
currentAngle = 0.0
Else If (currentAngle * 180 / cPI > 360.0) Then
currentAngle = (360/180) * cPI
End If
CallSubDelayed2(CallBack, EventName & "_AngleChanged", delta)
startAngle = angle
cvs.DrawBitmapRotated(bmp, Null, destRect, currentAngle * 180 / cPI)
pnl.Invalidate
End If
Return True
End Sub