Exemplo n.º 1
0
 private void webClient_DownloadRssCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     if (!e.Cancelled)
     {
         try
         {
             if (e.Error != null)
             {
                 throw e.Error;
             }
             else
             {
                 toolStripStatusLabel1.Text = "";
                 RssListViewItem r = e.UserState as RssListViewItem;
                 r.channel = new RssChannel(new MemoryStream(e.Result));
                 if (r.channel.Image.Url != null &&
                     Uri.IsWellFormedUriString(r.channel.Image.Url, UriKind.Absolute) &&
                     !FeedImageList.Images.ContainsKey(r.Name))
                 {
                     imageWebClient.CancelAsync();
                     imageWebClient.DownloadDataAsync(new Uri(r.channel.Image.Url), r);
                 }
                 FillListView(r.channel);
             }
         }
         catch (Exception ee)
         {
             HandleException(ee);
         }
     }
 }
Exemplo n.º 2
0
 void webClient_DownloadImageCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     if (!e.Cancelled)
     {
         if (e.Error == null)
         {
             RssListViewItem r = e.UserState as RssListViewItem;
             try
             {
                 Image i = byteArrayToImage(e.Result);
                 FeedImageList.Images.Add(r.Name, i);
                 try
                 {
                     using (IsolatedStorageFileStream oStream = new IsolatedStorageFileStream(Toolbox.MD5(r.Name), FileMode.Create, isoStore))
                     {
                         i.Save(oStream, ImageFormat.Png);
                     }
                 }
                 catch { }
             }
             catch (Exception ee)
             {
                 HandleException(ee);
             }
         }
     }
 }
Exemplo n.º 3
0
 private void RefreshRssFeed()
 {
     try
     {
         RssListViewItem r = rssFeedsListView.SelectedItems[0] as RssListViewItem;
         rssWebClient.CancelAsync();
         rssWebClient.DownloadDataAsync(new Uri(r.Url), r);
     }
     catch (Exception ex)
     {
         HandleException(ex);
     }
 }
Exemplo n.º 4
0
 private void rssFeedsListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
 {
     if (e.IsSelected)
     {
         RssListViewItem r = e.Item as RssListViewItem;
         if (r.channel == null)
         {
             RefreshRssFeed();
         }
         else
         {
             FillListView(r.channel);
         }
     }
 }