#Region Project Attributes
#ApplicationLabel: Screenshot
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: True
#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.
Dim TileSource As String="MapquestOSM" 'Mapnik, OSMPublicTransport, MapquestOSM
Dim dt As String="Maptemp" 'Filename for screenshot
Dim Timer1 As Timer 'Used to create a delay
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 MapView1 As MapView
Dim MapCenter As GeoPoint
Dim TouchEventsOverlay1 As TouchEventsOverlay 'Allows click & long click events
Dim SimpleLocationOverlay1 As SimpleLocationOverlay
Dim MarkersOverlay1 As MarkersOverlay
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("Layout1")
Activity.AddMenuItem("Take Screenshot", "MnuShot")
Timer1.Initialize( "Timer1",500)
' pass an EventName when initializing the MapView
' MapView has two events: CenterChanged and ZoomChanged
MapView1.Initialize("MapView1")
Activity.AddView(MapView1, 0, 0, 100%x, 100%y)
MapView1.SetMultiTouchEnabled(True)
MapView1.SetZoomEnabled(True)
MapCenter.Initialize(47.3763900,15.0911300) 'Leoben as center
MapView1.Zoom=15
MapView1.SetCenter(47.3763900,15.0911300)
MapView1.SetTileSource(TileSource)
Activity.Title="OSMDroid ["&MapView1.Zoom&"]"
'initialize the SimpleLocationOverlay and add it to the MapView
SimpleLocationOverlay1.Initialize(MapView1)
MapView1.AddOverlay(SimpleLocationOverlay1)
'set the SimpleLocationOverlay to display it's icon at the map center
SimpleLocationOverlay1.SetMyLocation3(MapView1.GetCenter)
'initialize the MarkersOverlay and add it to the MapView
'an EventName is required as we will listen for the two events that MarkersOverlay generates
MarkersOverlay1.Initialize(MapView1, "") 'No events
MapView1.AddOverlay(MarkersOverlay1)
'Add touch events to map
TouchEventsOverlay1.Initialize("TouchEventsOverlay1")
MapView1.AddOverlay(TouchEventsOverlay1)
Timer1.Enabled=True 'Wait for a short period for map to finish drawing
End Sub
Sub Timer1_Tick
'Need the timer to let the map finish drawing
Timer1.Enabled=False
End Sub
Sub MnuShot_Click
TakeScreenShot
End Sub
Sub TakeScreenShot
' Take a screenshot.
Dim Obj1, Obj2 As Reflector
Dim bmp As Bitmap
Dim c As Canvas
Obj1.Target = Obj1.GetActivityBA
Obj1.Target = Obj1.GetField("vg")
bmp.InitializeMutable(Activity.Width, Activity.Height)
c.Initialize2(bmp)
Dim args(1) As Object
Dim types(1) As String
Obj2.Target = c
Obj2.Target = Obj2.GetField("canvas")
args(0) = Obj2.Target
types(0) = "android.graphics.Canvas"
Obj1.RunMethod4("draw", args, types)
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, dt & ".png", False)
bmp.WriteToStream(Out, 100, "PNG")
Out.Close
StartActivity(ShowScreen)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub