Esempio n. 1
0
 public static void SerializeDB(LyricsDatabase lyricsDatabase)
 {
     if (lyricsDatabase == MyLyricsUtils.LyricsDB)
     {
         SerializeLyricDB();
     }
     else
     {
         SerializeLyricMarkedDB();
     }
 }
Esempio n. 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));
            }
        }
Esempio n. 3
0
        internal static int IsSongInLyricsDatabaseAsLRC(LyricsDatabase lyricDB, string artist, string title)
        {
            var capatalizedArtist = LyricUtil.CapatalizeString(artist);
            var capatalizedTitle  = LyricUtil.CapatalizeString(title);

            var key = CorrectKeyFormat(capatalizedArtist, capatalizedTitle);

            if (lyricDB.ContainsKey(key))
            {
                var lyricText = lyricDB[key].Lyrics;

                return(new SimpleLRC(capatalizedArtist, capatalizedTitle, lyricText).IsValid ? LRCFound : LyricFound);
            }

            return(LRCNotFound);
        }
Esempio n. 4
0
        internal static int IsSongInLyricsDatabase(LyricsDatabase lyricDB, string artist, string title)
        {
            var capatalizedArtist = LyricUtil.CapatalizeString(artist);
            var capatalizedTitle  = LyricUtil.CapatalizeString(title);

            var key = CorrectKeyFormat(capatalizedArtist, capatalizedTitle);

            if (lyricDB.ContainsKey(key))
            {
                var lyricText = lyricDB[key].Lyrics;

                return(lyricText.Equals(Mark) ? LyricMarked : LyricFound);
            }

            return(LyricNotFound);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(this, "Are you sure you want to delete the database with marked titles?", "Delete title database", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                string          path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + MyLyricsSettings.LyricsMarkedDBName;
                FileStream      fs   = new FileStream(path, FileMode.Create);
                BinaryFormatter bf   = new BinaryFormatter();
                MyLyricsSettings.LyricsMarkedDB = new LyricsDatabase();
                bf.Serialize(fs, MyLyricsSettings.LyricsMarkedDB);
                fs.Close();

                CurrentDB = MyLyricsSettings.LyricsMarkedDB;
                comboDatabase.SelectedIndex = 1;
                updateLyricsTree();
                updateInfo();
            }
        }
        private void btResetDatabase_Click(object sender, EventArgs e)
        {
            if (
                MessageBox.Show(this, "Are you sure the Lyrics database should be deleted?", "Delete Lyrics database",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                var path = Config.GetFolder(Config.Dir.Database) + "\\" + MyLyricsUtils.LyricsDBName;
                var fs   = new FileStream(path, FileMode.Create);
                var bf   = new BinaryFormatter();
                MyLyricsUtils.LyricsDB = new LyricsDatabase();
                bf.Serialize(fs, MyLyricsUtils.LyricsDB);
                fs.Close();

                CurrentLyricsDatabase       = MyLyricsUtils.LyricsDB;
                comboDatabase.SelectedIndex = 0;
                UpdateLyricsTree(false);
                UpdateInfo();
            }
        }
Esempio n. 7
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 comboDatabase_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboDatabase.SelectedIndex == 0 && currentDBIndex != 0)
     {
         resetFields();
         currentDBIndex        = 0;
         CurrentDB             = MyLyricsSettings.LyricsDB;
         btImportFiles.Enabled = true;
         btImportDirs.Enabled  = true;
         updateLyricsTree();
     }
     else if (comboDatabase.SelectedIndex == 1 && currentDBIndex != 1)
     {
         resetFields();
         currentDBIndex        = 1;
         CurrentDB             = MyLyricsSettings.LyricsMarkedDB;
         btImportFiles.Enabled = false;
         btImportDirs.Enabled  = false;
         updateLyricsTree();
     }
 }
 private void comboDatabase_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboDatabase.SelectedIndex == 0 && (_currentDbIndex != 0 || _mOnlyShowLRCs))
     {
         ResetFields();
         _currentDbIndex       = 0;
         CurrentLyricsDatabase = MyLyricsUtils.LyricsDB;
         btImportFiles.Enabled = true;
         btImportDirs.Enabled  = true;
         btImportTags.Enabled  = true;
         btExportTags.Enabled  = true;
         UpdateLyricsTree(false);
     }
     else if (comboDatabase.SelectedIndex == 1)
     {
         ResetFields();
         _currentDbIndex       = 0;
         CurrentLyricsDatabase = MyLyricsUtils.LyricsDB;
         btImportFiles.Enabled = true;
         btImportDirs.Enabled  = true;
         btImportTags.Enabled  = false;
         btExportTags.Enabled  = false;
         UpdateLyricsTree(true);
     }
     else if (comboDatabase.SelectedIndex == 2 && _currentDbIndex != 1)
     {
         ResetFields();
         _currentDbIndex       = 1;
         CurrentLyricsDatabase = MyLyricsUtils.LyricsMarkedDB;
         btImportFiles.Enabled = false;
         btImportDirs.Enabled  = false;
         btImportTags.Enabled  = false;
         btExportTags.Enabled  = false;
         UpdateLyricsTree(false);
     }
 }
        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();
        }
Esempio n. 11
0
        internal static int IsSongInLyricsMarkedDatabase(LyricsDatabase lyricMarkedDB, string artist, string title)
        {
            var key = CorrectKeyFormat(LyricUtil.CapatalizeString(artist), LyricUtil.CapatalizeString(title));

            return(lyricMarkedDB.ContainsKey(key) ? LyricMarked : LyricNotFound);
        }
Esempio n. 12
0
 public static LyricsDatabase GetOtherLyricsDatabase(LyricsDatabase currentDatabase)
 {
     return(currentDatabase.Equals(MyLyricsUtils.LyricsDB) ? MyLyricsUtils.LyricsMarkedDB : MyLyricsUtils.LyricsDB);
 }