Ejemplo n.º 1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            AppSettings = new AppSettings();

            if (AppSettings.LocationConsent == false)
            {
                var result = MessageBox.Show("This app accesses your phone's location. Is that ok?", "Location", MessageBoxButton.OKCancel);
                AppSettings.LocationConsent = result == MessageBoxResult.OK;
            }

            Map = new Map(MainMap);

            ToggleMetric.IsChecked = AppSettings.ShowMetric;

            // Ensure our background agent is runnin'
            if (!_backgroundAgent.IsRunning())
            {
                _backgroundAgent.StartPeriodicAgent();
            }
            ToggleAgent.IsChecked = _backgroundAgent.IsRunning();

            // Center the map where the we last saw the user...
            MainMap.Center = new GeoCoordinate(AppSettings.LastKnownLatitude, AppSettings.LastKnownLongitude);

            // Check if we have a friend's pin to show too!
            string strItemIndex;

            if (NavigationContext.QueryString.TryGetValue("Location", out strItemIndex))
            {
                _friendLocation = new Location();
                _friendLocation = _friendLocation.DataStringToLocation(strItemIndex);
            }

            Geolocator = new Geolocator();

            Animation = new Animation(false, false);

            RefreshLocation();
        }