public void RemoveSong(string artist, string title)
        {
            try
            {
                int artistIndex = treeView.Nodes.IndexOfKey(artist);
                int titleIndex  = treeView.Nodes[artistIndex].Nodes.IndexOfKey(title);
                treeView.Nodes[artistIndex].Nodes.RemoveAt(titleIndex);
                --m_NoOfTitles;

                // remove title from treeView
                if (treeView.Nodes[artistIndex].Nodes.Count == 0)
                {
                    treeView.Nodes.RemoveAt(artistIndex);
                    --m_NoOfArtists;
                }
            }
            catch
            {
                if (artist.Length == 0 && title.Length == 0)
                {
                    treeView.Nodes.RemoveAt(0);
                    --m_NoOfArtists;
                    treeView.Update();
                }
            }
            finally
            {
                treeView.Update();

                // remove title from database
                CurrentDB.Remove(DatabaseUtil.CorrectKeyFormat(artist, title));
                DatabaseUtil.SerializeDB(CurrentDB);
            }
        }
Пример #2
0
        public static void WriteToLyricsDatabase(LyricsDatabase lyricsDB, LyricsDatabase lyricsMarkedDB,
                                                 string capArtist, string capTitle, string lyric, string site)
        {
            if (IsSongInLyricsDatabase(lyricsDB, capArtist, capTitle).Equals(LyricNotFound))
            {
                lyricsDB.Add(CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, lyric, site));
            }

            if (IsSongInLyricsMarkedDatabase(lyricsMarkedDB, capArtist, capTitle).Equals(LyricMarked))
            {
                lyricsMarkedDB.Remove(CorrectKeyFormat(capArtist, capTitle));
            }
        }
Пример #3
0
        public static void ReplaceInLyricsDatabase(LyricsDatabase currentLyricsDB, string capArtist, string capTitle,
                                                   string lyric, string site)
        {
            var otherDatabase = GetOtherLyricsDatabase(currentLyricsDB);

            var key = CorrectKeyFormat(capArtist, capTitle);

            if (IsSongInLyricsDatabase(currentLyricsDB, capArtist, capTitle).Equals(LyricNotFound) == false)
            {
                currentLyricsDB.Remove(key);
            }

            currentLyricsDB.Add(key, new LyricsItem(capArtist, capTitle, lyric, site));

            if (IsSongInLyricsMarkedDatabase(otherDatabase, capArtist, capTitle).Equals(LyricMarked))
            {
                otherDatabase.Remove(CorrectKeyFormat(capArtist, capTitle));
            }
        }