コード例 #1
0
        private void OnPhotoSearchReturned(object sender, PhotoSearchEventArgs e)
        {
            JObject json = JObject.Parse(e.Response);
            JObject photosetJson = (JObject)json["photos"];

            int page = int.Parse(photosetJson["page"].ToString());
            int perPage = int.Parse(photosetJson["perpage"].ToString());
            int numTotal = int.Parse(photosetJson["total"].ToString());

            List<Photo> photos = new List<Photo>();
            foreach (var photoJson in photosetJson["photo"])
            {
                Photo photo = PhotoFactory.PhotoWithJObject((JObject)photoJson);
                photos.Add(photo);
            }

            PhotoSearchResultEventArgs evt = new PhotoSearchResultEventArgs();
            evt.SearchSessionId = e.SearchSessionId;
            evt.Page = page;
            evt.PerPage = perPage;
            evt.TotalCount = numTotal;
            evt.Photos = photos;
            PhotoSearchCompleted.DispatchEvent(this, evt);
        }
コード例 #2
0
        private void OnPhotoSearchResult(object sender, PhotoSearchResultEventArgs e)
        {
            Dispatcher.BeginInvoke(() => {
                if (e.SearchSessionId != SearchSessionId)
                    return;

                if (_photos.Count == 0 && e.Photos.Count == 0)
                {
                    NoResultLabel.Visibility = Visibility.Visible;
                    ResultListView.Visibility = Visibility.Collapsed;
                    LoadingView.Visibility = Visibility.Collapsed;

                    return;
                }

                // Add new photos
                foreach (Photo photo in e.Photos)
                {
                    if (!_photos.Contains(photo))
                        _photos.Add(photo);
                }

                NoResultLabel.Visibility = Visibility.Collapsed;
                ResultListView.Visibility = Visibility.Visible;
                LoadingView.Visibility = Visibility.Collapsed;

                TotalCount = e.TotalCount;
            });
        }