/// <summary>
        /// AddSong with tree parameters adds a lyric to the treeView and the lyric database
        /// </summary>
        /// <param name="artist">artist</param>
        /// <param name="title">title</param>
        /// <param name="lyrics">lyircs</param>
        /// <param name="site">site</param>
        private bool AddSong(string artist, string title, string lyrics, string site)
        {
            var item = new LyricsItem(artist, title, lyrics, site);

            if (DatabaseUtil.IsSongInLyricsDatabase(CurrentLyricsDatabase, artist, title).Equals(DatabaseUtil.LyricNotFound))
            {
                CurrentLyricsDatabase.Add(DatabaseUtil.CorrectKeyFormat(artist, title), item);
                try
                {
                    AddSong(item);
                }
                catch
                {
                    ;
                }
                treeView.Update();
                DatabaseUtil.SerializeDB(CurrentLyricsDatabase);

                if (SettingManager.GetParamAsBool(SettingManager.AutomaticWriteToMusicTag, true))
                {
                    TagReaderUtil.WriteLyrics(artist, title, lyrics);
                }

                return(true);
            }
            return(false);
        }
示例#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));
            }
        }
        /// <summary>
        /// AddSong with tree parameters adds a lyric to the treeView and the lyric database
        /// </summary>
        /// <param name="artist"></param>
        /// <param name="title"></param>
        /// <param name="lyric"></param>
        private bool AddSong(string artist, string title, string lyrics, string site)
        {
            LyricsItem item = new LyricsItem(artist, title, lyrics, site);

            if (DatabaseUtil.IsTrackInLyricsDatabase(CurrentDB, artist, title).Equals(DatabaseUtil.LYRIC_NOT_FOUND))
            {
                CurrentDB.Add(DatabaseUtil.CorrectKeyFormat(artist, title), item);
                AddSong(item);
                treeView.Update();
                DatabaseUtil.SerializeDB(CurrentDB);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
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));
            }
        }
        private void btSwitch_Click(object sender, EventArgs e)
        {
            string temp   = "";
            string artist = "";
            string title  = "";

            if (treeView.SelectedNode != null)
            {
                temp = treeView.SelectedNode.Text;

                if (treeView.SelectedNode.Parent != null)
                {
                    artist = treeView.SelectedNode.Parent.Text;
                    title  = temp;
                }
                else
                {
                    artist = temp;
                }
            }

            if (artist.Length == 0 && title.Length == 0)
            {
                MessageBox.Show("No artist or track selected");
            }
            else if (title.Length == 0)
            {
                TreeNode artistNode = treeView.SelectedNode;

                LyricsDatabase otherDatabase = null;
                if (CurrentDB.Equals(MyLyricsSettings.LyricsDB))
                {
                    otherDatabase = MyLyricsSettings.LyricsMarkedDB;
                }
                else
                {
                    otherDatabase = MyLyricsSettings.LyricsDB;
                }

                foreach (TreeNode node in artistNode.Nodes)
                {
                    string     key  = DatabaseUtil.CorrectKeyFormat(artist, node.Text);
                    LyricsItem item = CurrentDB[key];
                    CurrentDB.Remove(key);

                    if (!DatabaseUtil.IsTrackInLyricsDatabase(otherDatabase, artist, item.Title).Equals(DatabaseUtil.LYRIC_NOT_FOUND))
                    {
                        otherDatabase.Add(key, item);
                    }
                    else
                    {
                        otherDatabase[key] = item;
                    }
                }
                updateLyricsTree();
                DatabaseUtil.SerializeDBs();
            }
            else
            {
                string     key  = DatabaseUtil.CorrectKeyFormat(artist, title);
                LyricsItem item = CurrentDB[key];

                // remove song from treeview and current database
                RemoveSong(artist, title);

                // add song to other database and serialize it
                if (CurrentDB.Equals(MyLyricsSettings.LyricsDB))
                {
                    MyLyricsSettings.LyricsMarkedDB.Add(key, item);
                    DatabaseUtil.SerializeDB(MyLyricsSettings.LyricsMarkedDB);
                }
                else
                {
                    MyLyricsSettings.LyricsDB.Add(key, item);
                    DatabaseUtil.SerializeDB(MyLyricsSettings.LyricsDB);
                }
                updateLyricDatabaseStats();
            }

            treeView.Focus();
        }