Ejemplo n.º 1
0
    protected async override void OnNavigatedTo(NavigationEventArgs e)
    {
      Geopoint myPoint;

      if (e.Parameter == null)
      {
        // Add
        isViewing = false;

        var locator = new Geolocator();
        locator.DesiredAccuracyInMeters = 50;

        // MUST ENABLE THE LOCATION CAPABILITY!!!
        var position = await locator.GetGeopositionAsync();
        myPoint = position.Coordinate.Point;

      }
      else
      {
        // View or Delete
        isViewing = true;

        mapNote = (MapNote)e.Parameter;
        titleTextBox.Text = mapNote.Title;
        noteTextBox.Text = mapNote.Note;
        addButton.Content = "Delete";

        var myPosition = new Windows.Devices.Geolocation.BasicGeoposition();
        myPosition.Latitude = mapNote.Latitude;
        myPosition.Longitude = mapNote.Longitude;

        myPoint = new Geopoint(myPosition);


      }

      await MyMap.TrySetViewAsync(myPoint, 16D);
    }
Ejemplo n.º 2
0
    private async void addButton_Click(object sender, RoutedEventArgs e)
    {
      if (isViewing)
      {
        // Delete
        //Delete
        var messageDialog = new Windows.UI.Popups.MessageDialog("Are you sure?");

        // Add commands and set their callbacks; both buttons use the same callback function instead of inline event handlers
        messageDialog.Commands.Add(new UICommand(
            "Delete",
            new UICommandInvokedHandler(this.CommandInvokedHandler)));
        messageDialog.Commands.Add(new UICommand(
            "Cancel",
            new UICommandInvokedHandler(this.CommandInvokedHandler)));

        // Set the command that will be invoked by default
        messageDialog.DefaultCommandIndex = 0;

        // Set the command to be invoked when escape is pressed
        messageDialog.CancelCommandIndex = 1;

        // Show the message dialog
        await messageDialog.ShowAsync();

      }
      else
      {
        // Add
        MapNote newMapNote = new MapNote();
        newMapNote.Title = titleTextBox.Text;
        newMapNote.Note = noteTextBox.Text;
        newMapNote.Created = DateTime.Now;
        newMapNote.Latitude = MyMap.Center.Position.Latitude;
        newMapNote.Longitude = MyMap.Center.Position.Longitude;
        App.DataModel.AddMapNote(newMapNote);
        Frame.Navigate(typeof(MainPage));
      }



    }
Ejemplo n.º 3
0
 public async void DeleteMapNote(MapNote mapNote)
 {
     _mapNotes.Remove(mapNote);
     await saveMapNoteDataAsync();
 }
Ejemplo n.º 4
0
 public async void AddMapNote(MapNote mapNote)
 {
     _mapNotes.Add(mapNote);
     await saveMapNoteDataAsync();
 }
Ejemplo n.º 5
0
 public async void DeleteMapNote(MapNote mapNote)
 {
   _mapNotes.Remove(mapNote);
   await saveMapNoteDataAsync();
 }
Ejemplo n.º 6
0
 public async void AddMapNote(MapNote mapNote)
 {
   _mapNotes.Add(mapNote);
   await saveMapNoteDataAsync();
 }