|
From: <sa...@us...> - 2007-03-09 17:26:25
|
Revision: 171
http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=171&view=rev
Author: saamand
Date: 2007-03-09 09:26:16 -0800 (Fri, 09 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/plugins/MyLyrics/LRC/Properties/AssemblyInfo.cs
trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs
trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs
trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs
trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs
trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.Designer.cs
trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs
trunk/plugins/MyLyrics/My Lyrics/MyLyricsUtil.cs
trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs
trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/Properties/AssemblyInfo.cs
Modified: trunk/plugins/MyLyrics/LRC/Properties/AssemblyInfo.cs
===================================================================
--- trunk/plugins/MyLyrics/LRC/Properties/AssemblyInfo.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/LRC/Properties/AssemblyInfo.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -29,5 +29,5 @@
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.15")]
-[assembly: AssemblyFileVersion("0.15")]
+[assembly: AssemblyVersion("0.16")]
+[assembly: AssemblyFileVersion("0.16")]
Modified: trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs
===================================================================
--- trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -26,7 +26,7 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("0.15")]
+[assembly: AssemblyVersion("0.16")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs
===================================================================
--- trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -488,10 +488,7 @@
private void SaveLyricToDatabase()
{
- using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings("Lyrics.xml", false))
- {
- xmlwriter.SetValue(LyricUtil.capatalizeString(m_artist), LyricUtil.capatalizeString(m_title), m_LyricText);
- }
+ MyLyricsSetup.LyricsDB[MyLyricsUtil.CorrectKeyFormat(LyricUtil.capatalizeString(m_artist), LyricUtil.capatalizeString(m_title))].Lyrics = m_LyricText;
}
// Stop worker thread if it is running.
Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs
===================================================================
--- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -103,7 +103,7 @@
this.tabControl.Location = new System.Drawing.Point(12, 12);
this.tabControl.Name = "tabControl";
this.tabControl.SelectedIndex = 0;
- this.tabControl.Size = new System.Drawing.Size(528, 495);
+ this.tabControl.Size = new System.Drawing.Size(528, 494);
this.tabControl.TabIndex = 1;
//
// tabPageLyricsDatabase
@@ -111,7 +111,7 @@
this.tabPageLyricsDatabase.Location = new System.Drawing.Point(4, 22);
this.tabPageLyricsDatabase.Name = "tabPageLyricsDatabase";
this.tabPageLyricsDatabase.Padding = new System.Windows.Forms.Padding(3);
- this.tabPageLyricsDatabase.Size = new System.Drawing.Size(520, 469);
+ this.tabPageLyricsDatabase.Size = new System.Drawing.Size(520, 468);
this.tabPageLyricsDatabase.TabIndex = 1;
this.tabPageLyricsDatabase.Text = "Lyrics database";
this.tabPageLyricsDatabase.UseVisualStyleBackColor = true;
@@ -123,7 +123,7 @@
this.tabPageSetup.Location = new System.Drawing.Point(4, 22);
this.tabPageSetup.Name = "tabPageSetup";
this.tabPageSetup.Padding = new System.Windows.Forms.Padding(3);
- this.tabPageSetup.Size = new System.Drawing.Size(520, 469);
+ this.tabPageSetup.Size = new System.Drawing.Size(520, 454);
this.tabPageSetup.TabIndex = 2;
this.tabPageSetup.Text = "General setup";
this.tabPageSetup.UseVisualStyleBackColor = true;
@@ -242,7 +242,7 @@
this.tabPageDatabase.Location = new System.Drawing.Point(4, 22);
this.tabPageDatabase.Name = "tabPageDatabase";
this.tabPageDatabase.Padding = new System.Windows.Forms.Padding(3);
- this.tabPageDatabase.Size = new System.Drawing.Size(520, 469);
+ this.tabPageDatabase.Size = new System.Drawing.Size(520, 454);
this.tabPageDatabase.TabIndex = 2;
this.tabPageDatabase.Text = "Search music database";
this.tabPageDatabase.UseVisualStyleBackColor = true;
@@ -663,7 +663,7 @@
//
// btSave
//
- this.btSave.Location = new System.Drawing.Point(356, 513);
+ this.btSave.Location = new System.Drawing.Point(358, 512);
this.btSave.Name = "btSave";
this.btSave.Size = new System.Drawing.Size(78, 23);
this.btSave.TabIndex = 16;
@@ -673,7 +673,7 @@
//
// btClose
//
- this.btClose.Location = new System.Drawing.Point(440, 513);
+ this.btClose.Location = new System.Drawing.Point(442, 512);
this.btClose.Name = "btClose";
this.btClose.Size = new System.Drawing.Size(78, 23);
this.btClose.TabIndex = 99;
@@ -692,7 +692,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(539, 542);
+ this.ClientSize = new System.Drawing.Size(538, 543);
this.ControlBox = false;
this.Controls.Add(this.btClose);
this.Controls.Add(this.tabControl);
Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs
===================================================================
--- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -94,7 +94,10 @@
// worker thread
Thread m_LyricControllerThread;
- MusicDatabase dbs;
+ internal static LyricsDatabase LyricsDB = null;
+ internal static LyricsDatabase LyricsMarkedDB = null;
+ internal const string LyricsDBName = "LyricsDatabaseV2.db";
+ internal const string LyricsMarkedDBName = "LyricsMarkedDatabaseV2.db";
// Timer variables
int hour = 0;
@@ -169,6 +172,77 @@
MessageBox.Show("Something has gone wrong when reading Mediaportal.xml");
}
}
+
+ string path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + LyricsDBName;
+ FileInfo fileInfo = new FileInfo(path);
+
+ if (fileInfo.Exists == false)
+ {
+ MessageBox.Show("Serialize file - " + Environment.CurrentDirectory);
+
+ if (MessageBox.Show(this, "Your database will have to be upgraded to work with this version\r\nUpgrade now?", "Upgrade lyricsdatabase", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
+ {
+ ConvertFromXMLtoLyricsDatabase convertFromXMLtoLyricsDatabase = new ConvertFromXMLtoLyricsDatabase();
+ LyricsDB = convertFromXMLtoLyricsDatabase.Convert();
+
+ BinaryFormatter b = new BinaryFormatter();
+ Stream s = File.Open(path, FileMode.CreateNew, FileAccess.ReadWrite);
+ b.Serialize(s, LyricsDB);
+ s.Close();
+
+
+
+
+
+ //// Create file to save the database to
+ //FileStream fs = new FileStream(path, FileMode.Create);
+
+ //// Create a BinaryFormatter object to perform the serialization
+ //BinaryFormatter bf = new BinaryFormatter();
+
+ //// Use the BinaryFormatter object to serialize the database to the file
+ //bf.Serialize(fs, LyricsDB);
+
+ //// Create likewise a database for the remainingLyrics
+ //path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + LyricsMarkedDBName;
+ //fs = new FileStream(path, FileMode.Create);
+ //LyricsMarkedDB = new LyricsDatabase();
+ //bf.Serialize(fs, LyricsMarkedDB);
+
+ //// Close the file
+ //fs.Close();
+ }
+ }
+ else
+ {
+ path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName);
+ BinaryFormatter bf = new BinaryFormatter();
+ Stream s = File.Open(path, FileMode.Open, FileAccess.Read);
+ LyricsDB = (LyricsDatabase)bf.Deserialize(s, null);
+ s.Close();
+
+ // Open database to read data from
+ FileStream fs = new FileStream(path, FileMode.Open);
+
+ // Create a BinaryFormatter object to perform the deserialization
+ //BinaryFormatter bf = new BinaryFormatter();
+
+ // Use the BinaryFormatter object to deserialize the database
+ LyricsDB = new LyricsDatabase();
+ LyricsDB = (LyricsDatabase)bf.Deserialize(fs);
+
+ // Deserialize LyricsRemainingDatabase
+ path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + LyricsMarkedDBName;
+ fs = new FileStream(path, FileMode.Open);
+ LyricsMarkedDB = new LyricsDatabase();
+ LyricsMarkedDB = (LyricsDatabase)bf.Deserialize(fs);
+
+ // Close the file
+ fs.Close();
+ }
+
+ MyLyricsSetup_LyricsLibrary.CurrentDB = LyricsDB;
+ lyricUC.updateLyricsTree();
}
// Stop worker thread if it is running.
@@ -356,17 +430,15 @@
string capArtist = LyricUtil.capatalizeString(m_artist);
string capTitle = LyricUtil.capatalizeString(m_track);
- using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings("Lyrics.xml", false))
+
+ if (MyLyricsUtil.isTrackInLyricsDatabase(capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_NOT_FOUND))
{
- xmlwriter.SetValue(capArtist, capTitle, m_LyricText);
+ LyricsDB.Add(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, m_LyricText, site));
}
if (MyLyricsUtil.isTrackInLyricsMarkedDatabase(capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_MARKED))
{
- using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings("LyricsToFetch.xml", false))
- {
- xmlwriter.RemoveEntry(capArtist, capTitle);
- }
+ LyricsMarkedDB.Remove(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle));
}
StreamReader sr = File.OpenText(logFullFileName);
@@ -392,12 +464,9 @@
string capArtist = LyricUtil.capatalizeString(artist);
string capTitle = LyricUtil.capatalizeString(title);
- if (m_MarkSongsWhenNoLyricFound)
+ if (m_MarkSongsWhenNoLyricFound && MyLyricsUtil.isTrackInLyricsMarkedDatabase(capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_NOT_FOUND))
{
- using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings("LyricsToFetch.xml", false))
- {
- xmlwriter.SetValue(capArtist, capTitle, MyLyricsUtil.MARK);
- }
+ LyricsMarkedDB.Add(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, MyLyricsUtil.MARK, ""));
}
m_SongsWithMark += 1;
@@ -444,6 +513,25 @@
btImportAll.Enabled = true;
btCancel.Enabled = false;
isSearching(false);
+
+ if (LyricsDB != null)
+ {
+ string path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + LyricsDBName;
+ FileStream fs = new FileStream(path, FileMode.Create);
+ BinaryFormatter bf = new BinaryFormatter();
+ bf.Serialize(fs, LyricsDB);
+ fs.Close();
+ }
+
+ if (LyricsMarkedDB != null)
+ {
+ string path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + LyricsMarkedDBName;
+ FileStream fs = new FileStream(path, FileMode.Create);
+ BinaryFormatter bf = new BinaryFormatter();
+ bf.Serialize(fs, LyricsMarkedDB);
+ fs.Close();
+ }
+
lyricUC.updateLyricsTree();
}
@@ -579,50 +667,18 @@
}
else
{
- XmlTextReader tr = null;
- try
+ foreach (KeyValuePair<string, LyricsItem> kvp in LyricsMarkedDB)
{
- tr = new XmlTextReader("LyricsToFetch.xml");
-
- string currentArtist = "";
- string currentTitle = "";
- while (tr.Read())
+ if (++m_SongsNotKnown > m_Limit)
{
- switch (tr.Name)
- {
- case "section":
- if (tr.AttributeCount == 1)
- {
- currentArtist = tr.GetAttribute(0);
- }
- break;
- case "entry":
- if (tr.AttributeCount == 1)
- {
- currentTitle = tr.GetAttribute(0);
- string currentLyrics = tr.Value;
-
- if (++m_SongsNotKnown > m_Limit)
- {
- bgWorkerSearch.ReportProgress(-1);
- goto startSearch;
- }
-
- string[] lyricId = new string[2] { currentArtist, currentTitle };
- lyricConfigInfosQueue.Enqueue(lyricId);
- }
- break;
- }
-
+ bgWorkerSearch.ReportProgress(-1);
+ goto startSearch;
}
+ string[] lyricId = new string[2] { kvp.Value.Artist, kvp.Value.Title };
+ lyricConfigInfosQueue.Enqueue(lyricId);
+ }
- }
- catch { ;}
- finally
- {
- tr.Close();
- }
- //m_SongsToSearch = lyricConfigInfosQueue.Count;
+ m_SongsToSearch = lyricConfigInfosQueue.Count;
//bgWorkerSearch.ReportProgress(songNotKnown);
}
Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.Designer.cs
===================================================================
--- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.Designer.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.Designer.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -15,14 +15,12 @@
private void InitializeComponent()
{
this.btSave = new MediaPortal.UserInterface.Controls.MPButton();
- this.lbTitle = new MediaPortal.UserInterface.Controls.MPLabel();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.btDelete = new System.Windows.Forms.Button();
this.btAdd = new System.Windows.Forms.Button();
this.gbLibrary = new MediaPortal.UserInterface.Controls.MPGroupBox();
this.comboDatabase = new MediaPortal.UserInterface.Controls.MPComboBox();
this.lbDatabase = new MediaPortal.UserInterface.Controls.MPLabel();
- this.lbTestSecondsLeft = new System.Windows.Forms.Label();
this.btImportLRC = new MediaPortal.UserInterface.Controls.MPButton();
this.lbSongs2 = new MediaPortal.UserInterface.Controls.MPLabel();
this.tbLyrics = new MediaPortal.UserInterface.Controls.MPTextBox();
@@ -36,6 +34,9 @@
this.btResetDatabase = new System.Windows.Forms.Button();
this.lbResetDatabase = new MediaPortal.UserInterface.Controls.MPLabel();
this.openFileDialog2 = new System.Windows.Forms.OpenFileDialog();
+ this.lbTestSecondsLeft = new System.Windows.Forms.Label();
+ this.lbTitle = new MediaPortal.UserInterface.Controls.MPLabel();
+ this.lbSource = new MediaPortal.UserInterface.Controls.MPLabel();
this.gbLibrary.SuspendLayout();
this.gbResetDatabase.SuspendLayout();
this.SuspendLayout();
@@ -51,16 +52,6 @@
this.btSave.UseVisualStyleBackColor = true;
this.btSave.Click += new System.EventHandler(this.btSave_Click);
//
- // lbTitle
- //
- this.lbTitle.AutoSize = true;
- this.lbTitle.Location = new System.Drawing.Point(215, 66);
- this.lbTitle.MaximumSize = new System.Drawing.Size(275, 13);
- this.lbTitle.MinimumSize = new System.Drawing.Size(275, 13);
- this.lbTitle.Name = "lbTitle";
- this.lbTitle.Size = new System.Drawing.Size(275, 13);
- this.lbTitle.TabIndex = 4;
- //
// openFileDialog1
//
this.openFileDialog1.FileName = "ARTIST - TITLE.txt";
@@ -91,6 +82,7 @@
//
// gbLibrary
//
+ this.gbLibrary.Controls.Add(this.lbSource);
this.gbLibrary.Controls.Add(this.comboDatabase);
this.gbLibrary.Controls.Add(this.lbDatabase);
this.gbLibrary.Controls.Add(this.lbTestSecondsLeft);
@@ -121,7 +113,7 @@
this.comboDatabase.FormattingEnabled = true;
this.comboDatabase.Items.AddRange(new object[] {
"Lyrics database",
- "LyricsToFetct database"});
+ "Marked database"});
this.comboDatabase.Location = new System.Drawing.Point(85, 15);
this.comboDatabase.Name = "comboDatabase";
this.comboDatabase.Size = new System.Drawing.Size(144, 21);
@@ -136,16 +128,6 @@
this.lbDatabase.TabIndex = 26;
this.lbDatabase.Text = "Database:";
//
- // lbTestSecondsLeft
- //
- this.lbTestSecondsLeft.AutoSize = true;
- this.lbTestSecondsLeft.Location = new System.Drawing.Point(215, 335);
- this.lbTestSecondsLeft.Name = "lbTestSecondsLeft";
- this.lbTestSecondsLeft.Size = new System.Drawing.Size(93, 13);
- this.lbTestSecondsLeft.TabIndex = 25;
- this.lbTestSecondsLeft.Text = "SecondsLeftLabel";
- this.lbTestSecondsLeft.Visible = false;
- //
// btImportLRC
//
this.btImportLRC.Location = new System.Drawing.Point(95, 330);
@@ -158,7 +140,7 @@
//
// lbSongs2
//
- this.lbSongs2.Location = new System.Drawing.Point(82, 59);
+ this.lbSongs2.Location = new System.Drawing.Point(82, 65);
this.lbSongs2.Name = "lbSongs2";
this.lbSongs2.Size = new System.Drawing.Size(65, 15);
this.lbSongs2.TabIndex = 23;
@@ -179,7 +161,7 @@
//
// lbSongs
//
- this.lbSongs.Location = new System.Drawing.Point(11, 59);
+ this.lbSongs.Location = new System.Drawing.Point(11, 65);
this.lbSongs.Name = "lbSongs";
this.lbSongs.Size = new System.Drawing.Size(60, 15);
this.lbSongs.TabIndex = 22;
@@ -197,7 +179,7 @@
//
// lbArtists2
//
- this.lbArtists2.Location = new System.Drawing.Point(82, 44);
+ this.lbArtists2.Location = new System.Drawing.Point(82, 50);
this.lbArtists2.Name = "lbArtists2";
this.lbArtists2.Size = new System.Drawing.Size(65, 15);
this.lbArtists2.TabIndex = 21;
@@ -205,7 +187,7 @@
//
// lbArtists
//
- this.lbArtists.Location = new System.Drawing.Point(11, 44);
+ this.lbArtists.Location = new System.Drawing.Point(11, 50);
this.lbArtists.Name = "lbArtists";
this.lbArtists.Size = new System.Drawing.Size(60, 15);
this.lbArtists.TabIndex = 20;
@@ -238,7 +220,7 @@
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(181, 23);
this.button1.TabIndex = 11;
- this.button1.Text = "Reset LyricsToFetch database";
+ this.button1.Text = "Reset marked database";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
@@ -258,8 +240,8 @@
this.lbResetDatabase.Name = "lbResetDatabase";
this.lbResetDatabase.Size = new System.Drawing.Size(282, 41);
this.lbResetDatabase.TabIndex = 9;
- this.lbResetDatabase.Text = "Reset the \"Lyrics\" and/or \"LyricsToFetch\" database.\r\n\r\nAll data in each database" +
- " that is reset is lost for ever";
+ this.lbResetDatabase.Text = "Reset the \"Lyrics\" and/or \"marked\" database.\r\n\r\nAll data in each database that is" +
+ " reset is lost for ever";
//
// openFileDialog2
//
@@ -268,6 +250,36 @@
this.openFileDialog2.Multiselect = true;
this.openFileDialog2.RestoreDirectory = true;
//
+ // lbTestSecondsLeft
+ //
+ this.lbTestSecondsLeft.AutoSize = true;
+ this.lbTestSecondsLeft.Location = new System.Drawing.Point(215, 335);
+ this.lbTestSecondsLeft.Name = "lbTestSecondsLeft";
+ this.lbTestSecondsLeft.Size = new System.Drawing.Size(93, 13);
+ this.lbTestSecondsLeft.TabIndex = 25;
+ this.lbTestSecondsLeft.Text = "SecondsLeftLabel";
+ this.lbTestSecondsLeft.Visible = false;
+ //
+ // lbTitle
+ //
+ this.lbTitle.AutoSize = true;
+ this.lbTitle.Location = new System.Drawing.Point(221, 53);
+ this.lbTitle.MaximumSize = new System.Drawing.Size(290, 26);
+ this.lbTitle.MinimumSize = new System.Drawing.Size(290, 26);
+ this.lbTitle.Name = "lbTitle";
+ this.lbTitle.Size = new System.Drawing.Size(290, 26);
+ this.lbTitle.TabIndex = 4;
+ this.lbTitle.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
+ //
+ // lbSource
+ //
+ this.lbSource.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.lbSource.Location = new System.Drawing.Point(357, 297);
+ this.lbSource.Name = "lbSource";
+ this.lbSource.Size = new System.Drawing.Size(142, 15);
+ this.lbSource.TabIndex = 28;
+ this.lbSource.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+ //
// MyLyricsSetup_LyricsLibrary
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -275,7 +287,7 @@
this.Controls.Add(this.gbResetDatabase);
this.Controls.Add(this.gbLibrary);
this.Name = "MyLyricsSetup_LyricsLibrary";
- this.Size = new System.Drawing.Size(525, 515);
+ this.Size = new System.Drawing.Size(525, 456);
this.gbLibrary.ResumeLayout(false);
this.gbLibrary.PerformLayout();
this.gbResetDatabase.ResumeLayout(false);
@@ -285,7 +297,6 @@
#endregion
- private MediaPortal.UserInterface.Controls.MPLabel lbTitle;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private MediaPortal.UserInterface.Controls.MPGroupBox gbLibrary;
private MediaPortal.UserInterface.Controls.MPTextBox tbLyrics;
@@ -301,11 +312,13 @@
internal MediaPortal.UserInterface.Controls.MPButton btImportSingle;
internal MediaPortal.UserInterface.Controls.MPButton btImportLRC;
private System.Windows.Forms.OpenFileDialog openFileDialog2;
- private System.Windows.Forms.Label lbTestSecondsLeft;
- private MediaPortal.UserInterface.Controls.MPComboBox comboDatabase;
private MediaPortal.UserInterface.Controls.MPLabel lbDatabase;
internal System.Windows.Forms.Button button1;
internal System.Windows.Forms.Button btResetDatabase;
private MediaPortal.UserInterface.Controls.MPLabel lbResetDatabase;
+ private MediaPortal.UserInterface.Controls.MPComboBox comboDatabase;
+ private System.Windows.Forms.Label lbTestSecondsLeft;
+ private MediaPortal.UserInterface.Controls.MPLabel lbTitle;
+ private MediaPortal.UserInterface.Controls.MPLabel lbSource;
}
}
Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs
===================================================================
--- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -5,12 +5,13 @@
using System.Data;
using System.Text;
using System.Windows.Forms;
-using System.Xml;
using System.IO;
using System.Collections;
using System.Threading;
using System.Text.RegularExpressions;
using System.Diagnostics;
+using System.Runtime.Serialization;
+using System.Runtime.Serialization.Formatters.Binary;
using MediaPortal.GUI.Library;
using MediaPortal.Dialogs;
@@ -42,61 +43,34 @@
string nextLineToShow;
int lineCounter;
const int SHIFT_WHEN_HIT = 15;
- string currentDatabase = "";
+ internal static LyricsDatabase CurrentDB;
public MyLyricsSetup_LyricsLibrary(Form form)
{
this.m_Form = form;
InitializeComponent();
- currentDatabase = "Lyrics.xml";
comboDatabase.SelectedIndex = 0;
updateLyricsTree();
}
internal void updateLyricsTree()
{
- //if file is not found, create a new xml file
- if (!System.IO.File.Exists("Lyrics.xml"))
+ if (CurrentDB == null)
{
- MyLyricsUtil.createLyricDatabase();
+ return;
}
- if (!System.IO.File.Exists("LyricsToFetch.xml"))
- {
- MyLyricsUtil.createLyricToFetchDatabase();
- }
- // catch error when treeView suddenly is disposed due to application shutdown
try
{
treeView.Nodes.Clear();
m_NoOfArtists = 0;
m_NoOfTitles = 0;
- XmlTextReader tr = new XmlTextReader(currentDatabase);
-
- string currentArtist = "";
- string currentTitle = "";
- while (tr.Read())
+ foreach (KeyValuePair<string, LyricsItem> kvp in CurrentDB)
{
-
- switch (tr.Name)
- {
- case "section":
- if (tr.AttributeCount == 1)
- {
- currentArtist = tr.GetAttribute(0);
- }
- break;
- case "entry":
- if (tr.AttributeCount == 1)
- {
- currentTitle = tr.GetAttribute(0);
- AddSong(currentArtist, currentTitle);
- }
- break;
- }
+ AddSong(kvp.Value);
}
- tr.Close();
+
treeView.Sort();
updateLyricDatabaseStats();
}
@@ -111,40 +85,16 @@
private ArrayList getTitlesByArtist(string artist)
{
- XmlTextReader tr = new XmlTextReader(currentDatabase);
ArrayList titles = new ArrayList();
- while (tr.Read())
+ foreach (KeyValuePair<string, LyricsItem> kvp in CurrentDB)
{
- switch (tr.Name)
+ if (kvp.Value.Artist.Equals(artist))
{
- case "section":
- if (tr.AttributeCount == 1 && tr.GetAttribute(0).Equals(artist))
- {
- while (tr.Read())
- {
- if (tr.Name.Equals("entry"))
- {
- if (tr.AttributeCount == 1)
- {
- titles.Add(tr.GetAttribute(0));
- }
- }
- else if (tr.Name.Equals("section"))
- {
- tr.Close();
- return titles;
- }
- }
- }
- break;
-
- default:
- break;
+ titles.Add(kvp.Value.Title);
}
}
- tr.Close();
- return null;
+ return titles;
}
/// <summary>
@@ -152,10 +102,10 @@
/// </summary>
/// <param name="artist"></param>
/// <param name="title"></param>
- private void AddSong(string artist, string title)
+ private void AddSong(LyricsItem item)
{
- artist = LyricUtil.capatalizeString(artist);
- title = LyricUtil.capatalizeString(title);
+ string artist = LyricUtil.capatalizeString(item.Artist);
+ string title = LyricUtil.capatalizeString(item.Title);
// add artist, if it doesn't exists
if (!treeView.Nodes.ContainsKey(artist))
@@ -169,6 +119,7 @@
if (!treeView.Nodes[artistIndex].Nodes.ContainsKey(title))
{
treeView.Nodes[artistIndex].Nodes.Add(title, title);
+ treeView.Nodes[artistIndex].Nodes[treeView.Nodes[artistIndex].Nodes.Count - 1].Tag = item;
++m_NoOfTitles;
}
treeView.Update();
@@ -180,14 +131,10 @@
/// <param name="artist"></param>
/// <param name="title"></param>
/// <param name="lyric"></param>
- private void AddSong(string artist, string title, string lyric)
+ private void AddSong(string artist, string title, string lyrics)
{
- using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(currentDatabase, false))
- {
- xmlwriter.SetValue(artist, title, lyric);
- }
-
- AddSong(artist, title);
+ LyricsItem item = new LyricsItem(artist, title, lyrics, "MP config");
+ AddSong(item);
}
private void RemoveArtist(string artist)
@@ -206,11 +153,8 @@
treeView.Nodes[artistIndex].Nodes.RemoveAt(titleIndex);
--m_NoOfTitles;
- // remove title from xml-file
- using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(currentDatabase, false))
- {
- xmlwriter.RemoveEntry(artist, title);
- }
+ // remove title from database
+ CurrentDB.Remove(MyLyricsUtil.CorrectKeyFormat(artist, title));
// remove title from treeView
if (treeView.Nodes[artistIndex].Nodes.Count == 0)
@@ -233,13 +177,9 @@
m_CurrentArtist = artist;
m_CurrentTitle = LyricUtil.capatalizeString(title);
- string lyricText = "";
- using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(currentDatabase, false))
- {
- lyricText = xmlreader.GetValueAsString(m_CurrentArtist, m_CurrentTitle, "");
- }
+ string lyricsText = (string)CurrentDB[MyLyricsUtil.CorrectKeyFormat(artist, title)].Lyrics;
- LRC.SimpleLRC lrc = new LRC.SimpleLRC(artist, title, lyricText);
+ LRC.SimpleLRC lrc = new LRC.SimpleLRC(artist, title, lyricsText);
if (lrc.IsValid)
{
return true;
@@ -259,6 +199,7 @@
m_CurrentTitle = "";
tbLyrics.Text = "";
lbTitle.Text = "";
+ lbSource.Text = "";
tbLyrics.Enabled = false;
@@ -273,19 +214,17 @@
m_CurrentArtist = LyricUtil.capatalizeString(artist);
m_CurrentTitle = LyricUtil.capatalizeString(title);
- string lyricText = "";
- using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings(currentDatabase, false))
- {
- lyricText = xmlreader.GetValueAsString(m_CurrentArtist, m_CurrentTitle, "");
- }
+ LyricsItem item = CurrentDB[MyLyricsUtil.CorrectKeyFormat(m_CurrentArtist, m_CurrentTitle)];
+ string lyricsText = item.Lyrics;
- lyricText = LyricsEngine.LyricUtil.ReturnEnvironmentNewLine(lyricText);
+ lyricsText = LyricsEngine.LyricUtil.ReturnEnvironmentNewLine(lyricsText);
- m_OriginalLyric = lyricText;
+ m_OriginalLyric = lyricsText;
tbLyrics.Text = m_OriginalLyric;
tbLyrics.Enabled = true;
- lbTitle.Text = m_CurrentArtist + " - " + m_CurrentTitle;
+ lbTitle.Text = "\"" + m_CurrentArtist + " - " + m_CurrentTitle + "\"";
+ lbSource.Text = "(" + item.Source + ")";
}
}
// Selected an artist
@@ -327,11 +266,8 @@
private void btSave_Click(object sender, EventArgs e)
{
- using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(currentDatabase, false))
- {
- xmlwriter.SetValue(LyricUtil.capatalizeString(m_CurrentArtist), LyricUtil.capatalizeString(m_CurrentTitle), tbLyrics.Text);
- btSave.Enabled = false;
- }
+ CurrentDB[MyLyricsUtil.CorrectKeyFormat(LyricUtil.capatalizeString(m_CurrentArtist), LyricUtil.capatalizeString(m_CurrentTitle))].Lyrics = tbLyrics.Text;
+ btSave.Enabled = false;
}
private void tbLyrics_KeyUp(object sender, KeyEventArgs e)
@@ -480,43 +416,6 @@
{
if (MessageBox.Show(this, "Are you sure the lyrics database should be upgraded?", "Upgrade lyrics database", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
- StreamReader freader = File.OpenText("Lyrics.xml");
- StreamWriter fwriter = File.CreateText("LyricsTemp.xml");
-
- string text_line;
- while ((text_line = freader.ReadLine()) != null)
- {
- string strStart = "entry name=";
- string strFinish = ">";
-
- int indexStart = text_line.IndexOf(strStart);
- int indexFinish = text_line.IndexOf(strFinish);
-
- // if both strings are found, you have a line holding title of track
-
- if (indexStart != -1 && indexFinish != -1 && ((char)(text_line[indexFinish - 2])).Equals(' '))
- {
- string text_newline =
- text_line.Substring(0, indexFinish - 2) + text_line.Substring(indexFinish - 1);
- text_line = text_newline;
- }
-
- // write to output file
- fwriter.WriteLine(text_line);
- }
-
- // must explicitly close the readers
- freader.Close();
- fwriter.Close();
-
- FileInfo fi = new FileInfo("Lyrics.xml");
- fi.Delete();
-
- fi = new FileInfo("LyricsTemp.xml");
- fi.MoveTo("Lyrics.xml");
- fi = new FileInfo("LyricsTemp.xml");
- fi.Delete();
-
updateLyricsTree();
}
}
@@ -626,12 +525,12 @@
{
if (comboDatabase.SelectedIndex == 0)
{
- currentDatabase = "Lyrics.xml";
+ CurrentDB = MyLyricsSetup.LyricsDB;
updateLyricsTree();
}
else
{
- currentDatabase = "LyricsToFetch.xml";
+ CurrentDB = MyLyricsSetup.LyricsMarkedDB;
updateLyricsTree();
}
}
@@ -640,8 +539,13 @@
{
if (MessageBox.Show(this, "Are you sure the Lyrics database should be deleted?", "Delete Lyrics database", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
- MyLyricsUtil.createLyricDatabase();
- currentDatabase = "Lyrics.xml";
+ string path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + MyLyricsSetup.LyricsDBName;
+ FileStream fs = new FileStream(path, FileMode.Create);
+ BinaryFormatter bf = new BinaryFormatter();
+ bf.Serialize(fs, new LyricsDatabase());
+ fs.Close();
+
+ CurrentDB = MyLyricsSetup.LyricsDB;
comboDatabase.SelectedIndex = 0;
updateLyricsTree();
updateInfo();
@@ -651,10 +555,15 @@
private void button1_Click(object sender, EventArgs e)
{
- if (MessageBox.Show(this, "Are you sure the LyricsToFetch database should be deleted?", "Delete LyricsToFetch database", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
+ 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)
{
- MyLyricsUtil.createLyricToFetchDatabase();
- currentDatabase = "LyricsToFetch.xml";
+ string path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + MyLyricsSetup.LyricsMarkedDBName;
+ FileStream fs = new FileStream(path, FileMode.Create);
+ BinaryFormatter bf = new BinaryFormatter();
+ bf.Serialize(fs, new LyricsDatabase());
+ fs.Close();
+
+ CurrentDB = MyLyricsSetup.LyricsDB;
comboDatabase.SelectedIndex = 1;
updateLyricsTree();
updateInfo();
Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsUtil.cs
===================================================================
--- trunk/plugins/MyLyrics/My Lyrics/MyLyricsUtil.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsUtil.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
-using System.Xml;
using LyricsEngine;
@@ -20,19 +19,14 @@
string lyricText = "";
try
{
- using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("Lyrics.xml", false))
- {
- string capatalizedArtist = LyricUtil.capatalizeString(artist);
- string capatalizedTitle = LyricUtil.capatalizeString(title);
- lyricText = xmlreader.GetValue(capatalizedArtist, capatalizedTitle);
- }
+ string capatalizedArtist = LyricUtil.capatalizeString(artist);
+ string capatalizedTitle = LyricUtil.capatalizeString(title);
+
+ lyricText = MyLyricsSetup.LyricsDB[CorrectKeyFormat(capatalizedArtist, capatalizedTitle)].Lyrics;
+
}
- catch (System.Xml.XPath.XPathException XPathExp)
+ catch
{
- //Catch the XPathException and write it to the Visual Studio .NET output window.
- System.Diagnostics.Debug.WriteLine("XPathException:");
- System.Diagnostics.Debug.WriteLine("***************");
- System.Diagnostics.Debug.WriteLine(XPathExp.ToString());
return LYRIC_NOT_FOUND;
}
if (lyricText.Equals(""))
@@ -44,55 +38,38 @@
internal static int isTrackInLyricsMarkedDatabase(string artist, string title)
{
- string lyricText = "";
+ string lyricsText = "";
try
{
- using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("LyricsToFetch.xml", false))
- {
- string capatalizedArtist = LyricUtil.capatalizeString(artist);
- string capatalizedTitle = LyricUtil.capatalizeString(title);
- lyricText = xmlreader.GetValue(capatalizedArtist, capatalizedTitle);
- }
+ lyricsText = MyLyricsSetup.LyricsMarkedDB[MyLyricsUtil.CorrectKeyFormat(LyricUtil.capatalizeString(artist), LyricUtil.capatalizeString(title))].Lyrics;
}
- catch{;}
- if (lyricText.Equals(MyLyricsUtil.MARK))
+ catch{
+ return LYRIC_NOT_FOUND;
+ }
+ if (lyricsText.Equals(MyLyricsUtil.MARK))
return LYRIC_MARKED;
- return LYRIC_NOT_FOUND;
+ else
+ return LYRIC_NOT_FOUND;
}
- internal static void createLyricDatabase()
- {
- XmlTextWriter xmlWriter = new XmlTextWriter("Lyrics.xml", System.Text.Encoding.UTF8);
- xmlWriter.Formatting = Formatting.Indented;
- xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
- xmlWriter.WriteStartElement("Lyrics");
- xmlWriter.Close();
- }
- internal static void createLyricToFetchDatabase()
- {
- XmlTextWriter xmlWriter = new XmlTextWriter("LyricsToFetch.xml", System.Text.Encoding.UTF8);
- xmlWriter.Formatting = Formatting.Indented;
- xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
- xmlWriter.WriteStartElement("Lyrics");
- xmlWriter.Close();
- }
-
public static string LookUpLyricInDatabase(string artist, string title)
{
- string lyricText;
-
- using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("Lyrics.xml", false))
+ string lyricText = "";
+ try
{
- lyricText = xmlreader.GetValueAsString(artist, title, "");
- if (lyricText.Equals(""))
- {
- lyricText = xmlreader.GetValueAsString(LyricUtil.capatalizeString(artist), LyricUtil.capatalizeString(title), "");
- }
- lyricText = lyricText.Replace("\n", "\r\n");
+ lyricText = MyLyricsSetup.LyricsDB[CorrectKeyFormat(LyricUtil.capatalizeString(artist), LyricUtil.capatalizeString(title))].Lyrics;
+ return lyricText.Replace("\n", "\r\n");
}
+ catch
+ {
+ return lyricText;
+ }
+ }
- return lyricText;
+ public static string CorrectKeyFormat(string artist, string title)
+ {
+ return artist + "-" + title;
}
}
}
Modified: trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs
===================================================================
--- trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -31,5 +31,5 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("0.15")]
-[assembly: AssemblyFileVersion("0.15")]
+[assembly: AssemblyVersion("0.16")]
+[assembly: AssemblyFileVersion("0.16")]
Modified: trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/Properties/AssemblyInfo.cs
===================================================================
--- trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/Properties/AssemblyInfo.cs 2007-03-09 13:23:31 UTC (rev 170)
+++ trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/Properties/AssemblyInfo.cs 2007-03-09 17:26:16 UTC (rev 171)
@@ -29,5 +29,5 @@
// Build Number
// Revision
//
-[assembly: AssemblyVersion("0.15")]
-[assembly: AssemblyFileVersion("0.15")]
+[assembly: AssemblyVersion("0.16")]
+[assembly: AssemblyFileVersion("0.16")]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|