public async void SaveEvent(object sender, RoutedEventArgs e) { try { if(Activity.Text=="") { InvalidInput(); return; } Info data = new Info() { UserId = (++App.i).ToString(), Activity = Activity.Text.Trim(), Lat = pin.Location.Position.Latitude, Long = pin.Location.Position.Longitude, Interested = 1 }; var DataBase = new ParseObject("Activities"); DataBase["UserID"] = data.UserId.ToString(); DataBase["Interested"] = data.Interested; DataBase["Activity"] = data.Activity; DataBase["Location"] = new ParseGeoPoint(data.Lat, data.Long); await DataBase.SaveAsync(); Frame.Navigate(typeof(Nearby)); } catch(Exception ex) { Message.Text = ex.Message; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { info = e.Parameter as Info; ActivityName.Text = info.Activity; UpFor.Text = info.Interested.ToString() + " people are up for this!"; BasicGeoposition upos = new BasicGeoposition() { Latitude = info.Lat, Longitude = info.Long }; Map.Center = new Geopoint(upos); Map.ZoomLevel = 15; Map.LandmarksVisible = true; MapIcon pin = new MapIcon(); pin.Location = new Geopoint(upos); pin.NormalizedAnchorPoint = new Point(0.5, 1.0); Map.MapElements.Add(pin); Windows.Phone.UI.Input.HardwareButtons.BackPressed += App.HardwareButtons_BackPressed; }
/// <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) { bool isConnected = NetworkInterface.GetIsNetworkAvailable(); if (!isConnected) { await new MessageDialog("No internet connection is avaliable. The full functionality of the app isn't avaliable.").ShowAsync(); Application.Current.Exit(); } Geolocator geolocator = new Geolocator(); Geoposition pos = await geolocator.GetGeopositionAsync(); var geo = new ParseGeoPoint(pos.Coordinate.Point.Position.Latitude, pos.Coordinate.Point.Position.Longitude); try { ParseQuery<ParseObject> query = ParseObject.GetQuery("Activities") .WhereWithinDistance("Location", geo, ParseGeoDistance.FromMiles(10)).OrderByDescending("Interested"); IEnumerable<ParseObject> nearbyLocations = await query.FindAsync(); List<Info> users = new List<Info>(); foreach (var item in nearbyLocations) { Info variable = new Info(); variable.Activity = item.Get<String>("Activity"); variable.Interested = item.Get<int>("Interested"); variable.ObjID = item.ObjectId; ParseGeoPoint point = item.Get<ParseGeoPoint>("Location"); variable.Lat = point.Latitude; variable.Long = point.Longitude; users.Add(variable); } Activities.ItemsSource = users; } catch(Exception ex) { Heading.Text = ex.Message; } Windows.Phone.UI.Input.HardwareButtons.BackPressed += App.HardwareButtons_BackPressed; }