From: <sa...@us...> - 2007-03-18 11:13:41
|
Revision: 195 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=195&view=rev Author: saamand Date: 2007-03-17 06:53:17 -0700 (Sat, 17 Mar 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 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.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/LyricsEngine/LyricDiagnostics.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs 2007-03-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricDiagnostics.cs 2007-03-17 13:53:17 UTC (rev 195) @@ -10,15 +10,14 @@ { private static TraceSource ts; private static Stopwatch stopWatch; - private static string logName = "MyLyrics.log"; private static string logFileName = ""; private static FileStream objStream; private static TextWriterTraceListener objTraceListener; - public static void OpenLog(string logDir) + public static void OpenLog(string url) { - logFileName = logDir + "\\" + logName; + logFileName = url; if (ts == null) { Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2007-03-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2007-03-17 13:53:17 UTC (rev 195) @@ -125,7 +125,7 @@ </Target> --> <PropertyGroup> - <PostBuildEvent>::copy $(TargetFileName) "C:\Program Files\Team MediaPortal\MediaPortal"</PostBuildEvent> + <PostBuildEvent>copy $(TargetFileName) "C:\Program Files\Team MediaPortal\MediaPortal"</PostBuildEvent> <PreBuildEvent> </PreBuildEvent> </PropertyGroup> Modified: trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs 2007-03-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/LyricsEngine/Properties/AssemblyInfo.cs 2007-03-17 13:53:17 UTC (rev 195) @@ -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.16")] +[assembly: AssemblyVersion("0.17")] // // 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-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-03-17 13:53:17 UTC (rev 195) @@ -83,11 +83,12 @@ String[] m_sitesToSearch; - // Database settings + // Database and log settings internal static LyricsDatabase LyricsDB = null; internal static LyricsDatabase LyricsMarkedDB = null; internal const string LyricsDBName = "LyricsDatabaseV2.db"; internal const string LyricsMarkedDBName = "LyricsMarkedDatabaseV2.db"; + internal string logName = "MyLyrics.log"; #endregion @@ -192,8 +193,8 @@ startingScrollSpeedVertical = GUIGraphicsContext.ScrollSpeedVertical; GUIGraphicsContext.ScrollSpeedVertical = 1; - LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Log)); - //LyricDiagnostics.OpenLog(MediaPortal.Util.Config.GetFolder(MediaPortal.Util.Config.Dir.Log)); + LyricDiagnostics.OpenLog(MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Log, logName)); + //LyricDiagnostics.OpenLog(MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Log, logName)); LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Start, 0, LyricDiagnostics.elapsedTimeString() + "MyLyrics opens"); return true; } @@ -301,13 +302,13 @@ m_sitesToSearch = (string[])sitesToSearch.ToArray(typeof(string)); // Deserialize lyrics and marked database, and save references in LyricsDB - string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName); + string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); FileStream fs = new FileStream(path, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); LyricsDB = (LyricsDatabase)bf.Deserialize(fs); fs.Close(); - path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsMarkedDBName); + path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); fs = new FileStream(path, FileMode.Open); LyricsMarkedDB = (LyricsDatabase)bf.Deserialize(fs); fs.Close(); @@ -518,7 +519,7 @@ { LyricsDB.Add(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, m_LyricText, site)); - string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName); + string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); using (FileStream fs = new FileStream(path, FileMode.Open)) { BinaryFormatter bf = new BinaryFormatter(); @@ -532,7 +533,7 @@ { LyricsMarkedDB.Remove(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle)); - string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsMarkedDBName); + string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); using (FileStream fs = new FileStream(path, FileMode.Open)) { BinaryFormatter bf = new BinaryFormatter(); @@ -659,7 +660,11 @@ /// </summary> public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage) { - strButtonText = "My Lyrics";//GUILocalizeStrings.Get(9); // My News + using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) + { + strButtonText = ((string)xmlreader.GetValueAsString("myLyrics", "pluginsName", "My Lyrics")).ToString(); + } + //strButtonText = "Myrics";//GUILocalizeStrings.Get(9); // My News strButtonImage = String.Empty; strButtonImageFocus = String.Empty; strPictureImage = "hover_my lyrics.png"; Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs 2007-03-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs 2007-03-17 13:53:17 UTC (rev 195) @@ -31,6 +31,9 @@ this.tabControl = new MediaPortal.UserInterface.Controls.MPTabControl(); this.tabPageLyricsDatabase = new MediaPortal.UserInterface.Controls.MPTabPage(); this.tabPageSetup = new MediaPortal.UserInterface.Controls.MPTabPage(); + this.mpGroupBox2 = new MediaPortal.UserInterface.Controls.MPGroupBox(); + this.tbPluginName = new MediaPortal.UserInterface.Controls.MPTextBox(); + this.lbPluginName = new MediaPortal.UserInterface.Controls.MPLabel(); this.tbNote = new MediaPortal.UserInterface.Controls.MPLabel(); this.gbLyricSites = new MediaPortal.UserInterface.Controls.MPGroupBox(); this.cbHotLyrics = new MediaPortal.UserInterface.Controls.MPCheckBox(); @@ -52,7 +55,7 @@ this.cbMarkSongsWithNoLyrics = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.cbDisconsiderTitlesWithLyrics = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.lbSongsLimitNote = new MediaPortal.UserInterface.Controls.MPLabel(); - this.lbLimit = new MediaPortal.UserInterface.Controls.MPTextBox(); + this.tbLimit = new MediaPortal.UserInterface.Controls.MPTextBox(); this.lbSongsLimit = new MediaPortal.UserInterface.Controls.MPLabel(); this.gbMessages = new MediaPortal.UserInterface.Controls.MPGroupBox(); this.lbMessage = new MediaPortal.UserInterface.Controls.MPLabel(); @@ -86,6 +89,7 @@ this.bgWorkerSearch = new System.ComponentModel.BackgroundWorker(); this.tabControl.SuspendLayout(); this.tabPageSetup.SuspendLayout(); + this.mpGroupBox2.SuspendLayout(); this.gbLyricSites.SuspendLayout(); this.tabPageDatabase.SuspendLayout(); this.mpGroupBox1.SuspendLayout(); @@ -119,7 +123,7 @@ // // tabPageSetup // - this.tabPageSetup.Controls.Add(this.tbNote); + this.tabPageSetup.Controls.Add(this.mpGroupBox2); this.tabPageSetup.Controls.Add(this.gbLyricSites); this.tabPageSetup.Location = new System.Drawing.Point(4, 22); this.tabPageSetup.Name = "tabPageSetup"; @@ -129,10 +133,42 @@ this.tabPageSetup.Text = "General setup"; this.tabPageSetup.UseVisualStyleBackColor = true; // + // mpGroupBox2 + // + this.mpGroupBox2.AutoSize = true; + this.mpGroupBox2.Controls.Add(this.tbPluginName); + this.mpGroupBox2.Controls.Add(this.lbPluginName); + this.mpGroupBox2.FlatStyle = System.Windows.Forms.FlatStyle.Popup; + this.mpGroupBox2.Location = new System.Drawing.Point(4, 6); + this.mpGroupBox2.Name = "mpGroupBox2"; + this.mpGroupBox2.Size = new System.Drawing.Size(510, 63); + this.mpGroupBox2.TabIndex = 29; + this.mpGroupBox2.TabStop = false; + this.mpGroupBox2.Text = "Lyric sites to search"; + // + // tbPluginName + // + this.tbPluginName.BorderColor = System.Drawing.Color.Empty; + this.tbPluginName.Location = new System.Drawing.Point(87, 24); + this.tbPluginName.MaxLength = 30; + this.tbPluginName.Name = "tbPluginName"; + this.tbPluginName.Size = new System.Drawing.Size(154, 20); + this.tbPluginName.TabIndex = 13; + this.tbPluginName.Text = "My Lyrics"; + // + // lbPluginName + // + this.lbPluginName.AutoSize = true; + this.lbPluginName.Location = new System.Drawing.Point(13, 27); + this.lbPluginName.Name = "lbPluginName"; + this.lbPluginName.Size = new System.Drawing.Size(68, 13); + this.lbPluginName.TabIndex = 14; + this.lbPluginName.Text = "Plugin name:"; + // // tbNote // this.tbNote.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.tbNote.Location = new System.Drawing.Point(17, 111); + this.tbNote.Location = new System.Drawing.Point(13, 91); this.tbNote.Name = "tbNote"; this.tbNote.Size = new System.Drawing.Size(377, 18); this.tbNote.TabIndex = 19; @@ -142,15 +178,16 @@ // this.gbLyricSites.AutoSize = true; this.gbLyricSites.Controls.Add(this.cbHotLyrics); + this.gbLyricSites.Controls.Add(this.tbNote); this.gbLyricSites.Controls.Add(this.cbSeekLyrics); this.gbLyricSites.Controls.Add(this.cbLyricsOnDemand); this.gbLyricSites.Controls.Add(this.cbLyrics007); this.gbLyricSites.Controls.Add(this.cbEvilLabs); this.gbLyricSites.Controls.Add(this.cbLyricWiki); this.gbLyricSites.FlatStyle = System.Windows.Forms.FlatStyle.Popup; - this.gbLyricSites.Location = new System.Drawing.Point(4, 6); + this.gbLyricSites.Location = new System.Drawing.Point(4, 75); this.gbLyricSites.Name = "gbLyricSites"; - this.gbLyricSites.Size = new System.Drawing.Size(510, 102); + this.gbLyricSites.Size = new System.Drawing.Size(510, 125); this.gbLyricSites.TabIndex = 28; this.gbLyricSites.TabStop = false; this.gbLyricSites.Text = "Lyric sites to search"; @@ -301,7 +338,7 @@ this.gbGenerel.Controls.Add(this.cbMarkSongsWithNoLyrics); this.gbGenerel.Controls.Add(this.cbDisconsiderTitlesWithLyrics); this.gbGenerel.Controls.Add(this.lbSongsLimitNote); - this.gbGenerel.Controls.Add(this.lbLimit); + this.gbGenerel.Controls.Add(this.tbLimit); this.gbGenerel.Controls.Add(this.lbSongsLimit); this.gbGenerel.FlatStyle = System.Windows.Forms.FlatStyle.Popup; this.gbGenerel.Location = new System.Drawing.Point(3, 6); @@ -397,16 +434,16 @@ this.lbSongsLimitNote.TabIndex = 13; this.lbSongsLimitNote.Text = "(1000 is default)"; // - // lbLimit + // tbLimit // - this.lbLimit.BorderColor = System.Drawing.Color.Empty; - this.lbLimit.Location = new System.Drawing.Point(158, 19); - this.lbLimit.MaxLength = 6; - this.lbLimit.Name = "lbLimit"; - this.lbLimit.Size = new System.Drawing.Size(44, 20); - this.lbLimit.TabIndex = 1; - this.lbLimit.Text = "1000"; - this.lbLimit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; + this.tbLimit.BorderColor = System.Drawing.Color.Empty; + this.tbLimit.Location = new System.Drawing.Point(158, 19); + this.tbLimit.MaxLength = 6; + this.tbLimit.Name = "tbLimit"; + this.tbLimit.Size = new System.Drawing.Size(44, 20); + this.tbLimit.TabIndex = 1; + this.tbLimit.Text = "1000"; + this.tbLimit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // lbSongsLimit // @@ -695,7 +732,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(540, 539); + this.ClientSize = new System.Drawing.Size(537, 537); this.ControlBox = false; this.Controls.Add(this.btClose); this.Controls.Add(this.tabControl); @@ -710,6 +747,8 @@ this.tabControl.ResumeLayout(false); this.tabPageSetup.ResumeLayout(false); this.tabPageSetup.PerformLayout(); + this.mpGroupBox2.ResumeLayout(false); + this.mpGroupBox2.PerformLayout(); this.gbLyricSites.ResumeLayout(false); this.gbLyricSites.PerformLayout(); this.tabPageDatabase.ResumeLayout(false); @@ -765,7 +804,7 @@ internal MediaPortal.UserInterface.Controls.MPCheckBox cbLyricsOnDemand; internal MediaPortal.UserInterface.Controls.MPCheckBox cbSeekLyrics; private MediaPortal.UserInterface.Controls.MPLabel lbSongsLimitNote; - private MediaPortal.UserInterface.Controls.MPTextBox lbLimit; + private MediaPortal.UserInterface.Controls.MPTextBox tbLimit; private MediaPortal.UserInterface.Controls.MPLabel lbSongsLimit; private MediaPortal.UserInterface.Controls.MPGroupBox mpGroupBox1; private MediaPortal.UserInterface.Controls.MPButton btImportAll; @@ -782,5 +821,8 @@ internal MediaPortal.UserInterface.Controls.MPCheckBox cbHotLyrics; private MediaPortal.UserInterface.Controls.MPLabel tbNote; private MediaPortal.UserInterface.Controls.MPCheckBox cbSearchOnlyForMarkedSongs; + private MediaPortal.UserInterface.Controls.MPGroupBox mpGroupBox2; + private MediaPortal.UserInterface.Controls.MPTextBox tbPluginName; + private MediaPortal.UserInterface.Controls.MPLabel lbPluginName; } } \ No newline at end of file Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs 2007-03-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs 2007-03-17 13:53:17 UTC (rev 195) @@ -93,6 +93,7 @@ internal static LyricsDatabase LyricsMarkedDB = null; internal const string LyricsDBName = "LyricsDatabaseV2.db"; internal const string LyricsMarkedDBName = "LyricsMarkedDatabaseV2.db"; + internal const string LyricsXMLName = "Lyrics.xml"; // Timer variables int hour = 0; @@ -101,17 +102,24 @@ System.Windows.Forms.Timer timer; StopWatch stopwatch = new StopWatch(); - // Batch log information + // log information private string log; - private string logFileName = "MyLyricsBatch.log"; + private string logName = "MyLyrics.log"; + private string logBatchFileName = "MyLyricsBatch.log"; private string logFullFileName = ""; + private int lastShownLyricsTitles = 0; + private int lastShownMarkedLyricsTitles = 0; + bool stopCollectingOfTitles = false; public MyLyricsSetup() { - // Initialize GUI + LyricDiagnostics.OpenLog(MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Log, logName)); + //LyricDiagnostics.OpenLog(MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Log)); + + #region Initialize GUI and class InitializeComponent(); lyricsLibraryUC = new MyLyricsSetup_LyricsLibrary(this); this.tabPageLyricsDatabase.Controls.Add(lyricsLibraryUC); @@ -122,19 +130,19 @@ m_DelegateThreadFinished = new DelegateThreadFinished(this.ThreadFinishedMethod); m_DelegateThreadException = new DelegateThreadException(this.ThreadExceptionMethod); - LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Log)); - //LyricDiagnostics.OpenLog(MediaPortal.Util.Config.GetFolder(MediaPortal.Util.Config.Dir.Log)); // Grab music database MusicDatabase dbs = new MusicDatabase(); m_TotalTitles = dbs.GetNumOfSongs(); + #endregion - // Get settings saved in MediaPortal.xml + #region Get settings from in MediaPortal.xml using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) { try { - lbLimit.Text = xmlreader.GetValueAsString("myLyrics", "limit", m_TotalTitles.ToString()); + tbLimit.Text = xmlreader.GetValueAsString("myLyrics", "limit", m_TotalTitles.ToString()); + tbPluginName.Text = xmlreader.GetValueAsString("myLyrics", "pluginsName", "My Lyrics"); lbSongsLimitNote.Text = ("(You have currently " + m_TotalTitles.ToString() + " titles in your music database)"); cbLyricWiki.Checked = ((string)xmlreader.GetValueAsString("myLyrics", "useLyricWiki", "True")).ToString().Equals("True") ? true : false; @@ -173,60 +181,90 @@ MessageBox.Show("Something has gone wrong when reading Mediaportal.xml"); } } +#endregion - // Update database and serialize if needed... - string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName); - FileInfo fileInfo = new FileInfo(path); + #region Serialzie/deserialize lyricsdatabases + string lyricsXMLpath = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Base, LyricsXMLName); + FileInfo lyricsXMLfileInfo = new FileInfo(lyricsXMLpath); - if (fileInfo.Exists == false) + + // If lyrics.xml present, then convert database to new format... + if (lyricsXMLfileInfo.Exists) { - 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) + + string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + FileInfo fileInfo = new FileInfo(path); + + // .. but only if it hasn't already been converted + if (fileInfo.Exists == false) { - ConvertFromXMLtoLyricsDatabase convertFromXMLtoLyricsDatabase = new ConvertFromXMLtoLyricsDatabase(); - LyricsDB = convertFromXMLtoLyricsDatabase.Convert(); + 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(lyricsXMLpath); - // Create file to save the database to - FileStream fs = new FileStream(path, FileMode.Create); + // 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(); + // 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); + // Use the BinaryFormatter object to serialize the database to the file + bf.Serialize(fs, LyricsDB); + fs.Close(); - // 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); + // Create likewise a database for the remainingLyrics + path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); + fs = new FileStream(path, FileMode.Create); + LyricsMarkedDB = new LyricsDatabase(); + bf.Serialize(fs, LyricsMarkedDB); - // Close the file - fs.Close(); + // Close the file + fs.Close(); + } } + + // ... else deserialize the databases and save reference in LyricsDB and LyricsMarkedDB + else + { + DeserializeBothDB(); + } } - // ... else deserialize the databases and save reference in LyricsDB and LyricsMarkedDB + // If no Lyrics.xml present in base, then create new serialized databases else { - // Open database to read data from - FileStream fs = new FileStream(path, FileMode.Open); + string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + FileInfo fileInfo = new FileInfo(path); - // Create a BinaryFormatter object to perform the deserialization - BinaryFormatter bf = new BinaryFormatter(); + // .. but only if the databases hasn't been created + if (fileInfo.Exists == false) + { + path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); - // Use the BinaryFormatter object to deserialize the database - LyricsDB = (LyricsDatabase)bf.Deserialize(fs); - fs.Close(); + // Serialize empty LyricsDatabase if no lyrics.xml present + FileStream fs = new FileStream(path, FileMode.Create); + BinaryFormatter bf = new BinaryFormatter(); + LyricsDB = new LyricsDatabase(); + bf.Serialize(fs, LyricsDB); + fs.Close(); - // Deserialize LyricsRemainingDatabase - path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsMarkedDBName); - - fs = new FileStream(path, FileMode.Open); - LyricsMarkedDB = (LyricsDatabase)bf.Deserialize(fs); - fs.Close(); + // Serialize empty LyricsMarkedDatabase + path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); + fs = new FileStream(path, FileMode.Create); + LyricsMarkedDB = new LyricsDatabase(); + bf.Serialize(fs, LyricsMarkedDB); + fs.Close(); + } + else + { + DeserializeBothDB(); + } } MyLyricsSetup_LyricsLibrary.CurrentDB = LyricsDB; + #endregion + lyricsLibraryUC.updateLyricsTree(); } @@ -263,11 +301,13 @@ } } } + private void btSave_Click(object sender, System.EventArgs e) { using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings("MediaPortal.xml")) { - xmlwriter.SetValue("myLyrics", "limit", lbLimit.Text); + xmlwriter.SetValue("myLyrics", "limit", tbLimit.Text); + xmlwriter.SetValue("myLyrics", "pluginsName", tbPluginName.Text); xmlwriter.SetValue("myLyrics", "useLyricWiki", cbLyricWiki.Checked.ToString()); xmlwriter.SetValue("myLyrics", "useEvilLabs", cbEvilLabs.Checked.ToString()); xmlwriter.SetValue("myLyrics", "useLyrics007", cbLyrics007.Checked.ToString()); @@ -342,7 +382,7 @@ btImportAll.Enabled = false; - logFullFileName = Config.GetFile(Config.Dir.Log, logFileName); + logFullFileName = Config.GetFile(Config.Dir.Log, logBatchFileName); //if file is not found, create a new xml file if (!System.IO.File.Exists(logFullFileName)) @@ -358,7 +398,7 @@ writerLog.Close(); } - m_Limit = int.Parse(lbLimit.Text); + m_Limit = int.Parse(tbLimit.Text); m_DisregardKnownLyric = cbDisconsiderTitlesWithLyrics.Enabled && cbDisconsiderTitlesWithLyrics.Checked; m_MarkSongsWhenNoLyricFound = cbMarkSongsWithNoLyrics.Enabled && cbMarkSongsWithNoLyrics.Checked; @@ -804,11 +844,11 @@ string path = ""; if (ldb.Equals(LyricsDB)) { - path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName); + path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); } else if (ldb.Equals(LyricsMarkedDB)) { - path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsMarkedDBName); + path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); } // Create file to save the database to @@ -827,6 +867,28 @@ } } + private void DeserializeBothDB() + { + string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + + // 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 = (LyricsDatabase)bf.Deserialize(fs); + fs.Close(); + + // Deserialize LyricsRemainingDatabase + path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); + + fs = new FileStream(path, FileMode.Open); + LyricsMarkedDB = (LyricsDatabase)bf.Deserialize(fs); + fs.Close(); + } + private void MyLyricsSetup_FormClosing(object sender, FormClosingEventArgs e) { @@ -875,8 +937,18 @@ { if (tabControl.SelectedIndex == 0) { + if ((MyLyricsSetup_LyricsLibrary.CurrentDB.Equals(LyricsDB) && LyricsDB.Count != lastShownLyricsTitles) + || (MyLyricsSetup_LyricsLibrary.CurrentDB.Equals(LyricsMarkedDB) && LyricsMarkedDB.Count != lastShownMarkedLyricsTitles)) + { + lyricsLibraryUC.updateLyricsTree(); + } lyricsLibraryUC.treeView.Select(); } + else + { + lastShownLyricsTitles = LyricsDB.Count; + lastShownMarkedLyricsTitles = LyricsMarkedDB.Count; + } } } } \ No newline at end of file Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs 2007-03-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs 2007-03-17 13:53:17 UTC (rev 195) @@ -37,11 +37,6 @@ int m_NoOfTitles; LRC.SimpleLRC lrc; - System.Windows.Forms.Timer timer = null; - Stopwatch stopwatch = null; - string nextTimeToShow; - string nextLineToShow; - int lineCounter; const int SHIFT_WHEN_HIT = 15; internal static LyricsDatabase CurrentDB; private int currentDBIndex = 0; @@ -611,7 +606,7 @@ { if (MessageBox.Show(this, "Are you sure the Lyrics database should be deleted?", "Delete Lyrics database", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { - string path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + MyLyricsSetup.LyricsDBName; + string path = MediaPortal.Util.Config.GetFolder(MediaPortal.Util.Config.Dir.Database) + "\\" + MyLyricsSetup.LyricsDBName; FileStream fs = new FileStream(path, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); MyLyricsSetup.LyricsDB = new LyricsDatabase(); @@ -630,7 +625,7 @@ { 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) + "\\" + MyLyricsSetup.LyricsMarkedDBName; + string path = MediaPortal.Util.Config.GetFolder(MediaPortal.Util.Config.Dir.Database) + "\\" + MyLyricsSetup.LyricsMarkedDBName; FileStream fs = new FileStream(path, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); MyLyricsSetup.LyricsMarkedDB = new LyricsDatabase(); Modified: trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs 2007-03-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/My Lyrics/Properties/AssemblyInfo.cs 2007-03-17 13:53:17 UTC (rev 195) @@ -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.16")] -[assembly: AssemblyFileVersion("0.16")] +[assembly: AssemblyVersion("0.17")] +[assembly: AssemblyFileVersion("0.17")] 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-17 12:10:29 UTC (rev 194) +++ trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/Properties/AssemblyInfo.cs 2007-03-17 13:53:17 UTC (rev 195) @@ -29,5 +29,5 @@ // Build Number // Revision // -[assembly: AssemblyVersion("0.16")] -[assembly: AssemblyFileVersion("0.16")] +[assembly: AssemblyVersion("0.17")] +[assembly: AssemblyFileVersion("0.17")] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |