Advertisement
FANMixco

country.xaml.cs

Sep 19th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12. using Microsoft.Phone.Controls;
  13. using Microsoft.Phone.Reactive;
  14. using Newtonsoft.Json;
  15. using La_Ruta_Maya.classes;
  16. using System.Text;
  17. using System.Device.Location;
  18.  
  19. namespace La_Ruta_Maya.pages
  20. {
  21.     public partial class country : PhoneApplicationPage
  22.     {
  23.         double Latitude;
  24.         double Longitude;
  25.         GeoCoordinateWatcher myCoordinateWatcher;
  26.  
  27.         public country()
  28.         {
  29.             InitializeComponent();
  30.         }
  31.  
  32.         private void PhoneApplicationPage_Loaded_1(object sender, RoutedEventArgs e)
  33.         {
  34.             string id = (this.NavigationContext.QueryString["id"]); ;
  35.  
  36.             WebClient w = new WebClient();
  37.             Observable
  38.             .FromEvent<DownloadStringCompletedEventArgs>(w, "DownloadStringCompleted")
  39.             .Subscribe(r =>
  40.             {
  41.                 var deserialized = JsonConvert.DeserializeObject<List<countries>>(r.EventArgs.Result);
  42.                 txtMapName.Text = deserialized[0].name.ToString();
  43.             });
  44.             w.DownloadStringAsync(
  45.             new Uri("http://localhost/mayaRouteLocal/countries.php?id=" + id));
  46.  
  47.  
  48.             WebClient w2 = new WebClient();
  49.             Observable
  50.             .FromEvent<DownloadStringCompletedEventArgs>(w2, "DownloadStringCompleted")
  51.             .Subscribe(r =>
  52.             {
  53.                 var deserialized  = JsonConvert.DeserializeObject<List<locationCountry>>(r.EventArgs.Result);
  54.                
  55.                 ruinsList.ItemsSource = deserialized;
  56.             });
  57.             w2.DownloadStringAsync(
  58.             new Uri("http://localhost/mayaRouteLocal/locationCountries.php?id=" + id));
  59.  
  60.             //Latitude = App.ViewModel.values[int.Parse(id) - 1].latitude;
  61.             //Latitude = App.ViewModel.values[int.Parse(id) - 1].longitude;
  62.  
  63.             //map1.Center = new GeoCoordinate(Latitude, Longitude);
  64.             //map1.ZoomLevel = 8;
  65.             //map1.ZoomBarVisibility = Visibility.Visible;
  66.             //myCoordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
  67.             //myCoordinateWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(myCoordinateWatcher_PositionChanged);
  68.  
  69.         }
  70.  
  71.         void myCoordinateWatcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
  72.         {
  73.             if (!e.Position.Location.IsUnknown)
  74.             {
  75.                 Latitude = e.Position.Location.Latitude;
  76.                 Longitude = e.Position.Location.Longitude;
  77.                 map1.Center = new GeoCoordinate(Latitude, Longitude);
  78.             }
  79.         }
  80.  
  81.         private void PhoneList_Tap(object sender, System.Windows.Input.GestureEventArgs e)
  82.         {
  83.             ListBox item = (ListBox)sender;
  84.             if (item.SelectedItem != null)
  85.             {
  86. //                ListBoxItem value = (ListBoxItem)item.SelectedIndex;
  87.  
  88.                 locationCountry lr = item.SelectedItem as locationCountry;
  89.  
  90.                 string url = "/pages/ruinDetail.xaml?id=" + lr.idruin.ToString();
  91.                 NavigationService.Navigate(new Uri(url, UriKind.Relative));
  92.             }
  93.             item.SelectedIndex = -1;
  94.         }
  95.    
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement