private void amazonWS_FindCoverArtDone(AmazonWebservice aws, EventArgs e)
 {
   if (FindCoverArtDone != null)
   {
     FindCoverArtDone(amazonWS, e);
   }
 }
    private void amazonWS_GetAlbumInfoProgress(AmazonWebservice aws, int progressPercent)
    {
      if (SearchMode == SearchDepthMode.Album)
      {
        GUIDialogProgress dlgProgress =
          (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);

        if (dlgProgress != null)
        {
          dlgProgress.ShowProgressBar(true);
          dlgProgress.SetPercentage(progressPercent);
          dlgProgress.Progress();
        }
      }

      else
      {
        // The GUICoverArtGrabberProgress window will manage showing cover art grabber progress
        if (FindCoverArtProgress != null)
        {
          FindCoverArtProgress(amazonWS, progressPercent);
        }
      }
    }
    public void GetAlbumCovers(string artist, string album, string strPath, int parentWindowID,
                               bool checkForCompilationAlbum)
    {
      _SelectedAlbum = null;
      IsCompilationAlbum = false;

      if (checkForCompilationAlbum)
      {
        IsCompilationAlbum = GetIsCompilationAlbum(strPath, -1);
      }

      _Artist = artist;
      _Album = album;
      _AlbumPath = strPath;
      string origAlbumName = _Album;
      string filteredAlbumFormatString = GUILocalizeStrings.Get(4518);

      if (filteredAlbumFormatString.Length == 0)
      {
        filteredAlbumFormatString = "Album title not found\r\nTrying: {0}";
      }

      _ThumbPath = GetCoverArtThumbPath(artist, album, strPath);
      amazonWS = new AmazonWebservice();
      amazonWS.MaxSearchResultItems = MAX_SEARCH_ITEMS;

      amazonWS.FindCoverArtProgress += new AmazonWebservice.FindCoverArtProgressHandler(amazonWS_GetAlbumInfoProgress);
      amazonWS.FindCoverArtDone += new AmazonWebservice.FindCoverArtDoneHandler(amazonWS_FindCoverArtDone);

      Log.Info("Cover art grabber:getting cover art for [{0}-{1}]...", _Artist, _Album);

      if (IsCompilationAlbum)
      {
        Log.Info("Cover art grabber:compilation album found", _Artist, _Album);

        amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS;
        _Artist = "";
        string filterString = string.Format("{0} = \"{1}\"", GUILocalizeStrings.Get(484), " ");
        string filter = string.Format(filteredAlbumFormatString, filterString);

        Log.Info("Cover art grabber:trying again with blank artist name...");
        InternalGetAlbumCovers(_Artist, _Album, filter);
      }

      else
      {
        InternalGetAlbumCovers(_Artist, _Album, string.Empty);
      }

      // Did we fail to find any albums?
      if (!amazonWS.HasAlbums && !amazonWS.AbortGrab)
      {
        // Check if the album title includes a disk number description that might 
        // be altering the proper album title such as: White album (Disk 2)

        string cleanAlbumName = string.Empty;

        if (StripDiskNumberFromAlbumName(_Album, ref cleanAlbumName))
        {
          amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS;

          if (AlbumNotFoundRetryingFiltered != null)
          {
            AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, cleanAlbumName);
          }

          Log.Info("Cover art grabber:[{0}-{1}] not found. Trying [{0}-{2}]...", _Artist, _Album, cleanAlbumName);

          string filter = string.Format(filteredAlbumFormatString, cleanAlbumName);
          origAlbumName = _Album;
          InternalGetAlbumCovers(_Artist, cleanAlbumName, filter);
        }

        else if (GetProperAlbumName(_Album, ref cleanAlbumName))
        {
          amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS;

          if (AlbumNotFoundRetryingFiltered != null)
          {
            AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, cleanAlbumName);
          }

          Log.Info("Cover art grabber:[{0}-{1}] not found. Trying album name without sub-title [{0}-{2}]...", _Artist,
                   _Album, cleanAlbumName);

          string filter = string.Format(filteredAlbumFormatString, cleanAlbumName);
          origAlbumName = _Album;
          InternalGetAlbumCovers(_Artist, cleanAlbumName, filter);
        }
      }

      // Still no albums?
      if (!IsCompilationAlbum && !amazonWS.HasAlbums && !amazonWS.AbortGrab)
      {
        amazonWS.MaxSearchResultItems = MAX_UNFILTERED_SEARCH_ITEMS;

        if (AlbumNotFoundRetryingFiltered != null)
        {
          AlbumNotFoundRetryingFiltered(amazonWS, origAlbumName, GUILocalizeStrings.Get(4506));
        }

        string filterString = string.Format("{0} = \"{1}\"", GUILocalizeStrings.Get(483), " ");
        string filter = string.Format(filteredAlbumFormatString, filterString);

        // Try searching by artist only to get all albums for this artist...
        Log.Info("Cover art grabber:[{0}-{1}] not found. Trying again with blank album name...", _Artist, _Album);
        InternalGetAlbumCovers(_Artist, "", filter);
      }

      // if we're searching for a single album the progress dialog will 
      // be displayed so we need to close it...
      if (SearchMode == SearchDepthMode.Album)
      {
        GUIDialogProgress dlgProgress =
          (GUIDialogProgress)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PROGRESS);
        if (dlgProgress != null)
        {
          dlgProgress.SetPercentage(100);
          dlgProgress.Progress();
          dlgProgress.Close();
        }
      }

      amazonWS.FindCoverArtProgress -= new AmazonWebservice.FindCoverArtProgressHandler(amazonWS_GetAlbumInfoProgress);
      amazonWS.FindCoverArtDone -= new AmazonWebservice.FindCoverArtDoneHandler(amazonWS_FindCoverArtDone);
    }
 private void OnAlbumNotFoundRetryingFiltered(AmazonWebservice aws, string origAlbumName, string filteredAlbumName)
 {
   lblCurrentAlbum.Label = string.Format(GrabbingAlbumNameFormatString, filteredAlbumName);
   lblFilteredSearch.Label = string.Format("{0} not found", origAlbumName);
   lblFilteredSearch.Visible = true;
   string progressText = GetCurrentProgressString(0, filteredAlbumName);
   SetCurrentProgressPercentage(0);
   SetCurrentCoverArtProgressLabel(progressText, 0);
   GUIWindowManager.Process();
 }
    private void OnFindCoverArtProgress(AmazonWebservice aws, int progressPercent)
    {
      string albumName = aws.AlbumName;

      if (albumName.Length == 0)
      {
        albumName = GUILocalizeStrings.Get(4506);
      }

      string progressText = GetCurrentProgressString(progressPercent, albumName);
      SetCurrentProgressPercentage(progressPercent);
      SetCurrentCoverArtProgressLabel(progressText, progressPercent);
      Application.DoEvents();
      GUIWindowManager.Process();
    }
 private void OnFindCoverArtDone(AmazonWebservice aws, EventArgs e)
 {
   string progressText = string.Format("{0}% -- Done", 100);
   SetCurrentCoverArtProgressLabel(progressText, 100);
   progCurrent.Percentage = 100;
   Application.DoEvents();
   GUIWindowManager.Process();
 }