public AlbumPhoto GetPhotoByTag(string tag) { AlbumPhoto albumPhoto = null; if (!(tag == "1")) { if (!(tag == "2")) { if (!(tag == "3")) { if (tag == "4") { albumPhoto = this.Photo4; } } else { albumPhoto = this.Photo3; } } else { albumPhoto = this.Photo2; } } else { albumPhoto = this.Photo1; } return(albumPhoto); }
public void DeletePhoto(Photo photo) { Func <AlbumPhoto, bool> func; PhotosService.Current.DeletePhoto(photo.pid, this.OwnerId, (Action <BackendResult <ResponseWithId, ResultCode> >)(res => Execute.ExecuteOnUIThread((Action)(() => { if (res.ResultCode == ResultCode.Succeeded) { AlbumPhoto albumPhoto = this._albumPhotos.FirstOrDefault <AlbumPhoto>((func = (Func <AlbumPhoto, bool>)(ap => ap.Photo.pid == photo.pid))); if (albumPhoto != null) { this._albumPhotos.Remove(albumPhoto); this.RebindHeadersToAlbumPhotos(); this.PhotosCount = this.PhotosCount - 1; --this._photosGenCol.TotalCount; } EventAggregator.Current.Publish((object)new PhotoDeletedFromAlbum() { OwnerId = this.OwnerId, AlbumId = this._albumId, PhotoId = photo.pid }); this.UpdateThumbAfterPhotosMoving(); } else { GenericInfoUC.ShowBasedOnResult((int)res.ResultCode, "", null); } })))); }
private void AddPhotoToAlbumPhotos(AlbumPhoto albumPhoto, bool insertAtTheBeginning = false) { this._updatingCollection = true; if (insertAtTheBeginning) { this._albumPhotos.Insert(0, albumPhoto); } else { this._albumPhotos.Add(albumPhoto); } this._updatingCollection = false; }
private void albumPhoto_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (!(e.PropertyName == "IsSelected")) { return; } AlbumPhoto ap = sender as AlbumPhoto; if (ap == null) { return; } if (ap.IsSelected && !this._selectedPhotos.Any <AlbumPhoto>((Func <AlbumPhoto, bool>)(p => { if (p.AlbumId == ap.AlbumId) { return(p.SeqNo == ap.SeqNo); } return(false); }))) { if (this._selectedPhotos.Count == this._maxAllowedToSelect) { ap.IsSelected = false; } else { this._selectedPhotos.Add(ap); this.NotifySelectionChanged(); } } if (ap.IsSelected) { return; } AlbumPhoto albumPhoto = this._selectedPhotos.FirstOrDefault <AlbumPhoto>((Func <AlbumPhoto, bool>)(p => { if (p.AlbumId == ap.AlbumId) { return(p.SeqNo == ap.SeqNo); } return(false); })); if (albumPhoto == null) { return; } this._selectedPhotos.Remove(albumPhoto); this.NotifySelectionChanged(); }
internal void HandleEffectUpdate(string albumId, int seqNo) { if (!(this._albumId == albumId)) { return; } AlbumPhoto albumPhotoBySeqNo = this.GetAlbumPhotoBySeqNo(seqNo); if (albumPhotoBySeqNo == null) { return; } albumPhotoBySeqNo.NotifyUpdateThumbnail(); }
internal void MovePhotos(string albumId, List <long> pids, Action <bool> callback) { if (this._isBusy) { return; } this._isBusy = true; PhotosService.Current.MovePhotos(this.OwnerId, albumId, pids, (Action <BackendResult <ResponseWithId, ResultCode> >)(res => { this._isBusy = false; this.SetInProgress(false, ""); Execute.ExecuteOnUIThread((Action)(() => { EventAggregator.Current.Publish((object)new PhotosMovedToAlbum() { fromAlbumId = this._albumId, toAlbumId = albumId, photos = pids }); List <AlbumPhoto> albumPhotoList = new List <AlbumPhoto>(); foreach (long pid1 in pids) { long pid = pid1; AlbumPhoto albumPhoto = this._albumPhotos.FirstOrDefault <AlbumPhoto>((Func <AlbumPhoto, bool>)(p => p.Photo.pid == pid)); albumPhotoList.Add(albumPhoto); } foreach (AlbumPhoto albumPhoto in albumPhotoList) { this._albumPhotos.Remove(albumPhoto); this.PhotosCount = this.PhotosCount - 1; --this._photosGenCol.TotalCount; } this.RebindHeadersToAlbumPhotos(); callback(res.ResultCode == ResultCode.Succeeded); })); this._isBusy = false; this.SetInProgress(false, ""); })); }
private int IsSet(AlbumPhoto obj) { return(obj == null || obj.Photo != null && string.IsNullOrEmpty(obj.Src) ? 0 : 1); }
public void LoadData(bool refresh = true, Action callback = null) { if (this._isLoading) { return; } this._isLoading = true; if (refresh) { this._imageEditor.ResetCachedMediaLibrary(); this._photos.Clear(); this._albumPhotos.Clear(); } this.IsLoaded = false; this.SetInProgress(true, ""); ThreadPool.QueueUserWorkItem((WaitCallback)(o => { try { List <AlbumPhoto> photoHeaders = new List <AlbumPhoto>(); HashSet <long> longSet1 = new HashSet <long>(); using (MediaLibrary mediaLibrary = new MediaLibrary()) { using (PictureAlbum pictureAlbum = ((IEnumerable <PictureAlbum>)mediaLibrary.RootPictureAlbum.Albums).FirstOrDefault <PictureAlbum>((Func <PictureAlbum, bool>)(a => a.Name == this._albumId))) { this._recentlyAddedImageInd = -1; if ((pictureAlbum != null)) { int count = pictureAlbum.Pictures.Count; this._totalCount = count; int num1; for (int i = count - 1 - this._albumPhotos.Count; i >= 0; i = num1 - 1) { double width; double height; using (Picture picture = pictureAlbum.Pictures[i]) { HashSet <long> longSet2 = longSet1; DateTime date = picture.Date; long ticks1 = date.Ticks; longSet2.Add(ticks1); if (this._timestamps != null) { HashSet <long> timestamps = this._timestamps; date = picture.Date; long ticks2 = date.Ticks; if (!timestamps.Contains(ticks2)) { this._recentlyAddedImageInd = count - 1 - this._albumPhotos.Count - i; } } width = (double)picture.Width; height = (double)picture.Height; } AlbumPhoto albumPhoto = new AlbumPhoto(this._albumId, i, (Func <AlbumPhoto, bool, Stream>)((ap, preview) => this._imageEditor.GetImageStream(ap.AlbumId, ap.SeqNo, preview)), width, height); if (this._selectedPhotos.Any <AlbumPhoto>((Func <AlbumPhoto, bool>)(p => { if (p.SeqNo == i) { return(p.AlbumId == this._albumId); } return(false); }))) { albumPhoto.IsSelected = true; } albumPhoto.PropertyChanged += new PropertyChangedEventHandler(this.albumPhoto_PropertyChanged); photoHeaders.Add(albumPhoto); if (photoHeaders.Count != this._countToLoad) { num1 = i; } else { break; } } if (refresh) { this._timestamps = longSet1; } else { foreach (long num2 in longSet1) { if (!this._timestamps.Contains(num2)) { this._timestamps.Add(num2); } } } Execute.ExecuteOnUIThread((Action)(() => { foreach (AlbumPhoto albumPhoto in photoHeaders) { this.AlbumPhotos.Add(albumPhoto); } foreach (IEnumerable <AlbumPhoto> photos in photoHeaders.Partition <AlbumPhoto>(4)) { this._photos.Add(new AlbumPhotoHeaderFourInARow(photos) { SelectionOpacity = this._ownPhotoPick ? 0.0 : 1.0 }); } if (this._albumPhotos.Count == this.PhotosCount) { this.IsLoaded = true; } this.SetInProgress(false, ""); if (callback != null) { callback(); } this._isLoading = false; })); } else { this.SetInProgress(false, ""); if (callback != null) { callback(); } this._isLoading = false; } } } } catch (Exception ex) { Logger.Instance.Error("Failed to read gallery photos ", ex); } })); }