示例#1
0
        private List <IVirtualizable> GetMoreOtherVideoItems()
        {
            List <IVirtualizable>      virtualizableList  = new List <IVirtualizable>();
            IVideoCatalogItemUCFactory catalogItemFactory = ServiceLocator.Resolve <IVideoCatalogItemUCFactory>();
            VKList <VKClient.Common.Backend.DataObjects.Video> otherVideos = this.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
                })));
            }
            IEnumerator <VKClient.Common.Backend.DataObjects.Video> enumerator = ((IEnumerable <VKClient.Common.Backend.DataObjects.Video>)Enumerable.Skip <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       ucItem      = 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)ucItem);
                }
            }
            finally
            {
                if (enumerator != null)
                {
                    enumerator.Dispose();
                }
            }
            return(virtualizableList);
        }
示例#2
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);
        }