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); } }
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); } }
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 void CreateOrUpdateLayout() { foreach (IVirtualizable virtualizableChild in (Collection <IVirtualizable>) this.VirtualizableChildren) { virtualizableChild.ChangeState(VirtualizableState.Unloaded); } this.VirtualizableChildren.Clear(); if (this._thumbs.Count == 0) { return; } List <Rect> layout = RectangleLayoutHelper.CreateLayout(new Size(this.Width, this.DesiredHeight), this._thumbs.Select <ThumbsItem.Thumb, Size>((Func <ThumbsItem.Thumb, Size>)(t => new Size(t.Width, t.Height))).ToList <Size>(), 4.0); layout.Max <Rect>((Func <Rect, double>)(r => r.Left + r.Width)); int index = 0; foreach (Rect rect1 in layout) { Rect rect = rect1; Thickness margin = new Thickness(rect.Left, rect.Top, 0.0, 0.0); ThumbsItem.Thumb currentThumb = this._thumbs[index]; bool blackRectOnTop = !string.IsNullOrEmpty(currentThumb.Label); bool flag = !string.IsNullOrEmpty(currentThumb.LabelLarge); VirtualizableImage virtImage = new VirtualizableImage(rect.Width, rect.Height, margin, currentThumb.GetProperSrc(rect.Width, rect.Height), new Action <VirtualizableImage>(this.Image_Tap), index.ToString(), false, !this._isMessage, Stretch.UniformToFill, (Brush)null, -1.0, blackRectOnTop, false); this.VirtualizableChildren.Add((IVirtualizable)virtImage); if (currentThumb.Video != null) { this.VirtualizableChildren.Add((IVirtualizable) new UCItem(rect.Width, margin, (Func <UserControlVirtualizable>)(() => { return((UserControlVirtualizable) new VideoNewsItemDescUC() { Width = rect.Width, Height = rect.Height, DataContext = (object)new VideoNewsItemDescViewModel(currentThumb.Video, rect.Width > 460.0) }); }), (Func <double>)(() => rect.Height), (Action <UserControlVirtualizable>)null, 0.0, false)); virtImage.Tag2 = "NotAPreview"; } else if (currentThumb.GifDoc != null) { UCItem ucItem = new UCItem(rect.Width, margin, (Func <UserControlVirtualizable>)(() => { bool isOneItem = layout.Count == 1; InplaceGifViewerViewModel gifViewerViewModel = new InplaceGifViewerViewModel(currentThumb.GifDoc, false, this._isCommentThumbItem || this._isMessage, isOneItem); if (isOneItem) { return (UserControlVirtualizable) new InplaceGifViewerUC() { Width = rect.Width, Height = rect.Height, VM = gifViewerViewModel, gifOverlayUC = { OnTap = (Action)(() => this.Image_Tap(virtImage)) } } } ; return((UserControlVirtualizable) new GifOverlayUC() { Width = rect.Width, Height = rect.Height, DataContext = (object)gifViewerViewModel, OnTap = (Action)(() => this.Image_Tap(virtImage)) }); }), (Func <double>)(() => rect.Height), (Action <UserControlVirtualizable>)null, 0.0, false); virtImage.OverlayControl = (object)ucItem; this.VirtualizableChildren.Add((IVirtualizable)ucItem); } else if (currentThumb.Album != null || currentThumb.MarketAlbum != null) { this.VirtualizableChildren.Add((IVirtualizable) new UCItem(rect.Width, margin, (Func <UserControlVirtualizable>)(() => { return((UserControlVirtualizable) new AlbumNewsItemDescUC() { Width = rect.Width, Height = rect.Height, DataContext = (object)(currentThumb.Album != null ? new AlbumNewsItemDescViewModel(currentThumb.Album, rect.Width > 460.0) : new AlbumNewsItemDescViewModel(currentThumb.MarketAlbum, rect.Width > 460.0)) }); }), (Func <double>)(() => rect.Height), (Action <UserControlVirtualizable>)null, 0.0, false)); virtImage.Tag2 = "NotAPreview"; } else if (blackRectOnTop) { if (flag) { this.VirtualizableChildren.Add((IVirtualizable) new TextItem(rect.Width - 12.0, new Thickness(rect.Left + 12.0, rect.Top + rect.Height - 69.0, 0.0, 0.0), this._thumbs[index].LabelLarge, false, 25.33, "Segoe WP", 27.0, new SolidColorBrush(Colors.White), false, null)); double width = rect.Width - 12.0; Thickness textMargin = new Thickness(rect.Left + 12.0, rect.Top + rect.Height - 37.0, 0.0, 0.0); string label = this._thumbs[index].Label; int num1 = 0; double fontSize = 20.0; string fontFamily = "Segoe WP"; double lineHeight = 22.0; SolidColorBrush foreground = new SolidColorBrush(Colors.White); double num2 = 0.6; foreground.Opacity = num2; int num3 = 0; object local = null; this.VirtualizableChildren.Add((IVirtualizable) new TextItem(width, textMargin, label, num1 != 0, fontSize, fontFamily, lineHeight, foreground, num3 != 0, (Action)local)); } else { this.VirtualizableChildren.Add((IVirtualizable) new TextItem(rect.Width - 12.0, new Thickness(rect.Left + 12.0, rect.Top + rect.Height - 37.0, 0.0, 0.0), this._thumbs[index].Label, false, 20.0, "Segoe WP", 22.0, new SolidColorBrush(Colors.White), false, null)); } virtImage.Tag2 = "NotAPreview"; } ++index; } if (this.CurrentState != VirtualizableState.Unloaded) { foreach (IVirtualizable virtualizableChild in (Collection <IVirtualizable>) this.VirtualizableChildren) { virtualizableChild.ChangeState(this.CurrentState); } } double num; if (layout.Count <= 0) { num = 0.0; } else { Rect rect = layout.Last <Rect>(); double top = rect.Top; rect = layout.Last <Rect>(); double height = rect.Height; num = top + height; } this._height = num; }
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); } }
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()); } }