private void documentsList_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DocumentHeader selectedItem = this.documentsList.SelectedItem as DocumentHeader;

            this.documentsList.SelectedItem = null;
            if (selectedItem == null)
            {
                return;
            }
            if (!selectedItem.IsGif)
            {
                Navigator.Current.NavigateToWebUri(selectedItem.Document.url, true, false);
            }
            else
            {
                List <DocumentHeader> list1 = (List <DocumentHeader>)Enumerable.ToList <DocumentHeader>(Enumerable.Where <DocumentHeader>(this.ViewModel.DocumentsVM.Collection, (Func <DocumentHeader, bool>)(doc => doc.IsGif)));
                int num = -1;
                List <PhotoOrDocument> list = new List <PhotoOrDocument>();
                for (int index = 0; index < list1.Count; ++index)
                {
                    DocumentHeader documentHeader = list1[index];
                    if (documentHeader == selectedItem)
                    {
                        num = index;
                    }
                    list.Add(new PhotoOrDocument()
                    {
                        document = documentHeader.Document
                    });
                }
                if (num < 0)
                {
                    return;
                }
                InplaceGifViewerUC gifViewer = new InplaceGifViewerUC();
                Navigator.Current.NavigateToImageViewerPhotosOrGifs(num, list, false, false, null, null, false, (FrameworkElement)gifViewer, (Action <int>)(ind =>
                {
                    Doc document = list[ind].document;
                    if (document != null)
                    {
                        InplaceGifViewerViewModel gifViewerViewModel = new InplaceGifViewerViewModel(document, true, false, 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;
                    }
                }), (Action <int, bool>)((i, b) => {}), false);
            }
        }
Example #2
0
        private void list_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ExtendedLongListSelector extendedLongListSelector = (ExtendedLongListSelector)sender;
            DocumentHeader           documentHeader           = extendedLongListSelector.SelectedItem as DocumentHeader;

            if (documentHeader != null)
            {
                extendedLongListSelector.SelectedItem = (null);
                if (!documentHeader.IsGif)
                {
                    Navigator.Current.NavigateToWebUri(documentHeader.Document.url, true, false);
                    return;
                }
                InplaceGifViewerUC     gifViewer = new InplaceGifViewerUC();
                List <PhotoOrDocument> documents = new List <PhotoOrDocument>();
                int num = 0;
                List <DocumentHeader> list = Enumerable.ToList <DocumentHeader>(this.ViewModel.Sections[this.pivot.SelectedIndex].Items.Collection);
                if (this._isSearchNow)
                {
                    ObservableCollection <Group <DocumentHeader> > groupedCollection = ((GenericCollectionViewModel2 <VKList <Doc>, DocumentHeader>)extendedLongListSelector.DataContext).GroupedCollection;
                    list = new List <DocumentHeader>();
                    if (groupedCollection.Count > 0)
                    {
                        list = Enumerable.ToList <DocumentHeader>(groupedCollection[0]);
                    }
                    if (groupedCollection.Count > 1)
                    {
                        list.AddRange(Enumerable.ToList <DocumentHeader>(groupedCollection[1]));
                    }
                }
                IEnumerable <DocumentHeader> arg_103_0 = list;
                Func <DocumentHeader, bool>  arg_103_1 = new Func <DocumentHeader, bool>((document) => { return(document.IsGif); });

                using (IEnumerator <DocumentHeader> enumerator = Enumerable.Where <DocumentHeader>(arg_103_0, arg_103_1).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        DocumentHeader current = enumerator.Current;
                        if (current == documentHeader)
                        {
                            num = documents.Count;
                        }
                        documents.Add(new PhotoOrDocument
                        {
                            document = current.Document
                        });
                    }
                }
                Action <int> action = delegate(int i)
                {
                    if (documents[i].document != null)
                    {
                        InplaceGifViewerViewModel inplaceGifViewerViewModel = new InplaceGifViewerViewModel(documents[i].document, true, false, false);
                        gifViewer.VM = inplaceGifViewerViewModel;
                        inplaceGifViewerViewModel.Play(GifPlayStartType.manual);
                        gifViewer.Visibility = Visibility.Visible;
                        return;
                    }
                    InplaceGifViewerViewModel expr_58 = gifViewer.VM;
                    if (expr_58 != null)
                    {
                        expr_58.Stop();
                    }
                    gifViewer.Visibility = Visibility.Collapsed;
                };
                INavigator             arg_1DA_0 = Navigator.Current;
                int                    arg_1DA_1 = num;
                List <PhotoOrDocument> arg_1DA_2 = documents;
                bool                   arg_1DA_3 = false;
                bool                   arg_1DA_4 = false;

                bool             arg_1DA_7 = false;
                FrameworkElement arg_1DA_8 = gifViewer;
                Action <int>     arg_1DA_9 = action;
                //Action<int, bool> arg_1DA_10 = new Action<int, bool>(DocumentsPage.<>c.<>9.<list_OnSelectionChanged>b__8_3));

                arg_1DA_0.NavigateToImageViewerPhotosOrGifs(arg_1DA_1, arg_1DA_2, arg_1DA_3, arg_1DA_4, null, this, arg_1DA_7, arg_1DA_8, arg_1DA_9, null, this.ViewModel.OwnerId == AppGlobalStateManager.Current.LoggedInUserId);
            }
        }
Example #3
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());
            }
        }
        private async void HandleTap(DocumentHeader docHeader)
        {
            if (docHeader.IsGif)
            {
                if (this._tapHandled)
                {
                    return;
                }
                this._tapHandled = true;
                List <PhotoOrDocument> list = (List <PhotoOrDocument>)Enumerable.ToList <PhotoOrDocument>(Enumerable.Select <Attachment, PhotoOrDocument>(Enumerable.Where <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);
                }))), (Func <Attachment, bool>)(at =>
                {
                    if (at.photo != null)
                    {
                        return(true);
                    }
                    if (at.doc != null)
                    {
                        return(at.doc.IsGif);
                    }
                    return(false);
                })), (Func <Attachment, PhotoOrDocument>)(a => new PhotoOrDocument()//todo: right?
                {
                    document = a.doc,
                    photo    = a.photo
                })));
                int index = list.IndexOf((PhotoOrDocument)Enumerable.FirstOrDefault <PhotoOrDocument>(list, (Func <PhotoOrDocument, bool>)(at =>
                {
                    if (at.document != null && at.document.owner_id == docHeader.Document.owner_id)
                    {
                        return(at.document.id == docHeader.Document.id);
                    }
                    return(false);
                })));
                InplaceGifViewerUC gifViewer = new InplaceGifViewerUC();
                await AnimationBehavior.ClearGifCacheAsync();

                Navigator.Current.NavigateToImageViewerPhotosOrGifs(index, list, false, false, null, null, false, (FrameworkElement)gifViewer, (Action <int>)(ind =>
                {
                    Doc document = list[ind].document;
                    if (document != null)
                    {
                        InplaceGifViewerViewModel gifViewerViewModel = new InplaceGifViewerViewModel(document, true, false, 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;
                    }
                }), (Action <int, bool>)((i, b) => {}), false);
                this._tapHandled = false;
            }
            else
            {
                Navigator.Current.NavigateToWebUri(docHeader.Document.url, true, false);
            }
        }
Example #5
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());
            }
        }