// Group list retrieved for a user
        private void OnGroupListReturned(object sender, GetGroupListEventArgs e)
        {
            // Find the user
            if (!UserCache.ContainsKey(e.UserId))
                return;

            User user = UserCache[e.UserId];

            JObject rawJson = JObject.Parse(e.Response);
            JObject rootJson = (JObject)rawJson["groups"];

            List<FlickrGroup> result = new List<FlickrGroup>();
            user.GroupIds = new List<string>();
            foreach (var entry in rootJson["group"])
            {
                JObject json = (JObject)entry;
                FlickrGroup group = FlickrGroupFactory.GroupWithJObject(json);
                user.GroupIds.Add(group.ResourceId);
                result.Add(group);
            }

            // Dispatch event
            GroupListUpdatedEventArgs evt = new GroupListUpdatedEventArgs();
            evt.UserId = e.UserId;
            evt.Groups = result;
            GroupListUpdated.DispatchEvent(this, evt);
        }
Ejemplo n.º 2
0
        // Group list updated
        private void OnGroupListUpdated(object sender, GroupListUpdatedEventArgs e)
        {
            Dispatcher.BeginInvoke(() =>
            {
                if (e.UserId != Cinderella.CinderellaCore.CurrentUser.ResourceId)
                    return;

                if (Cinderella.CinderellaCore.GroupCache.Count == 0)
                {
                    GroupListStatusLabel.Text = AppResources.PreludeNoGroupFoundText;
                    GroupListStatusLabel.Visibility = Visibility.Visible;
                    GroupListView.Visibility = Visibility.Collapsed;
                }
                else
                {
                    GroupListStatusLabel.Visibility = Visibility.Collapsed;
                    GroupListView.Visibility = Visibility.Visible;

                    GroupList.Clear();
                    foreach (FlickrGroup group in e.Groups)
                    {
                        GroupList.Add(group);
                    }
                }

            });
        }