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

                        using (Image coverArtImage = task.Result.Image)
                        {
                            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));

                            albumItem.Image = bitmapFrame;
                        }

                        task.Result.Dispose();

                        //GC.Collect();

                    });
                    break;
            }
        }
Exemple #2
0
        private void UpdateAlbumImageArt(Task<BitmapFrame> task, AlbumModel albumItem)
        {
            switch (task.Status)
            {
                case TaskStatus.RanToCompletion:
                    Dispatcher.Invoke(() =>
                    {
                        if (!task.IsCanceled)
                        {
                            BitmapFrame coverArtImage = task.Result;
                            if (coverArtImage == null) return;

                            albumItem.Image = coverArtImage;
                        }
                    });
                    break;
                case TaskStatus.Faulted:
                    DownloadCoverArt(albumItem);
                    break;
            }
        }