Advertisement
Guest User

MainPage.Xaml.cs

a guest
Jul 11th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1.  
  2. namespace AppUnno
  3. {
  4.     public partial class MainPage : PhoneApplicationPage
  5.     {
  6.     public ObservableCollection<PopularVideos> PopVideos;
  7.         int aux = 3;
  8.         private List<Artista> _artistas;
  9.  
  10.         // Constructor
  11.         public MainPage()
  12.         {
  13.             PopVideos = new ObservableCollection<PopularVideos>();
  14.             if (NetworkInterface.GetIsNetworkAvailable())
  15.             {
  16.                 InitializeComponent();
  17.                 ConsultaArtista("http://www.unnu.com/music-artists");
  18.                 //ConsultaPopularVideos("http://www.unnu.com/popular-music-videos");
  19.                 panorama.Visibility = Visibility.Collapsed;
  20.                 // Set the data context of the listbox control to the sample data
  21.                 //DataContext = App.ViewModel;
  22.                                
  23.                 // you are setting your DataContext to 'App.ViewModel',
  24.                 //if you aren't using it, do the following instead:
  25.                 DataContext = this;
  26.                 this.Loaded += new RoutedEventHandler(MainPage_Loaded);                
  27.                 carregaFeed();
  28.                 ApplicationBarra(aux);
  29.                 HtmlWeb.LoadAsync("http://www.unnu.com/popular-music-videos", DownLoadCompleted);
  30.             }
  31.             else
  32.             {
  33.                 var result = MessageBox.Show("There are problems in your connection. Please verify your connection and try again!", "", MessageBoxButton.OK);
  34.                 aux = 1;
  35.                 ApplicationBarra(aux);
  36.             }
  37.         }
  38.     private void DownLoadCompleted(object sender, HtmlDocumentLoadCompleted e)
  39.     {
  40.         PopVideos.Clear();
  41.         var data = e.Document.DocumentNode.SelectSingleNode("//div[@class='content']")
  42.            .Descendants("img")
  43.            .Select(img => new PopularVideos()
  44.            {                  
  45.                Titulo = img.Attributes["alt"].Value,
  46.                Url = img.Attributes["src"].Value,                  
  47.            }).ToList();
  48.  
  49.         Deployment.Current.Dispatcher.BeginInvoke(() =>
  50.         {
  51.  
  52.             foreach (var item in data)
  53.             {  
  54.                 PopVideos.Add(new PopularVideos(item.Titulo, item.Url));
  55.             }
  56.         });
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement