Exemple #1
0
        /// <summary>
        /// Load location data from the server.
        /// Also intialize the application bar with the loaded data.
        /// </summary>
        private async Task LoadUIData()
        {
            //Change the header depending on the mode.
            bool isResolved = NavigationContext.QueryString[MODE_KEY].Equals(RESOLVED_REQUESTS);
            if (isResolved)
                LocationPivot.Header = AppResources.Map_PastSOSHeader;
            else
                LocationPivot.Header = AppResources.Map_UnresolvedSOSHeader;

            ApplicationBar.IsVisible = false;
            CancellationToken tk = App.ShowProgressOverlay(AppResources.Map_LoadingLocation);
            string message = "";
            try
            {
                myLocationPushpin = await LoadUserLocation();
                if (myLocationPushpin == null)
                    MessageBox.Show(AppResources.Map_CannotObtainLocation);
                else
                    LocationMapLayer.Add(myLocationPushpin.pushpinLayer);//Add the user's location to the maplayer.

                LocationList<Pushpin> sosLocations = await LoadSOSLocations(isResolved, tk, myLocationPushpin.position);

                List<LocationList<Pushpin>> longList = ViewModels.LocationList<Pushpin>.GroupByTime(sosLocations, 24);

                LocationList.ItemsSource = longList;

                //Add the last location to the maplayer.

                if (sosLocations.Count > 0)
                {
                    AddNewPushpin(sosLocations.First());
                    lastPushpin = sosLocations.First();
                }
                ApplicationBar.IsVisible = true;
            }
            catch (OperationCanceledException)
            {
                Debug.WriteLine("Loading UI Canceled.");
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                message = AppResources.Map_LoadingFailed;
                NavigationService.GoBack();
            }
            App.HideProgressOverlay();
            if (!message.Equals(""))
                MessageBox.Show(message);
        }
Exemple #2
0
        /// <summary>
        /// Load location data from the server.
        /// Also intialize the application bar with the loaded data.
        /// </summary>
        private async Task LoadUIData()
        {
            ApplicationBar.IsVisible = false;
            CancellationToken tk = App.ShowProgressOverlay(AppResources.Map_LoadingLocation);
            string message = "";
            try
            {
                myLocationPushpin = await LoadUserLocation();
                if (myLocationPushpin == null)
                    MessageBox.Show(AppResources.Map_CannotObtainLocation);
                else
                    LocationMapLayer.Add(myLocationPushpin.pushpinLayer);//Add the user's location to the maplayer.
                LocationList<Pushpin> lastLocations = await LoadLastLocations(tk, myLocationPushpin.position);
                LocationList<Pushpin> sosLocations = await LoadSOSLocations(tk, myLocationPushpin.position);

                List<LocationList<Pushpin>> longList = new List<LocationList<Pushpin>>();
                longList.Add(sosLocations);
                longList.AddRange(ViewModels.LocationList<Pushpin>.GroupByTime(lastLocations, 24));

                LocationList.ItemsSource = longList;

                //Add the last location to the maplayer.
                if (lastLocations.Count > 0)
                {
                    AddNewPushpin(lastLocations.First());
                    lastPushpin = lastLocations.First();
                }
                else if (sosLocations.Count > 0)
                {
                    AddNewPushpin(sosLocations.First());
                    lastPushpin = sosLocations.First();
                }
                ApplicationBar.IsVisible = true;
            }
            catch (OperationCanceledException)
            {
                Debug.WriteLine("loading canceled");
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
                message = AppResources.Map_LoadingFailed;
            }
            App.HideProgressOverlay();
            if (!message.Equals(""))
                MessageBox.Show(message);
        }
Exemple #3
0
        /// <summary>
        /// Listener for selecting items in the list.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LocationList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // If selected item is null (no selection) do nothing
            if (LocationList.SelectedItem == null)
                return;

            MapPivot.SelectedIndex = 1;//Go to the map page.

            Pushpin p = LocationList.SelectedItem as Pushpin; //Get the selected request

            LocationMapLayer.Remove(lastPushpin.pushpinLayer); //Remove the last pushpin from the map.
            AddNewPushpin(p); //Add the new one.
            lastPushpin = p; //Save the current one in lastPushpin

            // Reset selected item to null (no selection)
            LocationList.SelectedItem = null;
        }
Exemple #4
0
 /// <summary>
 /// Add a pushpin to the map and zoom to the position.
 /// </summary>
 /// <param name="p">the pushpin to be added</param>
 private void AddNewPushpin(Pushpin p)
 {
     LocationMap.SetView(p.position.Location, LocationMap.ZoomLevel, MapAnimationKind.Parabolic);
     LocationMapLayer.Add(p.pushpinLayer);
 }
Exemple #5
0
        private void LocationList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // If selected item is null (no selection) do nothing
            if (LocationList.SelectedItem == null)
                return;

            MapPivot.SelectedIndex = 1;

            Pushpin p = LocationList.SelectedItem as Pushpin;

            LocationMapLayer.Remove(lastPushpin.pushpinLayer);
            AddNewPushpin(p);
            lastPushpin = p;

            // Reset selected item to null (no selection)
            LocationList.SelectedItem = null;

        }