Exemple #1
0
        private void UpdateAlbumImageArt(Task<IImageFormat<Image>> task, AlbumItem albumItem)
        {
            switch (task.Status)
            {
                case TaskStatus.RanToCompletion:
                    Dispatcher.Invoke(() =>
                    {
                        if (task.Result == null)
                            return;

                        Image coverArtImage = task.Result.GetImage();

                        if (coverArtImage == null) return;

                        string localFileName = GetCoverArtFilename(albumItem.Child);

                        if (!File.Exists(localFileName))
                            coverArtImage.Save(localFileName);

                        BitmapFrame bitmapFrame = coverArtImage.ToBitmapSource().Resize(BitmapScalingMode.HighQuality, true, (int)(_albumArtSize * ScalingFactor), (int)(_albumArtSize * ScalingFactor));
                        coverArtImage.Dispose();
                        GC.Collect();
                        albumItem.Image = bitmapFrame;
                    });
                    break;
            }
        }
Exemple #2
0
        public AlbumItemModel(AlbumItem item, int itemIndex, string currentAlbumID, string primaryAlbumID, Func<RequestContext, string> getImageUrlBase, IUser currentUser)
        {
            this.item = item;
            this.ItemIndex = itemIndex;
            this.CurrentAlbumID = currentAlbumID;
            this.PrimaryAlbumID = primaryAlbumID;
            this.GetImageUrlBase = getImageUrlBase;

            this.WasProposedToBeDeletedByCurrentUser = item.ProposedToBeDeletedBy == currentUser;
        }
Exemple #3
0
        public AlbumItem CreateFrom(IFile file, AlbumItemType itemType)
        {
            var item = new AlbumItem(
                file,
                file.Name,
                itemType,
                file.GetLastWriteTime()
            );
            foreach (var store in this.metadataStores) {
                store.LoadMetadataTo(item);
            }

            return item;
        }
Exemple #4
0
 private void UpdateAlbumImageArt(Task<BitmapFrame> task, AlbumItem albumItem)
 {
     switch (task.Status)
     {
         case TaskStatus.RanToCompletion:
             Dispatcher.Invoke(() =>
             {
                 BitmapFrame coverArtImage = task.Result;
                 if (coverArtImage == null) return;
                 albumItem.Image = coverArtImage;
             });
             break;
         case TaskStatus.Faulted:
             DownloadCoverArt(albumItem);
             break;
     }
 }
Exemple #5
0
 private AlbumItemModel ToItemModel(AlbumItem item, int itemIndex, Func<Album, string> getAlbumID, IImageRequestStrategy imageAccess)
 {
     return new AlbumItemModel(
         item, itemIndex, this.ID,
         item.PrimaryAlbum.Get(getAlbumID).Value,
         request => imageAccess.GetActionUrl(request, this.ID, item.Name),
         this.CurrentUser
     );
 }
 public ItemDetailsViewModel(string albumID, AlbumItem item, IUser currentUser)
 {
     this.AlbumID = albumID;
     this.Item = item;
     this.CurrentUser = currentUser;
 }
Exemple #7
0
 public void SaveItem(AlbumItem item)
 {
     Argument.VerifyNotNull("item", item);
     this.metadataStores.ForEach(p => p.SaveMetadata(item));
 }
 private void DownloadCoverArt(AlbumItem albumItem)
 {
     SubsonicClient.GetCoverArtAsync(albumItem.Child.CoverArt).ContinueWith(t => UpdateAlbumImageArt(t, albumItem));
 }