Sub Globals
Dim x00, y00, x01, y01 As Float
Dim x10, y10, x11, y11 As Float
Dim pnlSignature, pnlBitmap As Panel
Dim cvsSignature, cvsBitmap As Canvas
Dim btnOK As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim x, y As Float
btnOK.Initialize("btnOK")
Activity.AddView(btnOK, 10, 10, 100, 60)
btnOK.Text = "OK"
pnlSignature.Initialize("pnlSignature")
Activity.AddView(pnlSignature, 80, 80, 640, 400)
pnlSignature.Color = Colors.Yellow
cvsSignature.Initialize(pnlSignature)
pnlBitmap.Initialize("")
Activity.AddView(pnlBitmap, 320, 0, 160, 100)
pnlBitmap.Color = Colors.White
cvsBitmap.Initialize(pnlBitmap)
End Sub
Sub pnlSignature_Touch (Action As Int, X As Float, Y As Float) As Boolean
Stroke = 2
Select Action
Case Activity.ACTION_DOWN
x00 = X
y00 = Y
x10 = Max(Stroke, X / 4) ' garanties at least one Stroke
y10 = Max(Stroke, Y / 4)
Case Activity.ACTION_MOVE
x01 = X
y01 = Y
x11 = Max(Stroke, X / 4)
y11 = Max(Stroke, Y / 4)
Log(x00&" "&x01&" "&y00&" "&y01)
cvsSignature.DrawLine(x00, y00, x01, y01, Colors.Black, 4)
cvsBitmap.DrawLine(x10, y10, x11, y11, Colors.Black, Stroke)
x00 = x01
y00 = y01
x10 = x11
y10 = y11
pnlSignature.Invalidate
pnlBitmap.Invalidate
End Select
Return True
End Sub
Sub btnOK_Click
Dim bdr As BitmapDrawable
Dim bmp As Bitmap
Dim destRect As Rect
destRect.Initialize(0, 0, 160, 100)
bdr = pnlBitmap.Background
bmp = bdr.Bitmap
cvsSignature.DrawBitmap(bmp,Null,destRect)
pnlSignature.Invalidate
End Sub