Example #1
0
        internal void AddOrUpdateAlbum(Album createdOrUpdatedAlbum)
        {
            Func <AlbumHeader, bool> _9__1 = null;

            Execute.ExecuteOnUIThread(delegate
            {
                AlbumHeader albumHeader = this.FindByAlbumId(createdOrUpdatedAlbum.aid);
                if (albumHeader != null)
                {
                    albumHeader.Album = createdOrUpdatedAlbum;
                    albumHeader.ReadDataFromAlbumField();
                    IEnumerable <AlbumHeader> arg_5B_0 = this.EditAlbumsVM.Collection;
                    Func <AlbumHeader, bool> arg_5B_1;
                    if ((arg_5B_1 = _9__1) == null)
                    {
                        arg_5B_1 = (_9__1 = ((AlbumHeader ah) => ah.AlbumId == createdOrUpdatedAlbum.aid));
                    }
                    AlbumHeader albumHeader2 = Enumerable.FirstOrDefault <AlbumHeader>(arg_5B_0, arg_5B_1);
                    if (albumHeader2 != null)
                    {
                        albumHeader2.Album = createdOrUpdatedAlbum;
                        albumHeader2.ReadDataFromAlbumField();
                        return;
                    }
                }
                else
                {
                    AlbumHeader albumHeader3 = new AlbumHeader
                    {
                        AlbumType = AlbumType.NormalAlbum,
                        Album     = createdOrUpdatedAlbum
                    };
                    albumHeader3.ImageUri = (albumHeader3.ImageUriSmall = "https://vk.com/images/m_noalbum.png");
                    albumHeader3.ReadDataFromAlbumField();
                    this.EditAlbumsVM.Insert(albumHeader3, 0);
                    if (this.AlbumsVM.Collection.Count > 1)
                    {
                        this.AlbumsVM.Collection[1].Insert(0, albumHeader3);
                    }
                    else
                    {
                        GenericCollectionViewModel <AlbumsData, Group <AlbumHeader> > arg_130_0 = this.AlbumsVM;
                        string arg_116_0            = PhotosMainViewModel.FormatAlbumsCount(1);
                        List <AlbumHeader> expr_10E = new List <AlbumHeader>();
                        expr_10E.Add(albumHeader3);
                        arg_130_0.Insert(new Group <AlbumHeader>(arg_116_0, expr_10E, false), this.AlbumsVM.Collection.Count);
                    }
                    this.UpdateAlbums();
                    this.UpdateAlbumsCount();
                    if (!this._inAlbumCreatedHandler)
                    {
                        EventAggregator.Current.Publish(new PhotoAlbumCreated
                        {
                            Album       = createdOrUpdatedAlbum,
                            EventSource = this.GetHashCode()
                        });
                    }
                }
            });
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            AlbumHeader albumHeader = item as AlbumHeader;

            if (albumHeader != null && albumHeader.AlbumType == AlbumType.NormalAlbum)
            {
                return(this.UserAlbumTemplate);
            }
            return(this.SystemAlbumTemplate);
        }
Example #3
0
 public void Handle(PhotoAlbumDeleted message)
 {
     if (message.EventSource != this.GetHashCode())
     {
         AlbumHeader albumHeader = Enumerable.FirstOrDefault <AlbumHeader>(this.EditAlbumsVM.Collection, (AlbumHeader a) => a.AlbumId == message.aid);
         if (albumHeader != null)
         {
             this.EditAlbumsVM.Delete(albumHeader);
             this.UpdateAlbums();
         }
     }
 }
Example #4
0
 public void Handle(PhotoSetAsAlbumCover message)
 {
     this.ApplyAlbumAction(message.aid, (Action <AlbumHeader>)(a =>
     {
         AlbumHeader albumHeader1 = a;
         Photo photo1             = message.Photo;
         string str1                = photo1 != null ? photo1.src_big :  null;
         albumHeader1.ImageUri      = str1;
         AlbumHeader albumHeader2   = a;
         Photo photo2               = message.Photo;
         string str2                = photo2 != null ? photo2.src :  null;
         albumHeader2.ImageUriSmall = str2;
     }));
 }
Example #5
0
 internal void DeleteAlbumHeader(AlbumHeader album)
 {
     if (album == this.AlbumHeader1)
     {
         this.AlbumHeader1 = null;
     }
     else
     {
         if (album != this.AlbumHeader2)
         {
             return;
         }
         this.AlbumHeader2 = null;
     }
 }
Example #6
0
        private void ApplyAlbumAction(string aid, Action <AlbumHeader> action)
        {
            AlbumHeader albumHeader = Enumerable.FirstOrDefault <AlbumHeader>(this.EditAlbumsVM.Collection, (AlbumHeader ah) => ah.AlbumId == aid);

            if (albumHeader != null)
            {
                action.Invoke(albumHeader);
            }
            AlbumHeader albumHeader2 = this.FindByAlbumId(aid);

            if (albumHeader2 != null)
            {
                if (albumHeader == null || albumHeader != albumHeader2)
                {
                    action.Invoke(albumHeader2);
                }
                albumHeader2.ReadDataFromAlbumField();
                return;
            }
            this.AlbumsVM.LoadData(true, false, null, false);
        }
Example #7
0
        internal void DeleteAlbums(List <AlbumHeader> list)
        {
            PhotosService arg_41_0 = PhotosService.Current;
            Func <AlbumHeader, string> arg_25_1 = new Func <AlbumHeader, string>((ah) => { return(ah.AlbumId); });

            arg_41_0.DeleteAlbums(Enumerable.ToList <string>(Enumerable.Select <AlbumHeader, string>(list, arg_25_1)), this.IsGroup ? this.UserOrGroupId : 0L);
            using (List <AlbumHeader> .Enumerator enumerator = list.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    AlbumHeader current = enumerator.Current;
                    this.EditAlbumsVM.Delete(current);
                    EventAggregator.Current.Publish(new PhotoAlbumDeleted
                    {
                        aid         = current.AlbumId,
                        EventSource = this.GetHashCode()
                    });
                }
            }
            this.UpdateAlbums();
        }
Example #8
0
 private void ConvertToAlbumHeaders(AlbumsData data, out List <AlbumHeader> nonEditAlbums, out List <AlbumHeader> editAlbums)
 {
     nonEditAlbums = new List <AlbumHeader>();
     editAlbums    = new List <AlbumHeader>();
     if (data.allPhotos.NotNullAndHasAtLeastOneNonNullElement())
     {
         List <AlbumHeader> albumHeaderList = nonEditAlbums;
         AlbumHeader        albumHeader     = new AlbumHeader();
         albumHeader.AlbumName = PhotoResources.PhotosMainPage_AllPhotos;
         string srcBig = data.allPhotos[0].src_big;
         albumHeader.ImageUri = srcBig;
         string src = data.allPhotos[0].src;
         albumHeader.ImageUriSmall = src;
         string str1 = data.allPhotos.Count >= 2 ? data.allPhotos[1].src_big : "";
         albumHeader.ImageUri2 = str1;
         string str2 = data.allPhotos.Count >= 3 ? data.allPhotos[2].src_big : "";
         albumHeader.ImageUri3 = str2;
         int allPhotosCount = data.allPhotosCount;
         albumHeader.PhotosCount = allPhotosCount;
         int num = 0;
         albumHeader.AlbumType = (AlbumType)num;
         albumHeaderList.Add(albumHeader);
     }
     if (data.profilePhotos.NotNullAndHasAtLeastOneNonNullElement())
     {
         List <AlbumHeader> albumHeaderList = nonEditAlbums;
         AlbumHeader        albumHeader     = new AlbumHeader();
         albumHeader.AlbumName = PhotoResources.PhotosMainPage_ProfilePhotos;
         string srcBig = data.profilePhotos[0].src_big;
         albumHeader.ImageUri = srcBig;
         string src = data.profilePhotos[0].src;
         albumHeader.ImageUriSmall = src;
         string str1 = data.profilePhotos.Count >= 2 ? data.profilePhotos[1].src_big : "";
         albumHeader.ImageUri2 = str1;
         string str2 = data.profilePhotos.Count >= 3 ? data.profilePhotos[2].src_big : "";
         albumHeader.ImageUri3 = str2;
         int profilePhotosCount = data.profilePhotosCount;
         albumHeader.PhotosCount = profilePhotosCount;
         int num = 1;
         albumHeader.AlbumType = (AlbumType)num;
         albumHeaderList.Add(albumHeader);
     }
     if (data.userPhotos.NotNullAndHasAtLeastOneNonNullElement())
     {
         nonEditAlbums.Add(new AlbumHeader()
         {
             AlbumName     = string.Format(PhotoResources.PhotosMainPage_PhotosWithFormat, data.userIns.first_name),
             ImageUri      = data.userPhotos[0].src_big,
             ImageUriSmall = data.userPhotos[0].src,
             ImageUri2     = data.userPhotos.Count >= 2 ? data.userPhotos[1].src_big : "",
             ImageUri3     = data.userPhotos.Count >= 3 ? data.userPhotos[2].src_big : "",
             PhotosCount   = data.userPhotosCount,
             AlbumType     = AlbumType.PhotosWithUser
         });
     }
     if (data.wallPhotos.NotNullAndHasAtLeastOneNonNullElement())
     {
         List <AlbumHeader> albumHeaderList = nonEditAlbums;
         AlbumHeader        albumHeader     = new AlbumHeader();
         albumHeader.AlbumName = PhotoResources.PhotosMainPage_WallPhotos;
         string srcBig = data.wallPhotos[0].src_big;
         albumHeader.ImageUri = srcBig;
         string src = data.wallPhotos[0].src;
         albumHeader.ImageUriSmall = src;
         string str1 = data.wallPhotos.Count >= 2 ? data.wallPhotos[1].src_big : "";
         albumHeader.ImageUri2 = str1;
         string str2 = data.wallPhotos.Count >= 3 ? data.wallPhotos[2].src_big : "";
         albumHeader.ImageUri3 = str2;
         int wallPhotosCount = data.wallPhotosCount;
         albumHeader.PhotosCount = wallPhotosCount;
         int num = 3;
         albumHeader.AlbumType = (AlbumType)num;
         albumHeaderList.Add(albumHeader);
     }
     if (data.savedPhotos.NotNullAndHasAtLeastOneNonNullElement())
     {
         List <AlbumHeader> albumHeaderList = nonEditAlbums;
         AlbumHeader        albumHeader     = new AlbumHeader();
         albumHeader.AlbumName = PhotoResources.PhotosMainPage_SavedPhotos;
         string srcBig = data.savedPhotos[0].src_big;
         albumHeader.ImageUri = srcBig;
         string src = data.savedPhotos[0].src;
         albumHeader.ImageUriSmall = src;
         string str1 = data.savedPhotos.Count >= 2 ? data.savedPhotos[1].src_big : "";
         albumHeader.ImageUri2 = str1;
         string str2 = data.savedPhotos.Count >= 3 ? data.savedPhotos[2].src_big : "";
         albumHeader.ImageUri3 = str2;
         int savedPhotosCount = data.savedPhotosCount;
         albumHeader.PhotosCount = savedPhotosCount;
         int num = 4;
         albumHeader.AlbumType = (AlbumType)num;
         albumHeaderList.Add(albumHeader);
     }
     foreach (Album album in data.albums)
     {
         if (album.aid != this._excludeAlbumId)
         {
             editAlbums.Add(new AlbumHeader()
             {
                 AlbumName     = album.title,
                 PhotosCount   = album.size,
                 ImageUri      = album.thumb_src,
                 ImageUriSmall = album.thumb_src_small,
                 AlbumId       = album.aid,
                 AlbumType     = AlbumType.NormalAlbum,
                 Album         = album
             });
         }
     }
 }
Example #9
0
 public void Reordered(AlbumHeader item, AlbumHeader before, AlbumHeader after)
 {
     PhotosService.Current.ReorderAlbums(item.AlbumId, before != null ? before.AlbumId : "", after != null ? after.AlbumId : "", this.OwnerId, (Action <BackendResult <ResponseWithId, ResultCode> >)(res => {}));
     this.UpdateAlbums();
 }
Example #10
0
 private void Initialize()
 {
     ThreadPool.QueueUserWorkItem((WaitCallback)(o =>
     {
         try
         {
             Stopwatch stopwatch = Stopwatch.StartNew();
             List <AlbumHeader> albumHeaders = new List <AlbumHeader>();
             using (MediaLibrary mediaLibrary = new MediaLibrary())
             {
                 using (PictureAlbum rootPictureAlbum = mediaLibrary.RootPictureAlbum)
                 {
                     PictureAlbumCollection pictureAlbumCollection = rootPictureAlbum != null ? rootPictureAlbum.Albums : (PictureAlbumCollection)null;
                     if (pictureAlbumCollection != null)
                     {
                         if (pictureAlbumCollection.Count > 0)
                         {
                             using (IEnumerator <PictureAlbum> enumerator = pictureAlbumCollection.GetEnumerator())
                             {
                                 while (((IEnumerator)enumerator).MoveNext())
                                 {
                                     PictureAlbum current = enumerator.Current;
                                     if (current != null)
                                     {
                                         PictureCollection pictures = current.Pictures;
                                         if (pictures != null)
                                         {
                                             string str = current.Name ?? "";
                                             AlbumHeader albumHeader1 = new AlbumHeader();
                                             albumHeader1.AlbumId = str;
                                             albumHeader1.AlbumName = str;
                                             int count = pictures.Count;
                                             albumHeader1.PhotosCount = count;
                                             AlbumHeader albumHeader2 = albumHeader1;
                                             string albumName = albumHeader2.AlbumName;
                                             if (!(albumName == "Camera Roll"))
                                             {
                                                 if (!(albumName == "Saved Pictures"))
                                                 {
                                                     if (!(albumName == "Sample Pictures"))
                                                     {
                                                         if (albumName == "Screenshots")
                                                         {
                                                             albumHeader2.AlbumName = CommonResources.AlbumScreenshots;
                                                             albumHeader2.OrderNo = 3;
                                                         }
                                                         else
                                                         {
                                                             albumHeader2.OrderNo = int.MaxValue;
                                                         }
                                                     }
                                                     else
                                                     {
                                                         albumHeader2.AlbumName = CommonResources.AlbumSamplePictures;
                                                         albumHeader2.OrderNo = 2;
                                                     }
                                                 }
                                                 else
                                                 {
                                                     albumHeader2.AlbumName = CommonResources.AlbumSavedPictures;
                                                     albumHeader2.OrderNo = 1;
                                                 }
                                             }
                                             else
                                             {
                                                 albumHeader2.AlbumName = CommonResources.AlbumCameraRoll;
                                                 albumHeader2.OrderNo = 0;
                                             }
                                             Picture picture = ((IEnumerable <Picture>)pictures).FirstOrDefault <Picture>();
                                             if (picture != null)
                                             {
                                                 try
                                                 {
                                                     albumHeader2.ImageStream = picture.GetThumbnail();
                                                 }
                                                 catch
                                                 {
                                                 }
                                                 try
                                                 {
                                                     picture.Dispose();
                                                 }
                                                 catch
                                                 {
                                                 }
                                             }
                                             albumHeaders.Add(albumHeader2);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             stopwatch.Stop();
             Execute.ExecuteOnUIThread((Action)(() =>
             {
                 this._albums.Clear();
                 foreach (IEnumerable <AlbumHeader> source in albumHeaders.OrderBy <AlbumHeader, int>((Func <AlbumHeader, int>)(ah => ah.OrderNo)).Partition <AlbumHeader>(2))
                 {
                     List <AlbumHeader> list = source.ToList <AlbumHeader>();
                     AlbumHeaderTwoInARow albumHeaderTwoInArow = new AlbumHeaderTwoInARow()
                     {
                         AlbumHeader1 = list[0]
                     };
                     if (list.Count > 1)
                     {
                         albumHeaderTwoInArow.AlbumHeader2 = list[1];
                     }
                     this._albums.Add(albumHeaderTwoInArow);
                 }
                 this._isLoaded = true;
                 this.NotifyPropertyChanged <string>((Expression <Func <string> >)(() => this.FooterText));
                 this.NotifyPropertyChanged <Visibility>((Expression <Func <Visibility> >)(() => this.FooterTextVisibility));
             }));
         }
         catch (Exception ex)
         {
             Logger.Instance.ErrorAndSaveToIso("Failed to read gallery albums", ex);
         }
     }));
 }