Example #1
0
 /*
  * Adds all songs by artistName to the blockTable. Full block.
  */
 public void addArtist(Artist artist)
 {
     if (artist.ArtistName == null || artist.ArtistName.Length == 0)
     {
         throw new ArgumentException("Null or zero-length artist name specified.");
     }
     else if (dict.ContainsKey(artist) && dict[artist] != null)
     {
         count = count - dict[artist].Count + 1; // remove all the songs from the count, but add 1 for the new artist block
         dict[artist] = null;
     }
     else if (!dict.ContainsKey(artist))
     {
         dict.Add(artist, null);
         count++;
     }
 }
Example #2
0
        /*
         * Adds song by artistName to the blockTable. Single block.
         */
        public void addSong(Song song)
        {
            if (song.ArtistName == null || song.SongTitle == null || song.ArtistName.Length == 0 || song.SongTitle.Length == 0)
            {
                throw new ArgumentException("Null or zero-length artist or song specified.");
            }
            else
            {
                Artist reqArtist = new Artist(song.ArtistName);
                if (dict.ContainsKey(reqArtist) && dict[reqArtist] == null) return; // artist's songs are all blocked, ignore and return

                if (!dict.ContainsKey(reqArtist))
                {
                    dict.Add(reqArtist, new HashSet<Song>());
                }
                dict[reqArtist].Add(song);
                count++;
            }
        }
Example #3
0
 /*
  * Just a shortcut to remove an old artist->add a new artist
  */
 public void updateArtist(Artist oldArtist, Artist newArtist)
 {
     removeArtist(oldArtist);
     addArtist(newArtist);
 }
Example #4
0
 /*
  * Removes song by artistName from the blockTable.
  */
 public void removeSong(Song song)
 {
     if (song.ArtistName == null || song.SongTitle == null || song.ArtistName.Length == 0 || song.SongTitle.Length == 0)
     {
         throw new ArgumentException("Null or zero-length artist or song specified.");
     }
     Artist reqArtist = new Artist(song.ArtistName);
     if (dict.ContainsKey(reqArtist))
     {
         if (dict[reqArtist] == null) return; // can't remove one song from a globally blocked artist.
         dict[reqArtist].Remove(song);
         count--;
     }
 }
Example #5
0
 /*
  * Removes artistName from the blockTable and all of its associated songs.
  */
 public void removeArtist(Artist artist)
 {
     if (artist == null || artist.ArtistName.Length == 0)
     {
         throw new ArgumentException("Null or zero-length artist name specified.");
     }
     else if(dict.ContainsKey(artist))
     {
         if (dict[artist] != null)
             count -= dict[artist].Count; // subtract the number of songs by artist
         else
             count--; // if we blocked all the songs by the artist, just subtract 1 (for the artist itself)
         dict.Remove(artist);
     }
 }
Example #6
0
 /*
  * Does the blockTable contain song by artistName?
  */
 public Boolean contains(Song song)
 {
     if (song == null || song.ArtistName == null || song.SongTitle == null)
     {
         return false;
     }
     Artist reqArtist = new Artist(song.ArtistName);
     return dict.ContainsKey(reqArtist) && (dict[reqArtist] == null || dict[reqArtist].Contains(song)); // true if the artistname is in the dict, and we either have an artist full block or the artist's dictionary object contains the song...
 }
Example #7
0
        private void removeSongButton_Click(object sender, EventArgs e)
        {
            if (blockedListBox.SelectedItems.Count == 0) return;
            while(blockedListBox.SelectedItems.Count > 0)
            {
                BlockableItemBase currSelectedItem = (BlockableItemBase)blockedListBox.SelectedItems[0];
                if (currSelectedItem.SongTitle == null)
                {
                    Artist currSelectedArtist = new Artist(currSelectedItem.ArtistName);
                    spotControl.getBlockTable().removeArtist(currSelectedArtist);
                }
                else
                {
                    spotControl.getBlockTable().removeSong((Song)currSelectedItem);
                }
                blockedListBox.Items.Remove(currSelectedItem);
                spotControl.checkCurrentSong();
            }

            MessageBox.Show(this, "Removed selected song(s) successfully.", "SpotMute - Remove");
        }