private void OnGroupTopicsReturned(object sender, GetGroupTopicsEventArgs e) { if (!Cinderella.CinderellaCore.GroupCache.ContainsKey(e.GroupId)) return; FlickrGroup group = Cinderella.CinderellaCore.GroupCache[e.GroupId]; JObject rawJson = JObject.Parse(e.Response); JObject rootJson = (JObject)rawJson["topics"]; int TotalCount = int.Parse(rootJson["total"].ToString()); int page = int.Parse(rootJson["page"].ToString()); int numPages = int.Parse(rootJson["pages"].ToString()); int perPage = int.Parse(rootJson["per_page"].ToString()); List<Topic> newTopics = new List<Topic>(); if (TotalCount > 0) { foreach (var entry in rootJson["topic"]) { JObject json = (JObject)entry; Topic topic = TopicFactory.TopicWithJObject(json, group); if (!group.Topics.Contains(topic)) { group.Topics.Add(topic); newTopics.Add(topic); } } } // Dispatch event GroupTopicsUpdatedEventArgs evt = new GroupTopicsUpdatedEventArgs(); evt.GroupId = group.ResourceId; evt.Page = page; evt.PageCount = numPages; evt.PerPage = perPage; evt.NewTopics = newTopics; GroupTopicsUpdated.DispatchEvent(this, evt); }
private void OnTopicListUpdated(object sender, GroupTopicsUpdatedEventArgs e) { Dispatcher.BeginInvoke(() => { if (e.GroupId == GroupSource.ResourceId) { if(SystemTray.ProgressIndicator != null) SystemTray.ProgressIndicator.IsVisible = false; } }); }
// Topic list updated private void OnTopicsUpdated(object sender, GroupTopicsUpdatedEventArgs e) { Dispatcher.BeginInvoke(() => { if (e.GroupId != GroupSource.ResourceId) return; if (e.NewTopics.Count == 0 && TopicCollection.Count == 0) { StatusLabel.Text = AppResources.GroupNoActiveTopicsText; StatusLabel.Visibility = Visibility.Visible; TopicListView.Visibility = Visibility.Collapsed; return; } if (e.NewTopics.Count == 0) return; StatusLabel.Visibility = Visibility.Collapsed; TopicListView.Visibility = Visibility.Visible; foreach (var topic in e.NewTopics) { if(!TopicCollection.Contains(topic)) TopicCollection.Add(topic); } }); }