#Region Project Attributes
#ApplicationLabel: b4aCanvasView
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#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.
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 cv1 As CanvasView
Dim b As Bitmap
Private Spinner1 As Spinner
Private Spinner2 As Spinner
Private Spinner3 As Spinner
Private Spinner4 As Spinner
Private Button1 As Button
Private Button2 As Button
Private Button3 As Button
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")
b.Initialize(File.DirAssets,"horse.png")
cv1.drawBitmap(b)
Spinner1.AddAll(Array As String("Draw","Eraser"))
Spinner2.AddAll(Array As String("PEN", "LINE", "RECTANGLE", "CIRCLE", "ELLIPSE", "QUADRATIC_BEZIER", "QUBIC_BEZIER"))
Spinner3.AddAll(Array As String("Red", "Yellow", "Green", "Blue", "Magenta", "Cyan", "Black"))
Spinner4.AddAll(Array As Int(1, 2, 3, 4, 5, 10, 15, 20, 25, 30, 35))
cv1.PaintStrokeColor = Colors.Red
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Spinner1_ItemClick (Position As Int, Value As Object)
If Position = 0 Then cv1.Mode = cv1.MODE_DRAW
If Position = 1 Then cv1.Mode = cv1.MODE_ERASER
End Sub
Sub Spinner2_ItemClick (Position As Int, Value As Object)
If Position = 0 Then cv1.Drawer = cv1.DRAWER_PEN
If Position = 1 Then cv1.Drawer = cv1.DRAWER_LINE
If Position = 2 Then cv1.Drawer = cv1.DRAWER_RECTANGLE
If Position = 3 Then cv1.Drawer = cv1.DRAWER_CIRCLE
If Position = 4 Then cv1.Drawer = cv1.DRAWER_ELLIPSE
If Position = 5 Then cv1.Drawer = cv1.DRAWER_QUADRATIC_BEZIER
If Position = 6 Then cv1.Drawer = cv1.DRAWER_QUBIC_BEZIER
End Sub
Sub Spinner3_ItemClick (Position As Int, Value As Object)
If Position = 0 Then cv1.PaintStrokeColor = Colors.Red
If Position = 1 Then cv1.PaintStrokeColor = Colors.Yellow
If Position = 2 Then cv1.PaintStrokeColor = Colors.Green
If Position = 3 Then cv1.PaintStrokeColor = Colors.Blue
If Position = 4 Then cv1.PaintStrokeColor = Colors.Magenta
If Position = 5 Then cv1.PaintStrokeColor = Colors.Cyan
If Position = 6 Then cv1.PaintStrokeColor = Colors.Black
End Sub
Sub Spinner4_ItemClick (Position As Int, Value As Object)
Dim pensize As Int = Value
cv1.PaintStrokeWidth = pensize
End Sub
Sub Button1_Click
cv1.undo
End Sub
Sub Button2_Click
cv1.redo
End Sub
Sub Button3_Click
cv1.clear
End Sub