// Favourite stream returned private void OnFavouriteStreamReturned(object sender, GetFavouriteStreamEventArgs e) { JObject rawJson = JObject.Parse(e.Response); JObject rootJson = (JObject)rawJson["photos"]; TotalFavouritePhotosCount = int.Parse(rootJson["total"].ToString()); int page = int.Parse(rootJson["page"].ToString()); int numPages = int.Parse(rootJson["pages"].ToString()); int perPage = int.Parse(rootJson["perpage"].ToString()); List<Photo> newPhotos = new List<Photo>(); foreach (var entry in rootJson["photo"]) { JObject json = (JObject)entry; Photo photo = PhotoFactory.PhotoWithJObject(json); if (!FavouriteList.Contains(photo)) { FavouriteList.Add(photo); newPhotos.Add(photo); } } // Dispatch event FavouriteStreamUpdatedEventArgs args = new FavouriteStreamUpdatedEventArgs(); args.Page = page; args.PageCount = numPages; args.PerPage = perPage; args.NewPhotos = newPhotos; FavouriteStreamUpdated.DispatchEvent(this, args); }
// Favourite stream updated private void OnFavouriteStreamUpdated(object sender, FavouriteStreamUpdatedEventArgs e) { Dispatcher.BeginInvoke(() => { if(SystemTray.ProgressIndicator != null) SystemTray.ProgressIndicator.IsVisible = false; if (Cinderella.CinderellaCore.FavouriteList.Count == 0) { StatusLabel.Visibility = Visibility.Visible; StatusLabel.Text = AppResources.GenericNoContentFound; ResultListView.Visibility = Visibility.Collapsed; } else { StatusLabel.Visibility = Visibility.Collapsed; ResultListView.Visibility = Visibility.Visible; } if (e.NewPhotos.Count == 0) return; foreach (var photo in e.NewPhotos) { if(!_photos.Contains(photo)) _photos.Add(photo); } }); }
// Favourite stream updated private void OnFavouriteStreamUpdated(object sender, FavouriteStreamUpdatedEventArgs e) { Dispatcher.BeginInvoke(() => { if (Cinderella.CinderellaCore.FavouriteList.Count == 0) { StatusLabel.Text = "No photos available"; StatusLabel.Visibility = Visibility.Visible; PhotoStreamListView.Visibility = Visibility.Collapsed; return; } StatusLabel.Visibility = Visibility.Collapsed; PhotoStreamListView.Visibility = Visibility.Visible; if (e.NewPhotos.Count == 0) return; // Need a headline renderer? List<PhotoGroup> newGroups = null; if (PhotoCollection.Count >= 1 && PhotoCollection[0].IsHeadline) { newGroups = rendererFactory.GeneratePhotoGroups(e.NewPhotos); } else { newGroups = rendererFactory.GeneratePhotoGroupsWithHeadline(e.NewPhotos); } foreach (var group in newGroups) { PhotoCollection.Add(group); } UpdateStreamVisibility(); }); }