'Activity module
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.
Dim camera1 As AdvancedCamera
Dim btnTiraFoto As Button
Dim pnlFoto As Panel
Dim boolSalvouColeta As Boolean : boolSalvouColeta=False
Dim strNomeArqFoto As String
Dim lblFoto As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Fotos")
lblFoto.Text=Main.gstrFoto
btnTiraFoto.Enabled = True
End Sub
Sub Activity_Resume
btnTiraFoto.Enabled = False
camera1.Initialize(pnlFoto, "Camera1")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
camera1.StopPreview
camera1.Release
End Sub
Sub btnTiraFoto_Click
btnTiraFoto.Enabled = False
camera1.Quality=50
camera1.PictureSize(320,240)
camera1.TakePicture
End Sub
Sub Camera1_Ready (Success As Boolean)
If Success Then
camera1.StartPreview
btnTiraFoto.Enabled = True
Else
ToastMessageShow("Não conseguiu abrir a câmera", True)
End If
End Sub
Sub Camera1_PictureTaken (data() As Byte)
camera1.StartPreview
Dim out As OutputStream
Dim dtHoje As Long : dtHoje = DateTime.Now
strNomeArqFoto = Main.gstrNomeCliExec.SubString2(0,10) & "-" & Main.gstrFoto & "-" & _
DateTime.GetDayOfMonth(dtHoje) & DateTime.GetMonth(dtHoje) & _
DateTime.GetHour(dtHoje) & DateTime.GetMinute(dtHoje) & _
DateTime.GetSecond(dtHoje) & ".jpg"
out = File.OpenOutput(File.DirRootExternal, strNomeArqFoto, False)
out.WriteBytes(data, 0, data.Length)
out.Close
ToastMessageShow("Foto salva: " & File.Combine(File.DirRootExternal, strNomeArqFoto), True)
btnTiraFoto.Enabled = False
End Sub