'Code module
#Region Project Attributes
#ApplicationLabel: Test3
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait
#iPadOrientations: Portrait
#Target: iPhone, iPad
#ATSEnabled: True
#MinVersion: 7
#PlistExtra:<key>NSLocationWhenInUseUsageDescription</key><string>Used to keep the countdown timer running.</string>
#PlistExtra:<key>NSLocationUsageDescription</key><string>Used to keep the countdown timer running.</string>
#End Region
#CertificateFile: ios_distribution.cer
#ProvisionFile: ad_hoc.mobileprovision
#IgnoreWarnings: 32
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private LocManager As LocationManager
Private countDownTimer As Timer
Dim intSeconds As Int
Private ButtonStart As Button
Private ButtonStop As Button
Private Label_Enable As Label
Private Label_Compass As Label
Private Label_Counter As Label
End Sub
Private Sub Application_Start (Nav As NavigationController)
'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
NavControl = Nav
Page1.Initialize("Page1")
Page1.RootPanel.Color = Colors.White
NavControl.ShowPage(Page1)
LocManager.Initialize("LocManager")
Page1.RootPanel.LoadLayout("Main")
Page1.Title = "Test3"
countDownTimer.Initialize("countDownTimer", 1000)
intSeconds = 0
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub Application_Foreground
StartLocationUpdates
End Sub
Private Sub Application_Background
'LocManager.Stop
'LocManager.StopHeading
End Sub
Private Sub LocManager_AuthorizationStatusChanged (Status As Int)
Label_Enable.Visible = (LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_DENIED _
Or LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_RESTRICTED)
StartLocationUpdates
End Sub
Private Sub StartLocationUpdates
'if the user allowed us to use the location service or if we never asked the user before then we call LocationManager.Start.
If LocManager.IsAuthorized Or LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_NOT_DETERMINED Then
LocManager.Start(0)
End If
LocManager.StartHeading
End Sub
Private Sub LocManager_HeadingChanged (MagneticHeading As Double, TrueHeading As Double)
Label_Compass.Text = NumberFormat(MagneticHeading, 1, 0)
End Sub
Sub countDownTimer_Tick
intSeconds = intSeconds + 1
Label_Counter.Text = intSeconds
End Sub
Sub ButtonStart_Click
intSeconds = 0
countDownTimer.Enabled = True
End Sub
Sub ButtonStop_Click
countDownTimer.Enabled = False
End Sub
[/CODE