Esempio n. 1
0
        private async void MenuItem_Click_1(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //string commentID = (commentsBox.SelectedItem as Post.Comment).commentID;
            string           index      = (string)(sender as Button).Tag;
            CustomMessageBox messageBox = new CustomMessageBox()
            {
                Message            = AppResources.doYouReallyWant,
                Caption            = AppResources.warning,
                LeftButtonContent  = AppResources.yes,
                RightButtonContent = AppResources.cancel
                                     //IsFullScreen = (bool)FullScreenCheckBox.IsChecked
            };

            var result = await ShowAsync(messageBox);

            switch (result)
            {
            case CustomMessageBoxResult.LeftButton:
                int res = await Global.googLib.RemoveComment(index);

                if (res != 1)
                {
                    Post.Comment comment = (from p in post.comments
                                            where p.commentID == index
                                            select p).FirstOrDefault();
                    post.comments.Remove(comment);
                    commentsBox.ItemsSource = null;
                    commentsBox.ItemsSource = post.comments;
                }
                break;

            case CustomMessageBoxResult.RightButton:
            case CustomMessageBoxResult.None:
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
        static Post _parsePost(JToken result)
        {
            Post post = new Post();

            post.type        = (string)result["sourceStreamName"];
            post.postID      = (string)result["updateId"];
            post.author      = (string)result["authorName"];
            post.avatar      = (string)result["author"]["photoUrl"];
            post.content     = (string)result["textTitle"];
            post.time        = (long)result["timestamp"];
            post.richContent = (string)result["title"];
            post.userID      = (string)result["author"]["obfuscatedId"];
            if (result["sharedFromAuthor"] != null)
            {
                post.shared.name        = (string)result["sharedFromAuthor"]["userName"];
                post.shared.userID      = (string)result["sharedFromAuthor"]["obfuscatedId"];
                post.shared.postID      = (string)result["originalItemId"];
                post.shared.content     = (string)result["originalAnnotation"];
                post.shared.richContent = (string)result["annotation"];
            }
            if (result["plusone"] != null)
            {
                post.plusCount          = Convert.ToInt32((string)result["plusone"]["globalCount"]);
                post.isPlusonedByViewer = (bool)result["plusone"]["isPlusonedByViewer"];
            }
            post.commentsCount    = (int)result["totalCommentCount"];
            post.reshareCount     = (int)result["originalReshareCount"];
            post.isMuted          = (bool)result["isMute"];
            post.isLocked         = (bool)result["isStrangerPost"];
            post.canViewerComment = (bool)result["canViewerComment"];
            if (result["comment"] != null)
            {
                foreach (var c in result["comment"])
                {
                    Post.Comment comment = new Post.Comment();
                    comment.author       = (string)c["author"]["userName"];
                    comment.userID       = (string)c["obfuscatedId"];
                    comment.commentID    = (string)c["commentId"];
                    comment.text         = (string)c["text"];
                    comment.originalText = (string)c["originalText"];
                    comment.avatar       = (string)c["author"]["photoUrl"];
                    comment.time         = (string)c["timestamp"];
                    if (c["plusone"] != null)
                    {
                        comment.plusCount          = Convert.ToInt32((string)c["plusone"]["globalCount"]);
                        comment.isPlusonedByViewer = (bool)c["plusone"]["isPlusonedByViewer"];
                    }
                    post.comments.Add(comment);
                }
            }
            if (result["location"] != null)
            {
                post.latitude    = (float)result["location"]["latitude"];
                post.longitude   = (float)result["location"]["latitude"];
                post.locationTag = (string)result["location"]["locationTag"];
                post.mapUrl      = (string)result["location"]["mapUrl"];
                post.mapPageUrl  = (string)result["location"]["mapsPageUrl"];
            }

            if (result["embed"] != null)
            {
                if (result["embed"]["emotishareV2"] != null)
                {
                    post.media.url   = (string)result["embed"]["emotishareV2"]["url"];
                    post.media.title = (string)result["embed"]["emotishareV2"]["name"];
                    if (result["embed"]["emotishareV2"]["proxiedImage"] != null)
                    {
                        post.media.image = (string)result["embed"]["emotishareV2"]["proxiedImage"]["imageUrl"];
                    }
                }
                if (result["embed"]["videoObjectV2"] != null)
                {
                    post.media.url = (string)result["embed"]["videoObjectV2"]["url"];
                    if (result["embed"]["videoObjectV2"]["proxiedImage"] != null)
                    {
                        post.media.image = (string)result["embed"]["videoObjectV2"]["proxiedImage"]["imageUrl"];
                    }
                    post.media.title       = (string)result["embed"]["videoObjectV2"]["name"];
                    post.media.description = (string)result["embed"]["videoObjectV2"]["description"];
                }
                if (result["embed"]["webPageV2"] != null)
                {
                    post.media.url    = (string)result["embed"]["webPageV2"]["url"];
                    post.media.title  = (string)result["embed"]["webPageV2"]["name"];
                    post.media.source = (string)result["embed"]["webPageV2"]["source"];
                    if (result["embed"]["webPageV2"]["proxiedImage"] != null)
                    {
                        post.media.image = (string)result["embed"]["webPageV2"]["proxiedImage"]["imageUrl"];
                    }
                }

                if (result["embed"]["postPhotoV2"] != null)
                {
                    post.media.url   = (string)result["embed"]["postPhotoV2"]["url"];
                    post.media.title = (string)result["embed"]["postPhotoV2"]["name"];
                    post.media.image = (string)result["embed"]["postPhotoV2"]["imageUrl"];
                    //post.photo.thumb = (string)result["embed"]["postPhotoV2"]["proxiedImage"]["imageUrl"];
                }
                if (result["embed"]["plusPhotoAlbumV2"] != null)
                {
                    /*
                     *  foreach (var item in data[97].Last.First.First[41])
                     *  {
                     *      Post.Photo photo = new Post.Photo();
                     *      photo.desc = item.Last.First.First[3].ToString();
                     *      photo.albumUrl = item.Last.First.First[0].ToString();
                     *      if (item.Last.First.First[5].HasValues)
                     *          photo.thumbImage = _parseLink(item.Last.First.First[5][0].ToString());
                     *      photo.image = item.Last.First.First[1].ToString();
                     *      post.photos.Add(photo);
                     *  }
                     *  var mainPhoto = (from p in post.photos
                     *                   where p.albumUrl.Contains(data[97].Last.First.First[26].ToString())
                     *                   select p).FirstOrDefault();
                     *  if (mainPhoto != null)
                     *      post.photo = mainPhoto.thumbImage;
                     *  else if (data[97].Last.First.First[5].HasValues)
                     *      post.photo = _parseLink(data[97].Last.First.First[5][0].ToString())
                     */
                    foreach (var item in result["embed"]["plusPhotoAlbumV2"]["associatedMedia"])
                    {
                        Post.Photo photo = new Post.Photo();
                        photo.desc       = (string)item["plusPhotoV2"]["description"];
                        photo.image      = (string)item["plusPhotoV2"]["imageUrl"];
                        photo.albumUrl   = (string)item["plusPhotoV2"]["url"];
                        photo.thumbImage = (string)item["plusPhotoV2"]["proxiedImage"]["imageUrl"];
                        post.photos.Add(photo);
                    }
                }
                if (result["embed"]["plusEventV2"] != null)
                {
                    post.events = Events.parseEvent((JObject)result["embed"]["plusEventV2"]);
                }
            }
            return(post);
        }