Example #1
0
            public void Add(object thumbnail, string name, string infoUri, int fullSizeImageWidth, int fullSizeImageHeight, object fullSizeImageCallback, CoverType coverType)
            {
                if (!mSource.QueryContinueSearchInternal())
                {
                    //Break out of this search
                    mSource.AbortSearch();
                    return;
                }

                if (mSource.FullSizeOnly || fullSizeImageCallback == null)
                {
                    Bitmap fullSize = null;
                    if (fullSizeImageCallback != null)                     //If fullSizeImageCallback == null, then no full size image supplied, so the thumbnail is the full size image
                    {
                        //Try to get the full size image without getting the thumbnail
                        fullSize = mSource.RetrieveFullSizeImage(fullSizeImageCallback);
                    }
                    if (fullSize == null)
                    {
                        //Fall back on using the thumbnail as the full size
                        fullSize = BitmapHelpers.GetBitmap(thumbnail);
                    }
                    if (fullSize != null)
                    {
                        mDispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                        {
                            mSource.Results.Add(new AlbumArt(mSource,
                                                             name,
                                                             infoUri,
                                                             fullSize,
                                                             coverType));
                        }));
                    }
                }
                else
                {
                    Bitmap thumbnailBitmap = BitmapHelpers.GetBitmap(thumbnail);

                    if (thumbnailBitmap != null)
                    {
                        mDispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate
                        {
                            mSource.Results.Add(new AlbumArt(mSource,
                                                             thumbnailBitmap,
                                                             name,
                                                             infoUri,
                                                             fullSizeImageWidth,
                                                             fullSizeImageHeight,
                                                             fullSizeImageCallback,
                                                             coverType));
                        }));
                    }
                }

                if (!mSource.QueryContinueSearchInternal())
                {
                    //Break out of this search
                    mSource.AbortSearch();
                    return;
                }
            }