From: <sa...@us...> - 2007-03-20 16:50:23
|
Revision: 199 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=199&view=rev Author: saamand Date: 2007-03-20 09:50:17 -0700 (Tue, 20 Mar 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MyLyrics/LyricsEngine/LyricSearch.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj trunk/plugins/MyLyrics/LyricsEngine/Setup.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/MyLyric Windows Application/MyLyric Windows Application/LyricsEngine Tester.cs Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricSearch.cs =================================================================== (Binary files differ) Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs 2007-03-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsController.cs 2007-03-20 16:50:17 UTC (rev 199) @@ -27,67 +27,60 @@ private ILyricForm m_Form; // status - private static int noOfLyricsToSearch; - private static int noOfLyricsSearched; - private static int noOfLyricsFound; - private static int noOfLyricsNotFound; + private int noOfLyricsToSearch; + private int noOfLyricsSearched; + private int noOfLyricsFound; + private int noOfLyricsNotFound; private bool m_StopSearches = false; public static event EventHandler StopTheSearchAndAbort = null; ArrayList threadList = new ArrayList(); - ArrayList suspendedThreadList = new ArrayList(); - // Main thread sets this event to stop LyricController ManualResetEvent m_EventStop_LyricController; - // LyricController sets this event when it is stopped - ManualResetEvent m_EventStopped_LyricController; - // Main thread sets this event to pause all LyricSearches - public ManualResetEvent m_EventStop_LyricSearches; - // Variables related to GoogleSites - private ArrayList m_GoogleLicenseKeysUsed = new ArrayList(); - private string m_GoogleLicenseKey = ""; - private bool m_noMoreValidLicenseKeys = false; - int m_managedThreadId = -1; + private string[] lyricsSites; - // Lyric sites - private string[] lyricSites; - private string[] eastSites; + internal static bool ALLOW_ALL_TO_SEARCH = false; + + public LyricsController(ILyricForm mainForm, - ManualResetEvent eventStopThread, ManualResetEvent eventThreadStopped, - string[] lyricSites) + ManualResetEvent eventStopThread, + string[] lyricSites, bool allowAllToSearch) { this.m_Form = mainForm; - LyricsController.noOfLyricsToSearch = 1; - LyricsController.noOfLyricsSearched = 0; - LyricsController.noOfLyricsFound = 0; - LyricsController.noOfLyricsNotFound = 0; + noOfLyricsToSearch = 1; + noOfLyricsSearched = 0; + noOfLyricsFound = 0; + noOfLyricsNotFound = 0; - this.lyricSites = lyricSites; + ALLOW_ALL_TO_SEARCH = allowAllToSearch; - ArrayList easySitesArrayList = new ArrayList(); - - foreach (string site in lyricSites) + // If search all, then include all + if (allowAllToSearch) { - if (Setup.IsMemberOfEasySites(site)) + this.lyricsSites = lyricSites; + } + else + { + ArrayList tempArrayList = new ArrayList(); + foreach (string site in lyricSites) { - easySitesArrayList.Add(site); + if (Setup.IsMember(site)) + { + tempArrayList.Add(site); + } } + this.lyricsSites = (string[])tempArrayList.ToArray(typeof(string)); } - eastSites = (string[])easySitesArrayList.ToArray(typeof(string)); - LyricSearch.EasySites = eastSites; + + LyricSearch.LyricsSites = lyricsSites; - // initialize events m_EventStop_LyricController = eventStopThread; - m_EventStopped_LyricController = eventThreadStopped; - m_EventStop_LyricSearches = new ManualResetEvent(false); - m_EventStop_LyricSearches.Set(); - LyricSearch.Abort = false; } @@ -118,7 +111,6 @@ stillThreadsAlive = true; } } - m_EventStopped_LyricController.Set(); break; } } @@ -144,58 +136,33 @@ } } - Thread.Sleep(500); + Thread.Sleep(100); - // inform main thread that this thread stopped - m_EventStopped_LyricController.Set(); finishThread("", "", "The search has ended.", ""); } - public void updateManualResetEvents(ManualResetEvent eventStopThread, ManualResetEvent eventThreadStopped) - { - this.m_EventStop_LyricController = eventStopThread; - this.m_EventStopped_LyricController = eventThreadStopped; - } - public void addNewLyricSearch(string artist, string title) { - if (eastSites.Length > 0) + if (lyricsSites.Length > 0) { // create worker thread instance - ThreadStart easySitesThreadInstance = delegate + ThreadStart siteThreadInstance = delegate { - - LyricSearch lyricSearch_EasySites = new LyricSearch(m_EventStop_LyricController, m_EventStopped_LyricController, this); - lyricSearch_EasySites.setLyricInfo(artist, title); - lyricSearch_EasySites.Run(); + LyricSearch lyricSearch = new LyricSearch(this); + lyricSearch.setLyricInfo(artist, title); + lyricSearch.Run(); }; - Thread lyricSearchThread = new Thread(easySitesThreadInstance); - lyricSearchThread.Name = "BasicSearch for " + artist + " - " + title; // looks nice in Output window + Thread lyricSearchThread = new Thread(siteThreadInstance); + lyricSearchThread.Name = "BasicSearch for " + artist + " - " + title; lyricSearchThread.IsBackground = true; lyricSearchThread.Start(); threadList.Add(lyricSearchThread); } } - public void suspendAllSearchThreadsExceptMe(int managedThreadId) - { - //// clean-up operations may be placed here - //for (int i = 0; i < threadList.Count; i++) - //{ - // if (((Thread)threadList[i]).ManagedThreadId != managedThreadId) - // ((Thread)threadList[i]).Suspend(); - //} - m_managedThreadId = managedThreadId; - m_EventStop_LyricSearches.Reset(); - } - public void resumeAllSearchThreads() - { - m_EventStop_LyricSearches.Reset(); - } - internal void updateString(String message, String site) { m_Form.UpdateString = new Object[] { message, site }; @@ -203,7 +170,6 @@ internal void statusUpdate(string artist, string title, string site, bool lyricFound) { - //LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + artist + " - " + title + " - " + site + " - " +lyricFound.ToString() ); if (lyricFound) ++noOfLyricsFound; else @@ -213,7 +179,7 @@ m_Form.UpdateStatus = new Object[] { noOfLyricsToSearch, noOfLyricsSearched, noOfLyricsFound, noOfLyricsNotFound }; - if (noOfLyricsSearched >= noOfLyricsToSearch) + if ((noOfLyricsSearched >= noOfLyricsToSearch) && ALLOW_ALL_TO_SEARCH == false) { finishThread(artist, title, "All songs have been searched!", site); } @@ -241,7 +207,6 @@ public void finishThread(String artist, String title, String message, String site) { m_EventStop_LyricController.Set(); - m_EventStopped_LyricController.Set(); m_Form.ThreadFinished = new Object[] { artist, title, message, site }; } @@ -250,12 +215,6 @@ m_Form.ThreadException = s; } - public string GoogleLicenseKey - { - get { return m_GoogleLicenseKey; } - set { m_GoogleLicenseKey = value; } - } - public bool StopSearches { get { return m_StopSearches; } @@ -263,41 +222,20 @@ if (value == true) { m_StopSearches = true; - m_EventStop_LyricSearches.Reset(); LyricSearch.Abort = true; //StopTheSearchAndAbort.Invoke(this, EventArgs.Empty); } else { m_StopSearches = false; - m_EventStop_LyricSearches.Set(); LyricSearch.Abort = false; } } } - public ArrayList GoogleLicenseKeysUsed - { - get { return m_GoogleLicenseKeysUsed; } - } - - public void addToGoogleLicenseKeysUsed(string key) - { - if (!m_GoogleLicenseKeysUsed.Contains(key)) - { - m_GoogleLicenseKeysUsed.Add(key); - } - } - public int NoOfLyricsToSearch { - set { LyricsController.noOfLyricsToSearch = value; } + set { noOfLyricsToSearch = value; } } - - public bool NoMoreValidLicenseKeys - { - get { return m_noMoreValidLicenseKeys; } - set { m_noMoreValidLicenseKeys = value; } - } } } Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2007-03-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2007-03-20 16:50:17 UTC (rev 199) @@ -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/Setup.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/Setup.cs 2007-03-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/LyricsEngine/Setup.cs 2007-03-20 16:50:17 UTC (rev 199) @@ -6,7 +6,7 @@ { public static class Setup { - public static string[] EasySites = new string[4] + public static string[] BatchSearchSites = new string[4] { "LyricWiki", //"EvilLabs", @@ -20,24 +20,19 @@ public static string[] AllSites() { ArrayList allSites = new ArrayList(); - allSites.AddRange(EasySites); + allSites.AddRange(BatchSearchSites); string[] allSitesArray = (string[])allSites.ToArray(typeof(string)); return allSitesArray; } public static bool IsMember(string value) { - return System.Array.IndexOf<string>(Setup.EasySites, value) != -1; + return System.Array.IndexOf<string>(Setup.BatchSearchSites, value) != -1; } - public static bool IsMemberOfEasySites(string value) - { - return System.Array.IndexOf<string>(Setup.EasySites, value) != -1; - } - public static int NoOfSites() { - return EasySites.Length; + return BatchSearchSites.Length; } } } Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-03-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-03-20 16:50:17 UTC (rev 199) @@ -68,7 +68,6 @@ // events used to stop worker thread ManualResetEvent m_EventStopThread; - ManualResetEvent m_EventThreadStopped; // Track info string m_artist = ""; @@ -95,7 +94,6 @@ public GUIMyLyrics() { m_EventStopThread = new ManualResetEvent(false); - m_EventThreadStopped = new ManualResetEvent(false); GetID = (int)GUIMyLyrics.WINDOW_MYLYRICS; @@ -193,8 +191,8 @@ startingScrollSpeedVertical = GUIGraphicsContext.ScrollSpeedVertical; GUIGraphicsContext.ScrollSpeedVertical = 1; - 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.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, logName)); + //LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, logName)); LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Start, 0, LyricDiagnostics.elapsedTimeString() + "MyLyrics opens"); return true; } @@ -302,13 +300,13 @@ m_sitesToSearch = (string[])sitesToSearch.ToArray(typeof(string)); // Deserialize lyrics and marked database, and save references in LyricsDB - string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName); FileStream fs = new FileStream(path, FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); LyricsDB = (LyricsDatabase)bf.Deserialize(fs); fs.Close(); - path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); + path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsMarkedDBName); fs = new FileStream(path, FileMode.Open); LyricsMarkedDB = (LyricsDatabase)bf.Deserialize(fs); fs.Close(); @@ -326,7 +324,6 @@ private void findLyric(MusicTag tag) { m_EventStopThread.Reset(); - m_EventThreadStopped.Reset(); GUIControl.ClearControl(GetID, (int)Controls.CONTROL_Lyric); GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_Lyric, ""); @@ -351,7 +348,7 @@ // 1) + 2) Check if LRC in music tag or Database - string lyricText = MyLyrics.MyLyricsUtil.LookUpLyricInDatabase(LyricsDB, m_artist, m_title); + string lyricText = MyLyrics.DatabaseUtil.LookUpLyricInDatabase(LyricsDB, m_artist, m_title); if ((!tag.Lyrics.Equals("") && (lrc = new LRC.SimpleLRC(m_artist, m_title, tag.Lyrics)).IsValid) || (!lyricText.Equals("") && (lrc = new LRC.SimpleLRC(m_artist, m_title, lyricText)).IsValid)) @@ -418,7 +415,7 @@ { lyricsFound = false; - lc = new LyricsController(this, m_EventStopThread, m_EventThreadStopped, m_sitesToSearch); + lc = new LyricsController(this, m_EventStopThread, m_sitesToSearch, false); // create worker thread instance ThreadStart job = delegate { @@ -429,8 +426,6 @@ m_LyricControllerThread.Name = "lyricSearch Thread"; // looks nice in Output window m_LyricControllerThread.Start(); - lc.GoogleLicenseKey = m_GoogleLicenseKeys[m_GoogleLicenseKeyIndex]; - lc.addNewLyricSearch(m_artist, m_title); } } @@ -515,11 +510,11 @@ string capArtist = LyricUtil.capatalizeString(m_artist); string capTitle = LyricUtil.capatalizeString(m_title); - if (MyLyricsUtil.isTrackInLyricsDatabase(LyricsDB, capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_NOT_FOUND)) + if (DatabaseUtil.IsTrackInLyricsDatabase(LyricsDB, capArtist, capTitle).Equals(DatabaseUtil.LYRIC_NOT_FOUND)) { - LyricsDB.Add(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, m_LyricText, site)); + LyricsDB.Add(DatabaseUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, m_LyricText, site)); - string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName); using (FileStream fs = new FileStream(path, FileMode.Open)) { BinaryFormatter bf = new BinaryFormatter(); @@ -529,11 +524,11 @@ } } - if (MyLyricsUtil.isTrackInLyricsMarkedDatabase(LyricsMarkedDB, capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_MARKED)) + if (DatabaseUtil.IsTrackInLyricsMarkedDatabase(LyricsMarkedDB, capArtist, capTitle).Equals(DatabaseUtil.LYRIC_MARKED)) { - LyricsMarkedDB.Remove(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle)); + LyricsMarkedDB.Remove(DatabaseUtil.CorrectKeyFormat(capArtist, capTitle)); - string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); + string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsMarkedDBName); using (FileStream fs = new FileStream(path, FileMode.Open)) { BinaryFormatter bf = new BinaryFormatter(); @@ -556,25 +551,6 @@ m_LyricControllerThread = null; lc = null; - - //// wait when thread will stop or finish - //while (m_LyricControllerThread.IsAlive) - //{ - // // We cannot use here infinite wait because our thread - // // makes syncronous calls to main form, this will cause deadlock. - // // Instead of this we wait for event some appropriate time - // // (and by the way give time to worker thread) and - // // process events. These events may contain Invoke calls. - // if (WaitHandle.WaitAll( - // (new ManualResetEvent[] { m_EventThreadStopped }), - // 100, - // true)) - // { - // break; - // } - - // Application.DoEvents(); - //} } } Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs 2007-03-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs 2007-03-20 16:50:17 UTC (rev 199) @@ -34,9 +34,9 @@ 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(); + this.tbNote = new MediaPortal.UserInterface.Controls.MPLabel(); this.cbSeekLyrics = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.cbLyricsOnDemand = new MediaPortal.UserInterface.Controls.MPCheckBox(); this.cbLyrics007 = new MediaPortal.UserInterface.Controls.MPCheckBox(); @@ -107,7 +107,7 @@ this.tabControl.Location = new System.Drawing.Point(7, 12); this.tabControl.Name = "tabControl"; this.tabControl.SelectedIndex = 0; - this.tabControl.Size = new System.Drawing.Size(528, 494); + this.tabControl.Size = new System.Drawing.Size(534, 494); this.tabControl.TabIndex = 1; this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged); // @@ -116,7 +116,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, 468); + this.tabPageLyricsDatabase.Size = new System.Drawing.Size(526, 468); this.tabPageLyricsDatabase.TabIndex = 1; this.tabPageLyricsDatabase.Text = "Lyrics database"; this.tabPageLyricsDatabase.UseVisualStyleBackColor = true; @@ -128,7 +128,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, 468); + this.tabPageSetup.Size = new System.Drawing.Size(526, 468); this.tabPageSetup.TabIndex = 2; this.tabPageSetup.Text = "General setup"; this.tabPageSetup.UseVisualStyleBackColor = true; @@ -165,15 +165,6 @@ 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(13, 91); - this.tbNote.Name = "tbNote"; - this.tbNote.Size = new System.Drawing.Size(377, 18); - this.tbNote.TabIndex = 19; - this.tbNote.Text = "(Seek Lyrics and Evil Labs are currently disabled due to instable servers)"; - // // gbLyricSites // this.gbLyricSites.AutoSize = true; @@ -205,6 +196,15 @@ this.cbHotLyrics.Text = "Hot Lyrics"; this.cbHotLyrics.UseVisualStyleBackColor = true; // + // 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(13, 91); + this.tbNote.Name = "tbNote"; + this.tbNote.Size = new System.Drawing.Size(377, 18); + this.tbNote.TabIndex = 19; + this.tbNote.Text = "(Seek Lyrics and Evil Labs are currently disabled due to instable servers)"; + // // cbSeekLyrics // this.cbSeekLyrics.AutoSize = true; @@ -280,7 +280,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, 468); + this.tabPageDatabase.Size = new System.Drawing.Size(526, 468); this.tabPageDatabase.TabIndex = 2; this.tabPageDatabase.Text = "Search music database"; this.tabPageDatabase.UseVisualStyleBackColor = true; @@ -702,7 +702,7 @@ // // btSave // - this.btSave.Location = new System.Drawing.Point(358, 512); + this.btSave.Location = new System.Drawing.Point(363, 512); this.btSave.Name = "btSave"; this.btSave.Size = new System.Drawing.Size(78, 23); this.btSave.TabIndex = 16; @@ -712,7 +712,7 @@ // // btClose // - this.btClose.Location = new System.Drawing.Point(442, 512); + this.btClose.Location = new System.Drawing.Point(447, 512); this.btClose.Name = "btClose"; this.btClose.Size = new System.Drawing.Size(78, 23); this.btClose.TabIndex = 99; @@ -732,7 +732,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(537, 537); + this.ClientSize = new System.Drawing.Size(548, 536); 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-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.cs 2007-03-20 16:50:17 UTC (rev 199) @@ -37,7 +37,6 @@ // events used to stop worker thread ManualResetEvent m_EventStopThread; - ManualResetEvent m_EventThreadStopped; // Delegates public delegate void DelegateStringUpdate(String message, String site); @@ -88,13 +87,6 @@ private Queue lyricConfigInfosQueue; string[] sitesToSearchArray = null; - // Database settings - internal static LyricsDatabase LyricsDB = null; - 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; int min = 0; @@ -104,8 +96,6 @@ // log information private string log; - private string logName = "MyLyrics.log"; - private string logBatchFileName = "MyLyricsBatch.log"; private string logFullFileName = ""; private int lastShownLyricsTitles = 0; @@ -116,8 +106,8 @@ public MyLyricsSetup() { - LyricDiagnostics.OpenLog(MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Log, logName)); - //LyricDiagnostics.OpenLog(MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Log)); + LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, MyLyricsSettings.LogName)); + //LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log)); #region Initialize GUI and class InitializeComponent(); @@ -184,7 +174,7 @@ #endregion #region Serialzie/deserialize lyricsdatabases - string lyricsXMLpath = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Base, LyricsXMLName); + string lyricsXMLpath = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Base, MyLyricsSettings.LyricsXMLName); FileInfo lyricsXMLfileInfo = new FileInfo(lyricsXMLpath); @@ -192,7 +182,7 @@ if (lyricsXMLfileInfo.Exists) { - string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); FileInfo fileInfo = new FileInfo(path); // .. but only if it hasn't already been converted @@ -201,7 +191,7 @@ 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); + MyLyricsSettings.LyricsDB = convertFromXMLtoLyricsDatabase.Convert(lyricsXMLpath); // Create file to save the database to FileStream fs = new FileStream(path, FileMode.Create); @@ -210,14 +200,14 @@ BinaryFormatter bf = new BinaryFormatter(); // Use the BinaryFormatter object to serialize the database to the file - bf.Serialize(fs, LyricsDB); + bf.Serialize(fs, MyLyricsSettings.LyricsDB); fs.Close(); // Create likewise a database for the remainingLyrics - path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); + path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsMarkedDBName); fs = new FileStream(path, FileMode.Create); - LyricsMarkedDB = new LyricsDatabase(); - bf.Serialize(fs, LyricsMarkedDB); + MyLyricsSettings.LyricsMarkedDB = new LyricsDatabase(); + bf.Serialize(fs, MyLyricsSettings.LyricsMarkedDB); // Close the file fs.Close(); @@ -234,26 +224,26 @@ // If no Lyrics.xml present in base, then create new serialized databases else { - string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); FileInfo fileInfo = new FileInfo(path); // .. but only if the databases hasn't been created if (fileInfo.Exists == false) { - path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); // 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); + MyLyricsSettings.LyricsDB = new LyricsDatabase(); + bf.Serialize(fs, MyLyricsSettings.LyricsDB); fs.Close(); // Serialize empty LyricsMarkedDatabase - path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); + path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsMarkedDBName); fs = new FileStream(path, FileMode.Create); - LyricsMarkedDB = new LyricsDatabase(); - bf.Serialize(fs, LyricsMarkedDB); + MyLyricsSettings.LyricsMarkedDB = new LyricsDatabase(); + bf.Serialize(fs, MyLyricsSettings.LyricsMarkedDB); fs.Close(); } else @@ -262,7 +252,7 @@ } } - MyLyricsSetup_LyricsLibrary.CurrentDB = LyricsDB; + MyLyricsSetup_LyricsLibrary.CurrentDB = MyLyricsSettings.LyricsDB; #endregion lyricsLibraryUC.updateLyricsTree(); @@ -375,14 +365,13 @@ lbTotalSongs2.Text = m_TotalTitles.ToString(); m_EventStopThread = new ManualResetEvent(false); - m_EventThreadStopped = new ManualResetEvent(false); m_noOfMessages = 0; m_noOfCurrentlySearches = 0; btImportAll.Enabled = false; - logFullFileName = Config.GetFile(Config.Dir.Log, logBatchFileName); + logFullFileName = Config.GetFile(Config.Dir.Log, MyLyricsSettings.LogBatchFileName); //if file is not found, create a new xml file if (!System.IO.File.Exists(logFullFileName)) @@ -409,7 +398,7 @@ if (m_SearchOnlyMarkedSongs) { - progressBar.Maximum = LyricsMarkedDB.Count; + progressBar.Maximum = MyLyricsSettings.LyricsMarkedDB.Count; } else { @@ -453,7 +442,6 @@ sitesToSearchArray = (string[])sitesToSearch.ToArray(typeof(string)); m_EventStopThread.Reset(); - m_EventThreadStopped.Reset(); bgWorkerSearch.RunWorkerAsync(); @@ -479,16 +467,8 @@ string capArtist = LyricUtil.capatalizeString(m_artist); string capTitle = LyricUtil.capatalizeString(m_track); - if (MyLyricsUtil.isTrackInLyricsDatabase(LyricsDB, capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_NOT_FOUND)) - { - LyricsDB.Add(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, m_LyricText, site)); - } + DatabaseUtil.WriteToLyricsDatabase(MyLyricsSettings.LyricsDB, MyLyricsSettings.LyricsMarkedDB, capArtist, capTitle, lyricStrings, site); - if (MyLyricsUtil.isTrackInLyricsMarkedDatabase(LyricsMarkedDB, capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_MARKED)) - { - LyricsMarkedDB.Remove(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle)); - } - StreamReader sr = File.OpenText(logFullFileName); log = sr.ReadToEnd(); sr.Close(); @@ -512,9 +492,9 @@ string capArtist = LyricUtil.capatalizeString(artist); string capTitle = LyricUtil.capatalizeString(title); - if (m_MarkSongsWhenNoLyricFound && MyLyricsUtil.isTrackInLyricsMarkedDatabase(LyricsMarkedDB ,capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_NOT_FOUND)) + if (m_MarkSongsWhenNoLyricFound && DatabaseUtil.IsTrackInLyricsMarkedDatabase(MyLyricsSettings.LyricsMarkedDB, capArtist, capTitle).Equals(DatabaseUtil.LYRIC_NOT_FOUND)) { - LyricsMarkedDB.Add(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, "", "")); + MyLyricsSettings.LyricsMarkedDB.Add(DatabaseUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, "", "")); } m_SongsWithMark += 1; @@ -551,9 +531,7 @@ if (lc != null) { lc.StopSearches = true; - // Save databases to disc - SerializeDB(LyricsDB); - SerializeDB(LyricsMarkedDB); + DatabaseUtil.SerializeDBs(); lyricsLibraryUC.updateLyricsTree(); } bgWorkerSearch.CancelAsync(); @@ -677,24 +655,24 @@ string capArtist = LyricUtil.capatalizeString(tag.Artist); string capTitle = LyricUtil.capatalizeString(tag.Title); - if (MyLyricsUtil.isTrackInLyricsDatabase(LyricsDB, capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_NOT_FOUND)) + if (DatabaseUtil.IsTrackInLyricsDatabase(MyLyricsSettings.LyricsDB, capArtist, capTitle).Equals(DatabaseUtil.LYRIC_NOT_FOUND)) { - LyricsDB.Add(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, tag.Lyrics, "Tag")); + MyLyricsSettings.LyricsDB.Add(DatabaseUtil.CorrectKeyFormat(capArtist, capTitle), new LyricsItem(capArtist, capTitle, tag.Lyrics, "Tag")); } - if (MyLyricsUtil.isTrackInLyricsMarkedDatabase(LyricsMarkedDB, capArtist, capTitle).Equals(MyLyricsUtil.LYRIC_MARKED)) + if (DatabaseUtil.IsTrackInLyricsMarkedDatabase(MyLyricsSettings.LyricsMarkedDB, capArtist, capTitle).Equals(DatabaseUtil.LYRIC_MARKED)) { - LyricsMarkedDB.Remove(MyLyricsUtil.CorrectKeyFormat(capArtist, capTitle)); + MyLyricsSettings.LyricsMarkedDB.Remove(DatabaseUtil.CorrectKeyFormat(capArtist, capTitle)); } } else { - int status = MyLyricsUtil.isTrackInLyricsDatabase(LyricsDB, song.Artist, song.Title); + int status = DatabaseUtil.IsTrackInLyricsDatabase(MyLyricsSettings.LyricsDB, song.Artist, song.Title); bool isTrackInLyricsMarkedDatabase = true; - if (!m_DisregardKnownLyric && status.Equals(MyLyricsUtil.LYRIC_FOUND) - || (!m_DisregardMarkedLyric && ((isTrackInLyricsMarkedDatabase = MyLyricsUtil.isTrackInLyricsMarkedDatabase(LyricsMarkedDB, song.Artist, song.Title).Equals(MyLyricsUtil.LYRIC_MARKED)) || status.Equals(MyLyricsUtil.LYRIC_MARKED))) - || (status.Equals(MyLyricsUtil.LYRIC_NOT_FOUND) && !MyLyricsUtil.isTrackInLyricsMarkedDatabase(LyricsMarkedDB, song.Artist, song.Title).Equals(MyLyricsUtil.LYRIC_MARKED))) + if (!m_DisregardKnownLyric && status.Equals(DatabaseUtil.LYRIC_FOUND) + || (!m_DisregardMarkedLyric && ((isTrackInLyricsMarkedDatabase = DatabaseUtil.IsTrackInLyricsMarkedDatabase(MyLyricsSettings.LyricsMarkedDB, song.Artist, song.Title).Equals(DatabaseUtil.LYRIC_MARKED)) || status.Equals(DatabaseUtil.LYRIC_MARKED))) + || (status.Equals(DatabaseUtil.LYRIC_NOT_FOUND) && !DatabaseUtil.IsTrackInLyricsMarkedDatabase(MyLyricsSettings.LyricsMarkedDB, song.Artist, song.Title).Equals(DatabaseUtil.LYRIC_MARKED))) { songNotKnown = 1; @@ -711,7 +689,7 @@ m_SongsToSearch = lyricConfigInfosQueue.Count; bgWorkerSearch.ReportProgress(songNotKnown); } - else if (status.Equals(MyLyricsUtil.LYRIC_FOUND)) + else if (status.Equals(DatabaseUtil.LYRIC_FOUND)) { m_SongsWithLyric += 1; } @@ -726,7 +704,7 @@ } else { - foreach (KeyValuePair<string, LyricsItem> kvp in LyricsMarkedDB) + foreach (KeyValuePair<string, LyricsItem> kvp in MyLyricsSettings.LyricsMarkedDB) { int songNotKnown = 1; if (++m_SongsNotKnown > m_Limit) @@ -753,7 +731,7 @@ if (lyricConfigInfosQueue.Count > 0) { // start running the lyricController - lc = new LyricsController(this, m_EventStopThread, m_EventThreadStopped, sitesToSearchArray); + lc = new LyricsController(this, m_EventStopThread, sitesToSearchArray, false); lc.NoOfLyricsToSearch = lyricConfigInfosQueue.Count; ThreadStart runLyricController = delegate @@ -839,37 +817,9 @@ m_LyricControllerThread = null; } - internal static void SerializeDB(LyricsDatabase ldb) - { - string path = ""; - if (ldb.Equals(LyricsDB)) - { - path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); - } - else if (ldb.Equals(LyricsMarkedDB)) - { - path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); - } - - // Create file to save the database to - using (FileStream fs = new FileStream(path, FileMode.Open)) - { - // Create a BinaryFormatter object to perform the serialization - BinaryFormatter bf = new BinaryFormatter(); - - ldb.SetLastModified(); - - // Use the BinaryFormatter object to serialize the database to the file - bf.Serialize(fs, ldb); - - // Close the file - fs.Close(); - } - } - private void DeserializeBothDB() { - string path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsDBName); + string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsDBName); // Open database to read data from FileStream fs = new FileStream(path, FileMode.Open); @@ -878,14 +828,14 @@ BinaryFormatter bf = new BinaryFormatter(); // Use the BinaryFormatter object to deserialize the database - LyricsDB = (LyricsDatabase)bf.Deserialize(fs); + MyLyricsSettings.LyricsDB = (LyricsDatabase)bf.Deserialize(fs); fs.Close(); // Deserialize LyricsRemainingDatabase - path = MediaPortal.Util.Config.GetFile(MediaPortal.Util.Config.Dir.Database, LyricsMarkedDBName); + path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, MyLyricsSettings.LyricsMarkedDBName); fs = new FileStream(path, FileMode.Open); - LyricsMarkedDB = (LyricsDatabase)bf.Deserialize(fs); + MyLyricsSettings.LyricsMarkedDB = (LyricsDatabase)bf.Deserialize(fs); fs.Close(); } @@ -937,8 +887,8 @@ { if (tabControl.SelectedIndex == 0) { - if ((MyLyricsSetup_LyricsLibrary.CurrentDB.Equals(LyricsDB) && LyricsDB.Count != lastShownLyricsTitles) - || (MyLyricsSetup_LyricsLibrary.CurrentDB.Equals(LyricsMarkedDB) && LyricsMarkedDB.Count != lastShownMarkedLyricsTitles)) + if ((MyLyricsSetup_LyricsLibrary.CurrentDB.Equals(MyLyricsSettings.LyricsDB) && MyLyricsSettings.LyricsDB.Count != lastShownLyricsTitles) + || (MyLyricsSetup_LyricsLibrary.CurrentDB.Equals(MyLyricsSettings.LyricsMarkedDB) && MyLyricsSettings.LyricsMarkedDB.Count != lastShownMarkedLyricsTitles)) { lyricsLibraryUC.updateLyricsTree(); } @@ -946,8 +896,8 @@ } else { - lastShownLyricsTitles = LyricsDB.Count; - lastShownMarkedLyricsTitles = LyricsMarkedDB.Count; + lastShownLyricsTitles = MyLyricsSettings.LyricsDB.Count; + lastShownMarkedLyricsTitles = MyLyricsSettings.LyricsMarkedDB.Count; } } } Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.Designer.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.Designer.cs 2007-03-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.Designer.cs 2007-03-20 16:50:17 UTC (rev 199) @@ -37,6 +37,7 @@ this.btResetLyricsDatabase = new System.Windows.Forms.Button(); this.lbResetDatabase = new MediaPortal.UserInterface.Controls.MPLabel(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.btSearchSingle = new MediaPortal.UserInterface.Controls.MPButton(); this.gbLibrary.SuspendLayout(); this.gbResetDatabase.SuspendLayout(); this.SuspendLayout(); @@ -44,10 +45,10 @@ // btSave // this.btSave.Enabled = false; - this.btSave.Location = new System.Drawing.Point(218, 301); + this.btSave.Location = new System.Drawing.Point(224, 303); this.btSave.Name = "btSave"; this.btSave.Size = new System.Drawing.Size(75, 23); - this.btSave.TabIndex = 6; + this.btSave.TabIndex = 7; this.btSave.Text = "&Save"; this.btSave.UseVisualStyleBackColor = true; this.btSave.Click += new System.EventHandler(this.btSave_Click); @@ -83,6 +84,7 @@ // // gbLibrary // + this.gbLibrary.Controls.Add(this.btSearchSingle); this.gbLibrary.Controls.Add(this.lbSource); this.gbLibrary.Controls.Add(this.comboDatabase); this.gbLibrary.Controls.Add(this.lbDatabase); @@ -111,9 +113,9 @@ // 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.Location = new System.Drawing.Point(386, 297); this.lbSource.Name = "lbSource"; - this.lbSource.Size = new System.Drawing.Size(142, 15); + this.lbSource.Size = new System.Drawing.Size(113, 15); this.lbSource.TabIndex = 28; this.lbSource.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // @@ -128,7 +130,7 @@ this.comboDatabase.Location = new System.Drawing.Point(85, 15); this.comboDatabase.Name = "comboDatabase"; this.comboDatabase.Size = new System.Drawing.Size(144, 21); - this.comboDatabase.TabIndex = 27; + this.comboDatabase.TabIndex = 1; this.comboDatabase.SelectedIndexChanged += new System.EventHandler(this.comboDatabase_SelectedIndexChanged); // // lbDatabase @@ -156,7 +158,7 @@ this.btImportDirs.Location = new System.Drawing.Point(95, 330); this.btImportDirs.Name = "btImportDirs"; this.btImportDirs.Size = new System.Drawing.Size(75, 23); - this.btImportDirs.TabIndex = 24; + this.btImportDirs.TabIndex = 5; this.btImportDirs.Text = "Import &dirs"; this.btImportDirs.UseVisualStyleBackColor = true; this.btImportDirs.Click += new System.EventHandler(this.btImportDIRS_Click); @@ -178,8 +180,8 @@ this.tbLyrics.Multiline = true; this.tbLyrics.Name = "tbLyrics"; this.tbLyrics.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.tbLyrics.Size = new System.Drawing.Size(296, 213); - this.tbLyrics.TabIndex = 5; + this.tbLyrics.Size = new System.Drawing.Size(291, 213); + this.tbLyrics.TabIndex = 6; this.tbLyrics.KeyUp += new System.Windows.Forms.KeyEventHandler(this.tbLyrics_KeyUp); // // lbSongs @@ -232,7 +234,7 @@ this.treeView.Location = new System.Drawing.Point(14, 81); this.treeView.Name = "treeView"; this.treeView.Size = new System.Drawing.Size(200, 213); - this.treeView.TabIndex = 1; + this.treeView.TabIndex = 2; this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect); // // gbResetDatabase @@ -283,6 +285,16 @@ "erns [Artist]-[Title].txt and *.lrc will be included to the lyrics database."; this.folderBrowserDialog1.ShowNewFolderButton = false; // + // btSearchSingle + // + this.btSearchSingle.Location = new System.Drawing.Point(224, 330); + this.btSearchSingle.Name = "btSearchSingle"; + this.btSearchSingle.Size = new System.Drawing.Size(75, 23); + this.btSearchSingle.TabIndex = 8; + this.btSearchSingle.Text = "&Find"; + this.btSearchSingle.UseVisualStyleBackColor = true; + this.btSearchSingle.Click += new System.EventHandler(this.btSearchSingle_Click); + // // MyLyricsSetup_LyricsLibrary // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -324,5 +336,6 @@ private System.ComponentModel.IContainer components; private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; internal System.Windows.Forms.TreeView treeView; + internal MediaPortal.UserInterface.Controls.MPButton btSearchSingle; } } Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs 2007-03-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs 2007-03-20 16:50:17 UTC (rev 199) @@ -144,12 +144,12 @@ { LyricsItem item = new LyricsItem(artist, title, lyrics, site); - if (MyLyricsUtil.isTrackInLyricsDatabase(CurrentDB, artist, title).Equals(MyLyricsUtil.LYRIC_NOT_FOUND)) + if (DatabaseUtil.IsTrackInLyricsDatabase(CurrentDB, artist, title).Equals(DatabaseUtil.LYRIC_NOT_FOUND)) { - CurrentDB.Add(MyLyricsUtil.CorrectKeyFormat(artist, title), item); + CurrentDB.Add(DatabaseUtil.CorrectKeyFormat(artist, title), item); AddSong(item); treeView.Update(); - MyLyricsSetup.SerializeDB(CurrentDB); + DatabaseUtil.SerializeDB(CurrentDB); return true; } else @@ -184,8 +184,8 @@ treeView.Update(); // remove title from database - CurrentDB.Remove(MyLyricsUtil.CorrectKeyFormat(artist, title)); - MyLyricsSetup.SerializeDB(CurrentDB); + CurrentDB.Remove(DatabaseUtil.CorrectKeyFormat(artist, title)); + DatabaseUtil.SerializeDB(CurrentDB); } private bool isSelectedLyricALRC() @@ -200,7 +200,7 @@ m_CurrentArtist = artist; m_CurrentTitle = LyricUtil.capatalizeString(title); - string lyricsText = (string)CurrentDB[MyLyricsUtil.CorrectKeyFormat(artist, title)].Lyrics; + string lyricsText = (string)CurrentDB[DatabaseUtil.CorrectKeyFormat(artist, title)].Lyrics; LRC.SimpleLRC lrc = new LRC.SimpleLRC(artist, title, lyricsText); if (lrc.IsValid) @@ -216,13 +216,14 @@ return false; } - internal void updateInfo() + public void updateInfo() { m_CurrentArtist = ""; m_CurrentTitle = ""; tbLyrics.Text = ""; lbTitle.Text = ""; lbSource.Text = ""; + lbLRCTest.Text = ""; tbLyrics.Enabled = false; @@ -237,7 +238,7 @@ m_CurrentArtist = LyricUtil.capatalizeString(artist); m_CurrentTitle = LyricUtil.capatalizeString(title); - LyricsItem item = CurrentDB[MyLyricsUtil.CorrectKeyFormat(m_CurrentArtist, m_CurrentTitle)]; + LyricsItem item = CurrentDB[DatabaseUtil.CorrectKeyFormat(m_CurrentArtist, m_CurrentTitle)]; string lyricsText = item.Lyrics; lyricsText = LyricsEngine.LyricUtil.ReturnEnvironmentNewLine(lyricsText); @@ -289,7 +290,7 @@ private void btSave_Click(object sender, EventArgs e) { - CurrentDB[MyLyricsUtil.CorrectKeyFormat(LyricUtil.capatalizeString(m_CurrentArtist), LyricUtil.capatalizeString(m_CurrentTitle))].Lyrics = tbLyrics.Text; + CurrentDB[DatabaseUtil.CorrectKeyFormat(LyricUtil.capatalizeString(m_CurrentArtist), LyricUtil.capatalizeString(m_CurrentTitle))].Lyrics = tbLyrics.Text; btSave.Enabled = false; } @@ -586,7 +587,7 @@ { resetFields(); currentDBIndex = 0; - CurrentDB = MyLyricsSetup.LyricsDB; + CurrentDB = MyLyricsSettings.LyricsDB; btImportFiles.Enabled = true; btImportDirs.Enabled = true; updateLyricsTree(); @@ -595,7 +596,7 @@ { resetFields(); currentDBIndex = 1; - CurrentDB = MyLyricsSetup.LyricsMarkedDB; + CurrentDB = MyLyricsSettings.LyricsMarkedDB; btImportFiles.Enabled = false; btImportDirs.Enabled = false; updateLyricsTree(); @@ -606,14 +607,14 @@ { 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.Util.Config.GetFolder(MediaPortal.Util.Config.Dir.Database) + "\\" + MyLyricsSetup.LyricsDBName; + string path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + MyLyricsSettings.LyricsDBName; FileStream fs = new FileStream(path, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); - MyLyricsSetup.LyricsDB = new LyricsDatabase(); - bf.Serialize(fs, MyLyricsSetup.LyricsDB); + MyLyricsSettings.LyricsDB = new LyricsDatabase(); + bf.Serialize(fs, MyLyricsSettings.LyricsDB); fs.Close(); - CurrentDB = MyLyricsSetup.LyricsDB; + CurrentDB = MyLyricsSettings.LyricsDB; comboDatabase.SelectedIndex = 0; updateLyricsTree(); updateInfo(); @@ -625,18 +626,36 @@ { 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.Util.Config.GetFolder(MediaPortal.Util.Config.Dir.Database) + "\\" + MyLyricsSetup.LyricsMarkedDBName; + string path = MediaPortal.Configuration.Config.GetFolder(MediaPortal.Configuration.Config.Dir.Database) + "\\" + MyLyricsSettings.LyricsMarkedDBName; FileStream fs = new FileStream(path, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); - MyLyricsSetup.LyricsMarkedDB = new LyricsDatabase(); - bf.Serialize(fs, MyLyricsSetup.LyricsMarkedDB); + MyLyricsSettings.LyricsMarkedDB = new LyricsDatabase(); + bf.Serialize(fs, MyLyricsSettings.LyricsMarkedDB); fs.Close(); - CurrentDB = MyLyricsSetup.LyricsMarkedDB; + CurrentDB = MyLyricsSettings.LyricsMarkedDB; comboDatabase.SelectedIndex = 1; updateLyricsTree(); updateInfo(); } } + + private void btSearchSingle_Click(object sender, EventArgs e) + { + string artist = ""; + string title = ""; + + if (treeView.SelectedNode != null) + { + title = treeView.SelectedNode.Text; + + if (treeView.SelectedNode.Parent != null) + { + artist = treeView.SelectedNode.Parent.Text; + } + } + + MyLyricsSetup_SearchTitleDialog std = new MyLyricsSetup_SearchTitleDialog(this, artist, title); + } } } Modified: trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/LyricsEngine Tester.cs =================================================================== --- trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/LyricsEngine Tester.cs 2007-03-19 20:32:28 UTC (rev 198) +++ trunk/plugins/MyLyrics/MyLyric Windows Application/MyLyric Windows Application/LyricsEngine Tester.cs 2007-03-20 16:50:17 UTC (rev 199) @@ -39,7 +39,6 @@ // events used to stop worker thread ManualResetEvent m_EventStopThread; - ManualResetEvent m_EventThreadStopped; private int START_XPOS = 0; private int START_YPOS = 450; @@ -66,7 +65,6 @@ // initialize events m_EventStopThread = new ManualResetEvent(false); - m_EventThreadStopped = new ManualResetEvent(false); noOfLyricSites = Setup.NoOfSites(); lyricSiteArray = new LyricSiteTestUC[noOfLyricSites]; @@ -127,7 +125,6 @@ } m_EventStopThread.Reset(); - m_EventThreadStopped.Reset(); ArrayList sites = new ArrayList(); @@ -140,7 +137,7 @@ } } - LyricsController lc = new LyricsController(this, m_EventStopThread, m_EventThreadStopped, (string[])sites.ToArray(typeof(string))); + LyricsController lc = new LyricsController(this, m_EventStopThread, (string[])sites.ToArray(typeof(string)), false); ThreadStart job = delegate { @@ -148,8 +145,6 @@ lc.Run(); }; - lc.GoogleLicenseKey = tbLicenseKey.Text; - m_LyricControllerThread = new Thread(job); m_LyricControllerThread.Start(); } @@ -445,11 +440,9 @@ m_EventStopThread.Reset(); - m_EventThreadStopped.Reset(); + LyricsController lc = new LyricsController(this, m_EventStopThread, Setup.AllSites(), true); - LyricsController lc = new LyricsController(this, m_EventStopThread, m_EventThreadStopped, Setup.AllSites()); - // create worker thread instance ThreadStart job = delegate This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |