예제 #1
0
        public void Image_Tap(VirtualizableImage source = null)
        {
            if (source == null)
            {
                source = Enumerable.FirstOrDefault <IVirtualizable>(this.VirtualizableChildren) as VirtualizableImage;
                if (source == null || source.Tag == null)
                {
                    return;
                }
            }
            int selectedPhotoIndex = int.Parse(source.Tag);

            if (this.ItemType == ThumbsItem.ItemDataType.Attachment)
            {
                List <Attachment> list1 = (List <Attachment>)Enumerable.ToList <Attachment>(Enumerable.OrderBy <Attachment, bool>(this._attachments, (Func <Attachment, bool>)(at =>
                {
                    if (at.doc == null)
                    {
                        return(false);
                    }
                    DocPreview preview = at.doc.preview;
                    return((preview != null ? preview.video : null) == null);
                })));
                Attachment attachment = list1[selectedPhotoIndex];
                if (attachment.type == "photo" || attachment.type == "doc")
                {
                    List <PhotoOrDocument> list = new List <PhotoOrDocument>();
                    int  selectedIndex          = 0;
                    bool flag = false;
                    IEnumerator <Attachment> enumerator = ((IEnumerable <Attachment>)Enumerable.Where <Attachment>(list1, (Func <Attachment, bool>)(at =>
                    {
                        if (at.photo == null)
                        {
                            return(at.doc != null);
                        }
                        return(true);
                    }))).GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            Attachment current = enumerator.Current;
                            if (current == attachment)
                            {
                                selectedIndex = list.Count;
                            }
                            if (current.doc != null)
                            {
                                flag = true;
                            }
                            list.Add(new PhotoOrDocument()
                            {
                                document = current.doc,
                                photo    = current.photo
                            });
                        }
                    }
                    finally
                    {
                        if (enumerator != null)
                        {
                            enumerator.Dispose();
                        }
                    }
                    if (flag)
                    {
                        InplaceGifViewerUC gifViewer = new InplaceGifViewerUC();
                        if (this._isCommentThumbItem)
                        {
                            CurrentMediaSource.GifPlaySource = StatisticsActionSource.comments;
                        }
                        else if (this._isMessage)
                        {
                            CurrentMediaSource.GifPlaySource = StatisticsActionSource.messages;
                        }
                        // ISSUE: method pointer
                        Navigator.Current.NavigateToImageViewerPhotosOrGifs(selectedIndex, list, false, this._friendsOnly, this.GetImageFunc(), null, false, (FrameworkElement)gifViewer, (Action <int>)(ind =>
                        {
                            Doc document = list[ind].document;
                            if (document != null)
                            {
                                InplaceGifViewerViewModel gifViewerViewModel = new InplaceGifViewerViewModel(document, true, true, false);
                                gifViewerViewModel.Play(GifPlayStartType.manual);
                                gifViewer.VM = gifViewerViewModel;
                                ((UIElement)gifViewer).Visibility = Visibility.Visible;
                            }
                            else
                            {
                                InplaceGifViewerViewModel vm = gifViewer.VM;
                                if (vm != null)
                                {
                                    vm.Stop();
                                }
                                ((UIElement)gifViewer).Visibility = Visibility.Collapsed;
                            }
                        }), new Action <int, bool>(this.ShowHideOverlay), false);
                    }
                    else
                    {
                        Navigator.Current.NavigateToImageViewer(this.PhotosCount, 0, this.PhotosListFromAttachments.IndexOf(attachment.photo), (List <long>)Enumerable.ToList <long>(Enumerable.Select <Photo, long>(this.PhotosListFromAttachments, (Func <Photo, long>)(p => p.pid))), (List <long>)Enumerable.ToList <long>(Enumerable.Select <Photo, long>(this.PhotosListFromAttachments, (Func <Photo, long>)(p => p.owner_id))), (List <string>)Enumerable.ToList <string>(Enumerable.Select <Photo, string>(this.PhotosListFromAttachments, (Func <Photo, string>)(p => p.access_key ?? ""))), this.PhotosListFromAttachments, "PhotosByIds", false, this._friendsOnly, this.GetImageFunc(), null, false);
                    }
                    if (!(attachment.type == "photo") || this._parentPostId == null)
                    {
                        return;
                    }
                    StatsEventsTracker.Instance.Handle(new PostActionEvent()
                    {
                        PostId     = this._parentPostId,
                        ActionType = PostActionType.PhotoOpened
                    });
                }
                else if (attachment.type == "video")
                {
                    if (attachment.video.owner_id == 0L || attachment.video.vid == 0L)
                    {
                        return;
                    }
                    if (this._isCommentThumbItem)
                    {
                        CurrentMediaSource.VideoSource  = StatisticsActionSource.comments;
                        CurrentMediaSource.VideoContext = this._itemId;
                    }
                    else if (this._isMessage)
                    {
                        CurrentMediaSource.VideoSource  = StatisticsActionSource.messages;
                        CurrentMediaSource.VideoContext = this._itemId;
                    }
                    else if (CurrentMediaSource.VideoSource == StatisticsActionSource.news)
                    {
                        CurrentMediaSource.VideoContext = this._itemId;
                    }
                    else if (CurrentMediaSource.VideoSource == StatisticsActionSource.wall_user || CurrentMediaSource.VideoSource == StatisticsActionSource.wall_group)
                    {
                        CurrentMediaSource.VideoContext = string.Concat(CurrentMediaSource.VideoContext, "|", this._itemId);
                    }
                    Navigator.Current.NavigateToVideoWithComments(attachment.video.guid == Guid.Empty ? attachment.video : null, attachment.video.owner_id, attachment.video.vid, attachment.video.access_key);
                    if (this._parentPostId == null)
                    {
                        return;
                    }
                    StatsEventsTracker.Instance.Handle(new PostActionEvent()
                    {
                        PostId     = this._parentPostId,
                        ActionType = PostActionType.VideoOpened
                    });
                }
                else if (attachment.type == "album")
                {
                    Album album = attachment.album;
                    if (album == null)
                    {
                        return;
                    }
                    AlbumType albumType = AlbumTypeHelper.GetAlbumType(album.aid);
                    Navigator.Current.NavigateToPhotoAlbum(Math.Abs(long.Parse(album.owner_id)), long.Parse(album.owner_id) < 0, albumType.ToString(), album.aid, "", 0, "", "", false, 0, false);
                }
                else
                {
                    if (!(attachment.type == "market_album"))
                    {
                        return;
                    }
                    MarketAlbum marketAlbum = attachment.market_album;
                    if (marketAlbum == null)
                    {
                        return;
                    }
                    Navigator.Current.NavigateToMarketAlbumProducts(marketAlbum.owner_id, marketAlbum.id, marketAlbum.title);
                }
            }
            else
            {
                if (this.ItemType != ThumbsItem.ItemDataType.NewsPhotosInfo || this._newsPhotosInfo.Photos.Count <= 0)
                {
                    return;
                }
                Navigator.Current.NaviateToImageViewerPhotoFeed(Math.Abs(this._newsPhotosInfo.SourceId), this._newsPhotosInfo.SourceId < 0, ((Photo)Enumerable.First <Photo>(this._newsPhotosInfo.Photos)).aid.ToString(), this._newsPhotosInfo.Count, selectedPhotoIndex, this._newsPhotosInfo.Date, this._newsPhotosInfo.Photos, this._newsPhotosInfo.NewsType == NewsPhotosInfo.NewsPhotoType.Photo ? "Photos" : "PhotoTags", this.GetImageFunc());
            }
        }
예제 #2
0
        private void GoToAlbum()
        {
            if (this.PhotoVM.PhotoWithInfo == null || this.PhotoVM.PhotoWithInfo.Photo == null)
            {
                return;
            }
            Photo     photo     = this.PhotoVM.PhotoWithInfo.Photo;
            AlbumType albumType = AlbumTypeHelper.GetAlbumType(photo.aid);

            Navigator.Current.NavigateToPhotoAlbum(photo.owner_id > 0L ? photo.owner_id : -photo.owner_id, photo.owner_id < 0, albumType.ToString(), photo.aid.ToString(), "", 0, "", "", false, 0, false);
        }
예제 #3
0
        public void Image_Tap(VirtualizableImage source = null)
        {
            if (source == null)
            {
                source = this.VirtualizableChildren.FirstOrDefault <IVirtualizable>() as VirtualizableImage;
                if (source == null || source.Tag == null)
                {
                    return;
                }
            }
            int selectedPhotoIndex = int.Parse(source.Tag);

            if (this.ItemType == ThumbsItem.ItemDataType.Attachment)
            {
                List <Attachment> list1 = this._attachments.OrderBy <Attachment, bool>((Func <Attachment, bool>)(at =>
                {
                    if (at.doc == null)
                    {
                        return(false);
                    }
                    DocPreview preview = at.doc.preview;
                    return((preview != null ? preview.video : (DocPreviewVideo)null) == null);
                })).ToList <Attachment>();
                Attachment attachment1 = list1[selectedPhotoIndex];
                if (attachment1.type == "photo" || attachment1.type == "doc")
                {
                    List <PhotoOrDocument> list = new List <PhotoOrDocument>();
                    int  selectedIndex          = 0;
                    bool flag = false;
                    foreach (Attachment attachment2 in list1.Where <Attachment>((Func <Attachment, bool>)(at =>
                    {
                        if (at.photo == null)
                        {
                            return(at.doc != null);
                        }
                        return(true);
                    })))
                    {
                        if (attachment2 == attachment1)
                        {
                            selectedIndex = list.Count;
                        }
                        if (attachment2.doc != null)
                        {
                            flag = true;
                        }
                        list.Add(new PhotoOrDocument()
                        {
                            document = attachment2.doc,
                            photo    = attachment2.photo
                        });
                    }
                    if (flag)
                    {
                        InplaceGifViewerUC gifViewer = new InplaceGifViewerUC();
                        if (this._isCommentThumbItem)
                        {
                            CurrentMediaSource.GifPlaySource = StatisticsActionSource.comments;
                        }
                        else if (this._isMessage)
                        {
                            CurrentMediaSource.GifPlaySource = StatisticsActionSource.messages;
                        }
                        Navigator.Current.NavigateToImageViewerPhotosOrGifs(selectedIndex, list, false, this._friendsOnly, this.GetImageFunc(), (PageBase)null, false, (FrameworkElement)gifViewer, (Action <int>)(ind =>
                        {
                            Doc document = list[ind].document;
                            if (document != null)
                            {
                                InplaceGifViewerViewModel gifViewerViewModel = new InplaceGifViewerViewModel(document, true, true, false);
                                gifViewerViewModel.Play(GifPlayStartType.manual);
                                gifViewer.VM         = gifViewerViewModel;
                                gifViewer.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                InplaceGifViewerViewModel vm = gifViewer.VM;
                                if (vm != null)
                                {
                                    vm.Stop();
                                }
                                gifViewer.Visibility = Visibility.Collapsed;
                            }
                        }), new Action <int, bool>(this.ShowHideOverlay), false);
                    }
                    else
                    {
                        Navigator.Current.NavigateToImageViewer(this.PhotosCount, 0, this.PhotosListFromAttachments.IndexOf(attachment1.photo), this.PhotosListFromAttachments.Select <Photo, long>((Func <Photo, long>)(p => p.pid)).ToList <long>(), this.PhotosListFromAttachments.Select <Photo, long>((Func <Photo, long>)(p => p.owner_id)).ToList <long>(), this.PhotosListFromAttachments.Select <Photo, string>((Func <Photo, string>)(p => p.access_key ?? "")).ToList <string>(), this.PhotosListFromAttachments, "PhotosByIds", false, this._friendsOnly, this.GetImageFunc(), (PageBase)null, false);
                    }
                }
                else if (attachment1.type == "video")
                {
                    if (attachment1.video.owner_id == 0L || attachment1.video.vid == 0L)
                    {
                        return;
                    }
                    if (this._isCommentThumbItem)
                    {
                        CurrentMediaSource.VideoSource  = StatisticsActionSource.comments;
                        CurrentMediaSource.VideoContext = this._itemId;
                    }
                    else if (this._isMessage)
                    {
                        CurrentMediaSource.VideoSource  = StatisticsActionSource.messages;
                        CurrentMediaSource.VideoContext = this._itemId;
                    }
                    else if (CurrentMediaSource.VideoSource == StatisticsActionSource.news)
                    {
                        CurrentMediaSource.VideoContext = this._itemId;
                    }
                    else if (CurrentMediaSource.VideoSource == StatisticsActionSource.wall_user || CurrentMediaSource.VideoSource == StatisticsActionSource.wall_group)
                    {
                        CurrentMediaSource.VideoContext = CurrentMediaSource.VideoContext + "|" + this._itemId;
                    }
                    Navigator.Current.NavigateToVideoWithComments(attachment1.video.guid == Guid.Empty ? attachment1.video : null, attachment1.video.owner_id, attachment1.video.vid, attachment1.video.access_key);
                }
                else if (attachment1.type == "album")
                {
                    Album album = attachment1.album;
                    if (album == null)
                    {
                        return;
                    }
                    AlbumType albumType = AlbumTypeHelper.GetAlbumType(album.aid);
                    Navigator.Current.NavigateToPhotoAlbum(Math.Abs(long.Parse(album.owner_id)), long.Parse(album.owner_id) < 0L, albumType.ToString(), album.aid, "", 0, "", "", false, 0);
                }
                else
                {
                    if (!(attachment1.type == "market_album"))
                    {
                        return;
                    }
                    MarketAlbum marketAlbum = attachment1.market_album;
                    if (marketAlbum == null)
                    {
                        return;
                    }
                    Navigator.Current.NavigateToMarketAlbumProducts(marketAlbum.owner_id, marketAlbum.id, marketAlbum.title);
                }
            }
            else
            {
                if (this.ItemType != ThumbsItem.ItemDataType.NewsPhotosInfo || this._newsPhotosInfo.Photos.Count <= 0)
                {
                    return;
                }
                Navigator.Current.NaviateToImageViewerPhotoFeed(Math.Abs(this._newsPhotosInfo.SourceId), this._newsPhotosInfo.SourceId < 0L, this._newsPhotosInfo.Photos.First <Photo>().aid.ToString(), this._newsPhotosInfo.Count, selectedPhotoIndex, this._newsPhotosInfo.Date, this._newsPhotosInfo.Photos, this._newsPhotosInfo.NewsType == NewsPhotosInfo.NewsPhotoType.Photo ? "Photos" : "PhotoTags", this.GetImageFunc());
            }
        }