public override void Render(CellContext context, double cellWidth, double cellHeight)
        {
            // check state and parameters:
            if (BoundObject == null)
            {
                return;
            }
            var artistInfo = BoundObject as ArtistInfo;

            if (artistInfo == null)
            {
                throw new InvalidCastException("FanArtArtistColumnCell can only bind ArtistInfo objects");
            }

            var  musicBrainzID = GetArtistsMbid(artistInfo);
            bool image         = false;

            // get artist image:
            if (musicBrainzID != null && FanArtMusicBrainz.HasImage(musicBrainzID))
            {
                string imagePath = FanArtArtistImageSpec.GetPath(
                    FanArtArtistImageSpec.CreateArtistImageFileName(musicBrainzID));

                var fas = ServiceManager.Get <FanArtService> ();
                if (!Banshee.IO.File.Exists(new Hyena.SafeUri(imagePath)))
                {
                    if (!fas.IsThereActiveJob())
                    {
                        ServiceManager.DbConnection.Execute(
                            "INSERT OR REPLACE INTO ArtistImageDownloads (MusicBrainzID, Downloaded, LastAttempt) VALUES (?, ?, ?)",
                            musicBrainzID, 0, DateTime.MinValue);

                        var artistName = FanArtMusicBrainz.ArtistNameByMBID(musicBrainzID);
                        ServiceManager.DbConnection.Execute(
                            "INSERT OR REPLACE INTO ArtistMusicBrainz (ArtistName, MusicBrainzId, LastAttempt) VALUES (?, ?, ?)",
                            artistName, musicBrainzID, DateTime.MinValue);

                        fas.FetchArtistImages(true);
                    }
                }
                else
                {
                    image = RenderArtistImage(imagePath, context);
                }
            }

            if (!image)
            {
                RenderArtistText(artistInfo.DisplayName, cellWidth, context);
            }
        }
        private string GetArtistsMbid(ArtistInfo artistInfo)
        {
            string musicBrainzID = null;

            var dbAlbumArtistInfo = artistInfo as DatabaseAlbumArtistInfo;

            if (dbAlbumArtistInfo != null)
            {
                musicBrainzID = FanArtMusicBrainz.MBIDByArtistID(dbAlbumArtistInfo.DbId);
            }

            if (musicBrainzID == null)
            {
                musicBrainzID = FanArtMusicBrainz.MBIDByArtistName(artistInfo.Name);
            }

            return(musicBrainzID);
        }