private async void uploadme_Click(object sender, RoutedEventArgs e) { //pick = true;//确定marker已选 /*AGeolocator ageol = new AGeolocator(); //初始化一个AGeolocator对象 //设置位置改变监听器,调用ageol_PositionChanged 函数 ageol.PositionChanged += ageol_PositionChanged;*/ if (!pick) { MessageDialog msg = new MessageDialog("请先定位"); await msg.ShowAsync(); } else { Boolean check = false; if (ListItems.Items.Count == 0) check = true; for (int i = 0; i < ListItems.Items.Count; i++) { location2 item = new location2(); item = ListItems.Items[i] as location2; if (item.user_id.Equals(user.UserId.ToString())) { check = true; item.x = marker.LngLat.LngX; item.y = marker.LngLat.LatY; UpdateCheckedTodoItem(item); /*MessageDialog msg = new MessageDialog(item.x.ToString() + " " + item.y.ToString()); msg.ShowAsync();*/ //break; } } if (!check) { var location_item = new location { x = marker.LngLat.LngX, y = marker.LngLat.LatY, Text = name, user_id = user.UserId.ToString() }; InsertTodoItem(location_item); } me_x = marker.LngLat.LngX; me_y = marker.LngLat.LatY; for (int i = 0; i < items2_t.Count; i++) { if (items2_t[i].value>0&&items2_t[i].Text!=name) { //MessageDialog msg = new MessageDialog(items2_t[i].value.ToString()); /*MessageDialog msg = new MessageDialog(GetDistance(me_y,me_x,items2_t[i].y,items2_t[i].x).ToString()); await msg.ShowAsync();*/ double dist=GetDistance(me_y,me_x,items2_t[i].y,items2_t[i].x); if (dist < 2000) { senttalkcontent("0","0",items2_t[i].Text,items2_t[i].user_id,name+"在您附近"+dist.ToString()+"米"); } } } } }
private async void DeleteTodoItem(location2 location_item) { //await todoTable.DeleteAsync(location_item); location location_item2 = new location(); location_item2.Id = location_item.Id; location_item2.Text = location_item.Text; location_item2.user_id = location_item.user_id; location_item2.x = location_item.x; location_item2.y = location_item.y; items2_t.Remove(location_item); await todoTable.DeleteAsync(location_item2); await RefreshTodoItems(); //items.Remove(location_item); }
private async void UpdateCheckedTodoItem(location2 item) { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list location location_item2 = new location(); location_item2.Id = item.Id; location_item2.Text = item.Text; location_item2.user_id = item.user_id; location_item2.x = item.x; location_item2.y = item.y; await todoTable.UpdateAsync(location_item2); await RefreshTodoItems(); //items.Remove(item); }
private async void InsertTodoItem(location location_item) { // This code inserts a new TodoItem into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView await todoTable.InsertAsync(location_item); location2 location_item2 = new location2(); location_item2.Id = location_item.Id; location_item2.Text = location_item.Text; location_item2.user_id = location_item.user_id; location_item2.x = location_item.x; location_item2.y = location_item.y; location_item2.value = 10; location_item2.image = new BitmapImage(new Uri("ms-appx:///Assets/res/我.png", UriKind.Absolute)); items2_t.Add(location_item2); await RefreshTodoItems(); //items.Add(location_item); }