コード例 #1
0
        private CommentItem CreateCommentItem(Comment comment)
        {
            User  user  = Enumerable.FirstOrDefault <User>(this.VM.Users, (Func <User, bool>)(u => u.uid == comment.from_id));
            User  user2 = Enumerable.FirstOrDefault <User>(this.VM.Users2, (Func <User, bool>)(u => u.uid == comment.reply_to_uid));
            Group group = Enumerable.FirstOrDefault <Group>(this.VM.Groups, (Func <Group, bool>)(g => g.id == -comment.from_id));

            if (user == null && comment.from_id == AppGlobalStateManager.Current.LoggedInUserId)
            {
                user = AppGlobalStateManager.Current.GlobalState.LoggedInUser;
            }
            if (user2 == null && comment.reply_to_uid == AppGlobalStateManager.Current.LoggedInUserId)
            {
                user2 = AppGlobalStateManager.Current.GlobalState.LoggedInUser;
            }
            Action <CommentItem> replyCallback = new Action <CommentItem>(this.ReplyToComment);
            LikeObjectType       likeObjType   = LikeObjectType.comment;

            if (this.VM.LikeObjectType == LikeObjectType.photo)
            {
                likeObjType = LikeObjectType.photo_comment;
            }
            if (this.VM.LikeObjectType == LikeObjectType.video)
            {
                likeObjType = LikeObjectType.video_comment;
            }
            if (this.VM.LikeObjectType == LikeObjectType.market)
            {
                likeObjType = LikeObjectType.market_comment;
            }
            return(CommentsItemsGeneratorHelper.CreateCommentItem(480.0, comment, likeObjType, this.VM.OwnerId, user, user2, group, new Action <CommentItem>(this.DeleteComment), replyCallback, new Action <CommentItem>(this.EditComment), null));
        }
コード例 #2
0
 private void GenerateComments(double topMargin)
 {
     if (this._commentsCountItem == null)
     {
         this._commentsCountItem = CommentsItemsGeneratorHelper.CreateCommentsCountItem(this.Width, new Func <string>(this.GetCommentsHeaderText), 0.0, Application.Current.Resources["PhoneNewsBackgroundBrush"] as SolidColorBrush);
         this.VirtualizableChildren.Add((IVirtualizable)this._commentsCountItem);
     }
     this._commentsCountItem.ViewMargin = new Thickness(0.0, topMargin, 0.0, 0.0);
     topMargin += this._commentsCountItem.FixedHeight;
     if (this._commentItems == null)
     {
         this._commentItems = new List <CommentItem>();
         Comments comments = this._newsItemData.NewsItem.comments;
         if ((comments != null ? comments.list :  null) != null)
         {
             using (IEnumerator <Comment> enumerator = ((IEnumerable <Comment>)ListExtensions.TakeLast <Comment>(Enumerable.OrderBy <Comment, int>(new List <Comment>((IEnumerable <Comment>) this._newsItemData.NewsItem.comments.list), (Func <Comment, int>)(c => c.date)), 1)).GetEnumerator())
             {
                 while (((IEnumerator)enumerator).MoveNext())
                 {
                     Comment     comment     = enumerator.Current;
                     Stopwatch   stopwatch   = Stopwatch.StartNew();
                     CommentItem commentItem = new CommentItem(448.0, new Thickness(), LikeObjectType.comment, null, null, null, this._newsItemData.NewsItem.source_id, comment, Enumerable.FirstOrDefault <User>(this._newsItemData.Profiles, (Func <User, bool>)(u => u.uid == comment.from_id)), null, (Group)Enumerable.FirstOrDefault <Group>(this._newsItemData.Groups, (Func <Group, bool>)(g => g.id == comment.from_id)), null, "", "", null, true, false, "");
                     stopwatch.Stop();
                     this.VirtualizableChildren.Add((IVirtualizable)commentItem);
                     commentItem.ViewMargin = new Thickness(16.0, topMargin, 0.0, 0.0);
                     topMargin += commentItem.FixedHeight + 16.0;
                     this._commentItems.Add(commentItem);
                 }
             }
         }
     }
     else
     {
         foreach (CommentItem commentItem in this._commentItems)
         {
             commentItem.ViewMargin = new Thickness(16.0, topMargin, 0.0, 0.0);
             topMargin += commentItem.FixedHeight + 16.0;
         }
     }
     this._fixedHeight = topMargin;
 }
コード例 #3
0
        private List <IVirtualizable> GenereateVirtualizableItemsToAdd()
        {
            List <IVirtualizable> virtualizableList = new List <IVirtualizable>();

            if (!this._commentsAreLoaded)
            {
                LikesInfo likesInfo1 = new LikesInfo();
                likesInfo1.count        = this.VM.LikesCount;
                likesInfo1.repostsCount = this.VM.RepostsCount;
                List <long>     likesAllIds = this.VM.LikesAllIds;
                List <UserLike> m0List      = (likesAllIds != null ? Enumerable.ToList <UserLike>(Enumerable.Select <long, UserLike>(likesAllIds, (Func <long, UserLike>)(uid => new UserLike()
                {
                    uid = uid
                }))) :  null) ?? new List <UserLike>();
                likesInfo1.users = ((List <UserLike>)m0List);
                LikesInfo       likesInfo2 = likesInfo1;
                double          width1     = 480.0;
                Thickness       margin1    = new Thickness();
                LikedObjectData objectData = new LikedObjectData();
                objectData.OwnerId = this.VM.OwnerId;
                objectData.ItemId  = this.VM.ItemId;
                objectData.Type    = (int)this.VM.LikeObjectType;
                LikesInfo   likesInfo3   = likesInfo2;
                int         num1         = this.VM.CanRepost ? 1 : 0;
                int         num2         = this.VM.UserLiked ? 1 : 0;
                User        loggedInUser = AppGlobalStateManager.Current.GlobalState.LoggedInUser;
                List <User> users        = this.VM.Users;
                this._likesItem = new LikesItem(width1, margin1, objectData, likesInfo3, num1 != 0, num2 != 0, loggedInUser, users);
                virtualizableList.Add((IVirtualizable)this._likesItem);
                ISupportOtherVideos otherVideosVm = this.OtherVideosVM;
                List <VKClient.Common.Backend.DataObjects.Video> videoList;
                if (otherVideosVm == null)
                {
                    videoList = null;
                }
                else
                {
                    VKList <VKClient.Common.Backend.DataObjects.Video> otherVideos = otherVideosVm.OtherVideos;
                    videoList = otherVideos != null ? otherVideos.items :  null;
                }
                if (videoList != null && otherVideosVm.OtherVideos.items.Count > 0)
                {
                    VKList <VKClient.Common.Backend.DataObjects.Video> otherVideos = otherVideosVm.OtherVideos;
                    List <Group> groupList = new List <Group>();
                    List <User>  userList  = new List <User>();
                    if (otherVideos.profiles != null)
                    {
                        userList.AddRange((IEnumerable <User>)Enumerable.Select <User, User>(otherVideos.profiles, (Func <User, User>)(profile => new User()
                        {
                            id         = profile.id,
                            first_name = profile.first_name,
                            last_name  = profile.last_name
                        })));
                    }
                    if (otherVideos.groups != null)
                    {
                        groupList.AddRange((IEnumerable <Group>)Enumerable.Select <Group, Group>(otherVideos.groups, (Func <Group, Group>)(profile => new Group()
                        {
                            id   = profile.id,
                            name = profile.name
                        })));
                    }
                    double    width2  = 480.0;
                    Thickness margin2 = new Thickness(0.0, 0.0, 0.0, 8.0);
                    Func <UserControlVirtualizable> func1 = (Func <UserControlVirtualizable>)(() => (UserControlVirtualizable) new TextSeparatorUC()
                    {
                        Text = CommonResources.OtherVideos
                    });
                    // ISSUE: variable of the null type
                    double landscapeWidth1 = 0.0;
                    int    num3            = 0;
                    //Func<UserControlVirtualizable> getUserControlFunc1;
                    UCItem ucItem1 = new UCItem(width2, margin2, func1, (Func <double>)(() => 56.0), null, landscapeWidth1, num3 != 0);
                    virtualizableList.Add((IVirtualizable)ucItem1);
                    IVideoCatalogItemUCFactory catalogItemFactory = ServiceLocator.Resolve <IVideoCatalogItemUCFactory>();
                    IEnumerator <VKClient.Common.Backend.DataObjects.Video> enumerator = ((IEnumerable <VKClient.Common.Backend.DataObjects.Video>)Enumerable.Take <VKClient.Common.Backend.DataObjects.Video>(otherVideos.items, 3)).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            VKClient.Common.Backend.DataObjects.Video video = enumerator.Current;
                            List <User>  knownUsers  = userList;
                            List <Group> knownGroups = groupList;
                            UCItem       ucItem2     = new UCItem(480.0, new Thickness(), (Func <UserControlVirtualizable>)(() =>
                            {
                                UserControlVirtualizable controlVirtualizable = catalogItemFactory.Create(video, knownUsers, knownGroups, StatisticsActionSource.video_recommend, this.CreateVideoContext(otherVideos.context));
                                ((System.Windows.Controls.Panel)(controlVirtualizable as CatalogItemUC).GridLayoutRoot).Background = ((Brush)(Application.Current.Resources["PhoneNewsBackgroundBrush"] as SolidColorBrush));
                                return(controlVirtualizable);
                            }), new Func <double> (() => catalogItemFactory.Height), null, 0.0, false);
                            virtualizableList.Add((IVirtualizable)ucItem2);
                        }
                    }
                    finally
                    {
                        if (enumerator != null)
                        {
                            enumerator.Dispose();
                        }
                    }
                    double    width3  = 480.0;
                    Thickness margin3 = new Thickness();
                    Func <UserControlVirtualizable> func2 = (Func <UserControlVirtualizable>)(() => new UserControlVirtualizable());
                    // ISSUE: variable of the null type
                    double landscapeWidth2 = 0.0;
                    int    num4            = 0;
                    //Func<UserControlVirtualizable> getUserControlFunc2;
                    UCItem ucItem3 = new UCItem(width3, margin3, func2, (Func <double>)(() => 8.0), null, landscapeWidth2, num4 != 0);
                    virtualizableList.Add((IVirtualizable)ucItem3);
                    if (otherVideos.items.Count > 3)
                    {
                        this._moreVideosUCItem = new UCItem(480.0, new Thickness(), (Func <UserControlVirtualizable>)(() => (UserControlVirtualizable) new CategoryFooterShortUC()
                        {
                            TapAction = new Action(this.MoreVideos_OnTap)
                        }), (Func <double>)(() => 64.0), null, 0.0, false);
                        virtualizableList.Add((IVirtualizable)this._moreVideosUCItem);
                    }
                }
                int totalCommentsCount = this.VM.TotalCommentsCount;
                this._commentsCountSeparatorUC = new TextSeparatorUC()
                {
                    Text = CommentsItemsGeneratorHelper.GetTextForCommentsCount(totalCommentsCount)
                };
                this._commentsCountItem = new UCItem(480.0, new Thickness(), (Func <UserControlVirtualizable>)(() => (UserControlVirtualizable)this._commentsCountSeparatorUC), (Func <double>)(() => 56.0), null, 0.0, false);
                virtualizableList.Add((IVirtualizable)this._commentsCountItem);
            }
            if (this.CommentsCountForReload > 0 && !ListExtensions.IsNullOrEmpty((IList)this.VM.Comments))
            {
                ShowMoreCommentsUC showMoreCommentsUc = new ShowMoreCommentsUC();
                double             num = 54.0;
                ((FrameworkElement)showMoreCommentsUc).Height = num;
                Action action = (Action)(() => this._loadMoreCommentsItem_Tap(null, null));
                showMoreCommentsUc.OnClickAction = action;
                string textFor = CommentsItemsGeneratorHelper.GetTextFor(this.CommentsCountForReload);
                showMoreCommentsUc.Text = textFor;
                ShowMoreCommentsUC showMoreCommentsUC = showMoreCommentsUc;
                this._loadMoreCommentsItem = new UCItem(480.0, new Thickness(), (Func <UserControlVirtualizable>)(() => (UserControlVirtualizable)showMoreCommentsUC), (Func <double>)(() => 54.0), null, 0.0, false);
                virtualizableList.Add((IVirtualizable)this._loadMoreCommentsItem);
            }
            long        num5         = -1;
            CommentItem commentItem1 = Enumerable.FirstOrDefault <IVirtualizable>(this.virtPanel.VirtualizableItems, (Func <IVirtualizable, bool>)(i => i is CommentItem)) as CommentItem;

            if (commentItem1 != null)
            {
                num5 = commentItem1.Comment.cid;
            }
            List <Comment> .Enumerator enumerator1 = this.VM.Comments.GetEnumerator();
            try
            {
                while (enumerator1.MoveNext())
                {
                    Comment current = enumerator1.Current;
                    if (current.cid != num5)
                    {
                        CommentItem commentItem2 = this.CreateCommentItem(current);
                        virtualizableList.Add((IVirtualizable)commentItem2);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            finally
            {
                enumerator1.Dispose();
            }
            ((UIElement)this.ucNewComment).Opacity          = (this.VM.CanComment ? 1.0 : 0.6);
            ((UIElement)this.ucNewComment).IsHitTestVisible = this.VM.CanComment;
            return(virtualizableList);
        }
コード例 #4
0
 private void KeepCommentsCountItemUpToDate()
 {
     this._commentsCountSeparatorUC.Text = CommentsItemsGeneratorHelper.GetTextForCommentsCount(this._runningCommentsCount);
 }
コード例 #5
0
 private CommentItem CreateCommentItem(User user, Comment c, VKClient.Common.Backend.DataObjects.Group group)
 {
     return(CommentsItemsGeneratorHelper.CreateCommentItem(480.0, c, LikeObjectType.topic_comment, -this._gid, user, (User)null, group, new Action <CommentItem>(this.deleteCommentCallback), new Action <CommentItem>(this.replyCommentCallback), new Action <CommentItem>(this.editCommentCallback), (Action <CommentItem>)null));
 }