/// <summary>
		/// Invoked when this page is about to be displayed in a Frame.
		/// </summary>
		/// <param name="e">Event data that describes how this page was reached.
		/// This parameter is typically used to configure the page.</param>
		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;

				lifeThread = (LifeThread)e.Parameter;
				titleTextBox.Text = lifeThread.Title;
				noteTextBox.Text = lifeThread.Thread;
				addButton.Content = "Delete";

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

				myPoint = new Geopoint(myPosition);
			}

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

				// Add commands and set their callbacks; both buttons use the same callback function
				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
				LifeThread newLifeThead = new LifeThread();
				newLifeThead.Title = titleTextBox.Text;
				newLifeThead.Thread = noteTextBox.Text;
				newLifeThead.Created = DateTime.Now;
				newLifeThead.Latitude = MyMap.Center.Position.Latitude;
				newLifeThead.Longitude = MyMap.Center.Position.Longitude;
				App.DataModel.AddLifeThread(newLifeThead);
				Frame.Navigate(typeof(MainPage));
			}
			
		}
Exemple #3
0
		public async void DeleteLifeThread(LifeThread lifeThread)
		{
			_lifeThreads.Remove(lifeThread);
			await saveLifeThreadDataAsync();
		}
Exemple #4
0
		public async void AddLifeThread(LifeThread lifeThread)
		{
			_lifeThreads.Add(lifeThread);
			await saveLifeThreadDataAsync();
		}