public Page_DetailNhaTro() { InitializeComponent(); item = new NhaTro(); _tooltip = new USCustomPushpin(); Infoex = new NhaTro(); itemInlist = new NhaTro(); }
protected async override void OnNavigatedTo(NavigationEventArgs e) { //if (AppManagement._flagsaveNTTrangChu == true) // NavigationService.GoBack(); if (AppManagement._flagHouseSave == false) { string _url = ""; _url = AppManagement._URI + "task=getRoomsByIds&scope=title,description,id,address&link=1&rids=" + AppManagement.listPivot.ElementAt(0).id + "&num=1"; HttpClient client = new HttpClient(); var response = await client.GetStringAsync(new Uri(_url)); var data = JsonConvert.DeserializeObject <IDictionary <string, object> >(response)["data"]; AppManagement.ListInfoExtend.ListInfoExtends = JsonConvert.DeserializeObject <List <InfoExtends> >(data.ToString()); getItem(); pivotNT.ItemsSource = AppManagement.listPivot; AppManagement._flagnavigateBack = true; AppManagement._flagFillMarker = true; item = pivotNT.Items.ElementAt(0) as NhaTro; itemInlist = AppManagement.list.FirstOrDefault(r => r.id == item.id); _tooltip = AppManagement._list_marker.FirstOrDefault(r => r.TagId == item.id); if (item.flagColor == 1) { item.flagColor = 2; itemInlist.flagColor = 2; if (AppManagement._nhadaxem == null) { AppManagement._nhadaxem = new List <NhaTro>(); } AppManagement._nhadaxem.Add(item); Controller_Read_Write_NhaTro.WriteNhaXem(); } _tooltip.ColorMarker = item.flagColor.ToString(); _tooltip.FillMarker(); iconStar.Source = new BitmapImage(new Uri(item.link, UriKind.Relative)); } else { pivotNT.ItemsSource = AppManagement.listPivot; AppManagement._flagnavigateBack = true; AppManagement._flagFillMarker = true; item = pivotNT.Items.ElementAt(0) as NhaTro; iconStar.Source = new BitmapImage(new Uri(item.link, UriKind.Relative)); } }
private void Remove_Add_NhaTro(ICollection <NhaTro> newlist) { for (int i = 0; i < AppManagement._list_marker.Count; i++) { int dem = 0; for (int j = 0; j < newlist.Count; j++) { if (AppManagement._list_marker[i].TagId == newlist.ElementAt(j).id) { break; } else { dem += 1; } } if (dem == newlist.Count) { var marker = AppManagement._list_marker.ElementAt(i); AppManagement._list_marker.Remove(marker); AppManagement._layer.Remove(AppManagement._layer.FirstOrDefault(r => r.Content == marker)); i -= 1; } } for (int i = 0; i < newlist.Count; i++) { int dem = 0; for (int j = 0; j < AppManagement._list_marker.Count; j++) { if (AppManagement._list_marker[j].TagId == newlist.ElementAt(i).id) { break; } else { dem += 1; } } if (dem == AppManagement._list_marker.Count) { USCustomPushpin _tooltip = new USCustomPushpin(); _tooltip.TagId = newlist.ElementAt(i).id; _tooltip.Price = newlist.ElementAt(i).price; _tooltip.PathStar = newlist.ElementAt(i).flagColor.ToString(); _tooltip.ColorMarker = newlist.ElementAt(i).flagColor.ToString(); _tooltip.FillMarker(); var _grid = _tooltip.Content as Grid; var _stackpanel = _grid.Children.FirstOrDefault(r => r.GetType() == new StackPanel().GetType()) as StackPanel; _stackpanel.Tag = _tooltip.TagId; _stackpanel.Tap += Marker_Tapped; AppManagement._list_marker.Add(_tooltip); MapOverlay overlay = new MapOverlay(); overlay.Content = _tooltip; GeoCoordinate coo = new GeoCoordinate(); coo.Latitude = double.Parse(AppManagement.list.ElementAt(i).latitude, CultureInfo.InvariantCulture); coo.Longitude = double.Parse(AppManagement.list.ElementAt(i).longitude, CultureInfo.InvariantCulture); overlay.GeoCoordinate = coo; AppManagement._layer.Add(overlay); } } }