From: <sa...@us...> - 2007-04-12 18:17:37
|
Revision: 316 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=316&view=rev Author: saamand Date: 2007-04-12 11:16:51 -0700 (Thu, 12 Apr 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs trunk/plugins/MyLyrics/My Lyrics/MyLyrics.csproj trunk/plugins/MyLyrics/My Lyrics/MyLyrics.csproj.user trunk/plugins/MyLyrics/My Lyrics/MyLyricsSettings.cs trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup.Designer.cs trunk/plugins/MyLyrics/My Lyrics/MyLyricsSetup_LyricsLibrary.cs trunk/plugins/MyLyrics/MyLyrics.suo Modified: trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs 2007-04-12 07:54:06 UTC (rev 315) +++ trunk/plugins/MyLyrics/LyricsEngine/LRC/SimpleLRCTimeAndLineCollection.cs 2007-04-12 18:16:51 UTC (rev 316) @@ -4,7 +4,7 @@ namespace LRC { - public class SimpleLRCTimeAndLineCollection : IEnumerable + public class SimpleLRCTimeAndLineCollection : IEnumerable, ICollection { private object[] items = null; @@ -15,11 +15,36 @@ Sort(items); } + #region IEnumerable implementation public IEnumerator GetEnumerator() { return new Enumerator(items); } + #endregion + #region ICollection implementation + public int Count + { + get { return items.Length; } + } + + public bool IsSynchronized + { + get { throw new Exception("The method or operation is not implemented."); } + } + + public object SyncRoot + { + get { throw new Exception("The method or operation is not implemented."); } + } + + public void CopyTo(Array array, int index) + { + throw new Exception("The method or operation is not implemented."); + } + #endregion + + #region Enumerator class, IEnumerator implementation private class Enumerator : IEnumerator { private int cursor; @@ -63,14 +88,9 @@ } } } + #endregion - - private void Sort(object obj) - { - IComparer myComparer = new SortAfterTimeClass(); - Array.Sort(items, myComparer); - } - + #region SortAfterTimeClass class, IComparer implementation public class SortAfterTimeClass : IComparer { // Calls CaseInsensitiveComparer.Compare with the parameters reversed. @@ -80,6 +100,24 @@ } } + #endregion + + public string[] Copy() + { + string[] array = new string[this.Count]; + for (int i = 0; i < this.Count; i++) + { + SimpleLRCTimeAndLine timeLine = (SimpleLRCTimeAndLine)items[i]; + array.SetValue(timeLine.Line, i); + } + return array; + } + + private void Sort(object obj) + { + IComparer myComparer = new SortAfterTimeClass(); + Array.Sort(items, myComparer); + } } } Modified: trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj =================================================================== --- trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2007-04-12 07:54:06 UTC (rev 315) +++ trunk/plugins/MyLyrics/LyricsEngine/LyricsEngine.csproj 2007-04-12 18:16:51 UTC (rev 316) @@ -69,6 +69,8 @@ <DependentUpon>Resources.resx</DependentUpon> <DesignTime>True</DesignTime> </Compile> + <None Include="app.config" /> + <None Include="ClassDiagram1.cd" /> <None Include="Properties\Settings.settings"> <Generator>SettingsSingleFileGenerator</Generator> <LastGenOutput>Settings.Designer.cs</LastGenOutput> Modified: trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs =================================================================== --- trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-04-12 07:54:06 UTC (rev 315) +++ trunk/plugins/MyLyrics/My Lyrics/MyLyrics.cs 2007-04-12 18:16:51 UTC (rev 316) @@ -1,6 +1,4 @@ -#define DEBUGGING - -using System; +using System; using System.Windows.Forms; using System.Threading; using System.Diagnostics; @@ -36,10 +34,11 @@ public static int WINDOW_MYLYRICS = 90478; private int selectedScreen = 0; - string lyricsScreenXML = ""; + string lyricsScreenXML = "MyLyrics.xml"; bool exitingMyLyrics = false; - bool firstTime = false; + bool newTrack = false; + bool alreadyValidLRC = false; // worker thread Thread m_LyricControllerThread; @@ -54,7 +53,6 @@ string m_TrackText = ""; string m_StatusText = ""; string m_LyricText = ""; - string m_Path = ""; bool lyricsFound = false; @@ -69,36 +67,57 @@ #endregion - #region Fields related to one of lyrics modes + #region GUI enums + enum GUI_General_Controls + { + CONTROL_BACKGROUND = 1, + CONTROL_LBStatus = 11 + } - enum LyricGUI_Controls + enum GUI_Lyrics_Controls { - CONTROL_BACKGROUND = 1, - CONTROL_LBTrack = 10, - CONTROL_LBStatus = 11, CONTROL_Lyric = 20 } + enum GUI_LRC_Controls : int + { + CONTROL_ART_CURRENTLY = 24, + CONTROL_ART_DURATION = 25, + CONTROL_ART_ALBUM = 26, + CONTROL_ART_YEAR = 27, + CONTROL_ART_NOWPLAYINGBACK = 31, + CONTROL_ART_ALBUMART = 112, + CONTROL_ART_PROGRESS = 118, + CONTROL_ART_PROGRESSIMAGE = 117, + + CONTROL_TAGBUTTON = 50, + + CONTROL_EDIT_TIME = 600, + CONTROL_EDIT_LINE = 200, + CONTROL_EDIT_LINE_DONE = 300, + + CONTROL_VIEW_LINE = 400, + CONTROL_VIEW_LINE_DONE = 500 + } #endregion #region Fields related to LRC mode - const int SHIFT_WHEN_HIT = 10; + internal const int BASIC_WIDE_LIMIT = 40; LRC.SimpleLRC lrc; IEnumerator enumerator; System.Windows.Forms.Timer timer; Stopwatch stopwatch; string nextTimeToShow; string nextLineToShow; - int lineCounter; #endregion #region Fields releated to the editor mode - internal const int TAG_IN_ROUND = 5; - internal int currentLineToTagIndex = 1; - internal int currentLineToTag_Total = 0; + internal const int TAG_IN_ROUND = 13; + internal int currentLRCLine = 0; + internal int LRCLinesTotal = 0; internal int tagRoundFinished = 0; internal int min = 0; internal int sec = 0; @@ -106,36 +125,6 @@ string[] lines; ArrayList times; - - enum EditorGUI_Controls : int - { - CONTROL_BACKGROUND = 1, - CONTROL_LBTrack = 10, - CONTROL_LBStatus = 11, - - CONTROL_TAGBUTTON = 50, - - CONTROL_TIME = 100, - CONTROL_TIME1 = 101, - CONTROL_TIME2 = 102, - CONTROL_TIME3 = 103, - CONTROL_TIME4 = 104, - CONTROL_TIME5 = 105, - - CONTROL_LINE = 200, - CONTROL_LINE1 = 201, - CONTROL_LINE2 = 202, - CONTROL_LINE3 = 203, - CONTROL_LINE4 = 204, - CONTROL_LINE5 = 205, - - CONTROL_LINE_DONE = 300, - CONTROL_LINE1_DONE = 301, - CONTROL_LINE2_DONE = 302, - CONTROL_LINE3_DONE = 303, - CONTROL_LINE4_DONE = 304, - CONTROL_LINE5_DONE = 305 - } #endregion @@ -159,356 +148,141 @@ { case (int)MyLyricsSettings.Screen.LYRICS_BASIC: selectedScreen = (int)MyLyricsSettings.Screen.LYRICS_BASIC; - lyricsScreenXML = "MyLyrics.xml"; break; case (int)MyLyricsSettings.Screen.LYRICS_WIDE: selectedScreen = (int)MyLyricsSettings.Screen.LYRICS_WIDE; - lyricsScreenXML = "MyLyricsWide.xml"; break; case (int)MyLyricsSettings.Screen.LRC_BASIC: selectedScreen = (int)MyLyricsSettings.Screen.LRC_BASIC; - lyricsScreenXML = "MyLyricsLRC.xml"; break; case (int)MyLyricsSettings.Screen.LRC_EDITOR: selectedScreen = (int)MyLyricsSettings.Screen.LRC_EDITOR; - lyricsScreenXML = "MyLyricsEditor.xml"; break; default: selectedScreen = (int)MyLyricsSettings.Screen.LYRICS_BASIC; - lyricsScreenXML = "MyLyrics.xml"; break; } + timer = new System.Windows.Forms.Timer(); + return Load(GUIGraphicsContext.Skin + @"\" + lyricsScreenXML); } - public override void OnAction(Action action) + + public override void Process() { - switch (action.wID) + if (newTrack) { - case Action.ActionType.ACTION_PREVIOUS_MENU: + alreadyValidLRC = false; + + if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_BASIC || selectedScreen == (int)MyLyricsSettings.Screen.LRC_WIDE) { - GUIWindowManager.ShowPreviousWindow(); - return; - } - } - base.OnAction(action); - } + lyricsFound = false; + StopThread(); + newTrack = false; - private void resetAll() - { + MusicTag tag = new MusicTag(); + tag.Artist = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); + tag.Title = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); + m_artist = tag.Artist; + m_title = tag.Title; - //deregister the handler! - GUIPropertyManager.OnPropertyChanged -= this.trackChangeHandler; - - firstTime = false; - exitingMyLyrics = true; - m_artist = ""; - m_title = ""; - m_TrackText = ""; - m_StatusText = ""; - m_LyricText = ""; - m_Path = ""; - lyricsFound = false; - m_LyricControllerThread = null; - lc = null; - m_sitesToSearch = null; - - resetLrcFields(); - } - - private void resetLrcFields() - { - if (timer != null) - timer.Dispose(); - if (stopwatch != null) - stopwatch.Reset(); - nextTimeToShow = ""; - nextLineToShow = ""; - lineCounter = 0; - } - - public override bool OnMessage(GUIMessage message) - { - switch (message.Message) - { - case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: + // Get lyric + if (!tag.Artist.Equals("")) { - exitingMyLyrics = false; - base.OnMessage(message); - - LoadSettings(); - - LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, logName)); - LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Start, 0, LyricDiagnostics.elapsedTimeString() + "MyLyrics opens, screen: " + lyricsScreenXML); - return true; + findLyric(tag); } - case GUIMessage.MessageType.GUI_MSG_CLICKED: + else { + m_artist = ""; + m_title = ""; + m_TrackText = ""; + m_StatusText = "No music file playing"; + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); + m_LyricText = ""; + GUIControl.SetControlLabel(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric, m_LyricText); + } + } + else if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) + { + newTrack = false; - //get sender control - int iControl = message.SenderControlId; + m_artist = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); + m_title = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); - if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) - { - if (iControl == (int)EditorGUI_Controls.CONTROL_TAGBUTTON) - { - string time = "[" + min.ToString() + ":" + (sec.ToString().Length == 2 ? sec.ToString() : "0" + sec.ToString()) + "." + (stopwatch.ElapsedMilliseconds.ToString().Length == 3 ? stopwatch.ElapsedMilliseconds.ToString() : stopwatch.ElapsedMilliseconds.ToString() + "0") + "]"; - lines[currentLineToTag_Total] = time + lines[currentLineToTag_Total]; - GUIControl.SetControlLabel(GetID, (int)EditorGUI_Controls.CONTROL_TIME + currentLineToTagIndex, time); - GUIControl.HideControl(GetID, (int)EditorGUI_Controls.CONTROL_LINE + currentLineToTagIndex); - - if (++currentLineToTag_Total < lines.Length) - { - - // If a new round has to start - if (++currentLineToTagIndex == TAG_IN_ROUND + 1) - { - currentLineToTagIndex = 1; - ++tagRoundFinished; - - for (int i = 1; i <= TAG_IN_ROUND && currentLineToTag_Total + i < lines.Length ; i++) - { - GUIControl.ShowControl(GetID, (int)EditorGUI_Controls.CONTROL_LINE + i); - GUIControl.SetControlLabel(GetID, (int)EditorGUI_Controls.CONTROL_TIME + i, ""); - GUIControl.SetControlLabel(GetID, (int)EditorGUI_Controls.CONTROL_LINE + i, lines[tagRoundFinished * TAG_IN_ROUND + i]); - GUIControl.SetControlLabel(GetID, (int)EditorGUI_Controls.CONTROL_LINE_DONE + i, lines[tagRoundFinished * TAG_IN_ROUND + i]); - } - } - } - else - { - MessageBox.Show("The lyric has now completely been converted into a lrc!"); - StringBuilder lyric = new StringBuilder(); - for (int i = 0; i < lines.Length; i++) - { - lyric.Append(lines[i] + "\n"); - } - lyric.Replace("\r", ""); - - string artist = LyricUtil.capatalizeString(m_artist); - string title = LyricUtil.capatalizeString(m_title); - string lyricAsString = lyric.ToString(); - - int lastLineShift = lyricAsString.LastIndexOf("\n"); - lyricAsString = lyricAsString.Substring(0, lastLineShift); - - LyricsItem item = new LyricsItem(artist, title, lyricAsString, "MP LRC-editor"); - LyricsDB[DatabaseUtil.CorrectKeyFormat(artist, title)] = item; - - string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName); - using (FileStream fs = new FileStream(path, FileMode.Open)) - { - BinaryFormatter bf = new BinaryFormatter(); - LyricsDB.SetLastModified(); - bf.Serialize(fs, LyricsDB); - fs.Close(); - } - } - - } - } - return true; + if (DatabaseUtil.IsTrackInLyricsDatabase(LyricsDB, m_artist, m_title).Equals(DatabaseUtil.LYRIC_FOUND)) + { + LyricsItem item = LyricsDB[DatabaseUtil.CorrectKeyFormat(m_artist, m_title)]; + m_LyricText = item.Lyrics; + showLRCtoEdit(); } - case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: + else { - StopThread(); - resetAll(); - LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Stop, 0, LyricDiagnostics.elapsedTimeString() + "MyLyrics closes, screen: " + lyricsScreenXML); - break; + startSearch(); } - } - return base.OnMessage(message); - } - - //event driven handler to detect track change - private void trackChangeHandler(string tag2, string value) - { - if (tag2.Equals("#Play.Current.Track") && !exitingMyLyrics) // track has changed - { - if (!value.Equals("")) // additional check - { - lyricsFound = false; - StopThread(); - - MusicTag tag = new MusicTag(); - tag.Artist = GUIPropertyManager.GetProperty("#Play.Current.Artist"); - tag.Title = GUIPropertyManager.GetProperty("#Play.Current.Title"); - - findLyric(tag); } - else + else if (!exitingMyLyrics) { - m_artist = ""; - m_title = ""; - m_TrackText = ""; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBTrack, m_StatusText); - m_StatusText = "No music file playing"; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus, m_StatusText); - m_LyricText = ""; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_Lyric, m_LyricText); + startSearch(); } } + base.Process(); } - //event driven handler to detect track change - private void timeHandler(string tag2, string value) + private void startSearch() { - if (tag2.Equals("#currentplaytime") && !exitingMyLyrics) - { - if (stopwatch != null && stopwatch.IsRunning) - { - stopwatch.Stop(); - } + lyricsFound = false; + StopThread(); + newTrack = false; - stopwatch = new Stopwatch(); - stopwatch.Start(); + MusicTag tag = new MusicTag(); + tag.Artist = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); + tag.Title = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); - string[] timeStrings = value.Split(':'); - min = int.Parse(timeStrings[0]); - sec = int.Parse(timeStrings[1]); - - if (!value.Equals("")) // additional check - { - lyricsFound = false; - StopThread(); - - MusicTag tag = new MusicTag(); - tag.Artist = GUIPropertyManager.GetProperty("#Play.Current.Artist"); - tag.Title = GUIPropertyManager.GetProperty("#Play.Current.Title"); - - findLyric(tag); - } - else - { - m_artist = ""; - m_title = ""; - m_TrackText = ""; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBTrack, m_StatusText); - m_StatusText = "No music file playing"; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus, m_StatusText); - m_LyricText = ""; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_Lyric, m_LyricText); - } + if (!tag.Artist.Equals("")) findLyric(tag); + else + { + m_artist = ""; + m_title = ""; + m_TrackText = ""; + m_StatusText = "No music file playing"; + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); + m_LyricText = ""; + GUIControl.SetControlLabel(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric, m_LyricText); } } - public override void Process() + private void showLRCtoEdit() { - if (firstTime && selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) + LRC.SimpleLRC lrc = new LRC.SimpleLRC(m_artist, m_title, m_LyricText); + + if (lrc.IsValid) { - firstTime = false; - - string artist = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Artist")); - string title = LyricUtil.capatalizeString(GUIPropertyManager.GetProperty("#Play.Current.Title")); - - string lyric = ""; - - if (DatabaseUtil.IsTrackInLyricsDatabase(LyricsDB, artist, title).Equals(DatabaseUtil.LYRIC_FOUND)) - { - LyricsItem item = LyricsDB[DatabaseUtil.CorrectKeyFormat(artist, title)]; - lyric = item.Lyrics; - - lines = lyric.Split(new string[1] { "\n" }, StringSplitOptions.None); - - for (int i = tagRoundFinished * TAG_IN_ROUND; i < (tagRoundFinished + 1) * TAG_IN_ROUND; i++) - { - GUIControl.SetControlLabel(GetID, (int)EditorGUI_Controls.CONTROL_LINE + i, lines[i]); - GUIControl.SetControlLabel(GetID, (int)EditorGUI_Controls.CONTROL_LINE_DONE + i, lines[i]); - } - } + alreadyValidLRC = true; + lines = new string[1] { "This track already has a valid LRC!" }; } - else if (firstTime && !exitingMyLyrics) //when mylyrics is opened while music is already playing, trackChangeHandler won't be called + else { - lyricsFound = false; - StopThread(); - firstTime = false; - - MusicTag tag = new MusicTag(); - tag.Artist = GUIPropertyManager.GetProperty("#Play.Current.Artist"); - tag.Title = GUIPropertyManager.GetProperty("#Play.Current.Title"); - - if (!tag.Artist.Equals("")) findLyric(tag); - else - { - m_artist = ""; - m_title = ""; - m_TrackText = ""; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBTrack, m_StatusText); - m_StatusText = "No music file playing"; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus, m_StatusText); - m_LyricText = ""; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_Lyric, m_LyricText); - } + lines = m_LyricText.Split(new string[1] { "\n" }, StringSplitOptions.None); } - - /* - if (isNewTrack() && exitingMyLyrics == false) + try { - lyricsFound = false; - StopThread(); - m_Path = g_Player.CurrentFile; - MusicTag tag = MediaPortal.TagReader.TagReader.ReadTag(m_Path); - - - //quick and dirty CDA support hack :) - if (g_Player.IsCDA) - { - tag = new MusicTag(); - tag.Artist = GUIPropertyManager.GetProperty("#Play.Current.Artist"); - tag.Title = GUIPropertyManager.GetProperty("#Play.Current.Title"); - } - - if (!m_Path.Equals("")) + for (int i = tagRoundFinished * TAG_IN_ROUND; i < (tagRoundFinished + 1) * TAG_IN_ROUND; i++) { - //findLyric(tag); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i, lines[i]); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, lines[i]); } - else - { - m_artist = ""; - m_title = ""; - m_TrackText = ""; - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_LBTrack, m_StatusText); - m_StatusText = "No music file playing"; - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_LBStatus, m_StatusText); - m_LyricText = ""; - GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_Lyric, m_LyricText); - } - }*/ - - - base.Process(); + } + catch { ;} } - private bool isNewTrack() - { - return !m_Path.Equals(g_Player.CurrentFile); - } - void LoadSettings() { - firstTime = true; + newTrack = true; - // Clear and update labels - if (selectedScreen != (int)MyLyricsSettings.Screen.LRC_EDITOR) - { - GUIControl.ClearControl(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus); - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus, m_StatusText); - GUIControl.ClearControl(GetID, (int)LyricGUI_Controls.CONTROL_LBTrack); - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBTrack, m_TrackText); - GUIControl.ClearControl(GetID, (int)LyricGUI_Controls.CONTROL_Lyric); - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_Lyric, m_LyricText); + resetGUI(selectedScreen); - GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(trackChangeHandler); - - times = new ArrayList(); - } - else if(selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) - { - GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(timeHandler); - } - bool useLyricWiki, useEvilLabs, useLyrics007, useLyricsOnDemand, useSeekLyrics, useHotLyrics; using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.Settings("MediaPortal.xml")) @@ -567,6 +341,116 @@ { } + public override bool OnMessage(GUIMessage message) + { + switch (message.Message) + { + case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: + { + exitingMyLyrics = false; + base.OnMessage(message); + + LoadSettings(); + + LyricDiagnostics.OpenLog(MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Log, logName)); + LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Start, 0, LyricDiagnostics.elapsedTimeString() + "MyLyrics opens, screen: " + lyricsScreenXML); + return true; + } + case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: + { + StopThread(); + resetAll(); + LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Stop, 0, LyricDiagnostics.elapsedTimeString() + "MyLyrics closes, screen: " + lyricsScreenXML); + break; + } + } + return base.OnMessage(message); + } + + + public override void OnAction(Action action) + { + switch (action.wID) + { + case Action.ActionType.ACTION_PREVIOUS_MENU: + { + GUIWindowManager.ShowPreviousWindow(); + break; + } + case Action.ActionType.ACTION_KEY_PRESSED: + { + if (action.m_key.KeyChar.Equals(13)) + { + tagLine(); + } + if (action.m_key.KeyChar.Equals(40)) + { + lyricsFound = false; + if (selectedScreen != (int)MyLyricsSettings.Screen.LRC_EDITOR) + { + resetGUI((int)MyLyricsSettings.Screen.LRC_EDITOR); + + } + else + { + // parameter could be anything but LRC_EDITOR. Will find correct type when running findLyric(). + resetGUI((int)MyLyricsSettings.Screen.LYRICS_BASIC); + } + + newTrack = true; + Process(); + } + break; + } + } + base.OnAction(action); + } + + //event driven handler to detect track change + private void trackChangeHandler(string tag2, string value) + { + if (tag2.Equals("#Play.Current.Track") && !exitingMyLyrics) // track has changed + { + if (!value.Equals("")) // additional check + { + resetGUI(selectedScreen); + StopThread(); + resetAll(); + newTrack = true; + Process(); + } + else + { + m_artist = ""; + m_title = ""; + m_TrackText = ""; + m_StatusText = "No music file playing"; + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); + m_LyricText = ""; + GUIControl.SetControlLabel(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric, m_LyricText); + } + } + } + + //event driven handler to detect track change + private void timeHandler(string tag2, string value) + { + if (tag2.Equals("#currentplaytime") && !exitingMyLyrics) + { + if (stopwatch != null && stopwatch.IsRunning) + { + stopwatch.Stop(); + } + + stopwatch = new Stopwatch(); + stopwatch.Start(); + + string[] timeStrings = value.Split(':'); + min = int.Parse(timeStrings[0]); + sec = int.Parse(timeStrings[1]); + } + } + /// <summary> /// findLyric searches for a lyric related to the given tag. /// </summary> @@ -576,17 +460,16 @@ { m_EventStopThread.Reset(); - GUIControl.ClearControl(GetID, (int)LyricGUI_Controls.CONTROL_Lyric); - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_Lyric, ""); + GUIControl.ClearControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); + GUIControl.SetControlLabel(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric, ""); if (tag != null && tag.Artist != "") { m_artist = tag.Artist.Trim(); m_title = tag.Title.Trim(); m_TrackText = m_artist + " - " + m_title; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBTrack, m_TrackText); - m_StatusText = "Searching for a matching lyric. Please wait a moment..."; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus, m_StatusText); + m_StatusText = "Searching for a matching lyric..."; + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); LyricDiagnostics.TraceSource.TraceEvent(TraceEventType.Information, 0, LyricDiagnostics.elapsedTimeString() + "findLyric(" + m_artist + ", " + m_title + ")"); @@ -604,36 +487,39 @@ 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)) { - resetLrcFields(); - m_StatusText = ""; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus, m_StatusText); + lines = lrc.SimpleLRCTimeAndLineCollection.Copy(); - if (lrc == null) + //Let's see if the basic or wide version of the LRC-screen should be shown + bool aLongLinePresent = false; + for (int i = 0; i < lines.Length; i++) { - MessageBox.Show("The lrc-file couldn't not be read properly." + Environment.NewLine + "The reading of the files was suspended."); - return; + if (lines[i].Length > BASIC_WIDE_LIMIT) + { + aLongLinePresent = true; + break; + } } - else if (lrc.IsValid == false) + + if (aLongLinePresent) { - MessageBox.Show("The selected file is not a valid lrc-file."); - return; + resetGUI((int)MyLyricsSettings.Screen.LRC_WIDE); } - else if (lrc.Lyric.Equals("")) + else { - MessageBox.Show("The lrc-file couldn't not be read properly." + Environment.NewLine + "It seemed to be empty."); - return; + resetGUI((int)MyLyricsSettings.Screen.LRC_BASIC); } + m_StatusText = ""; + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); + enumerator = lrc.SimpleLRCTimeAndLineCollection.GetEnumerator(); if (!lrc.Artist.Equals("") && !lrc.Title.Equals("")) { m_StatusText = ""; m_LyricText = ""; - GUIControl.ClearControl(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus); - GUIControl.ClearControl(GetID, (int)LyricGUI_Controls.CONTROL_Lyric); // setup timer and stopwatch timer = new System.Windows.Forms.Timer(); @@ -647,6 +533,16 @@ timer.Start(); stopwatch.Start(); } + + try + { + for (int i = tagRoundFinished * TAG_IN_ROUND; i < (tagRoundFinished + 1) * TAG_IN_ROUND; i++) + { + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i, lines[i]); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, lines[i]); + } + } + catch { ;} } // 2) Lyric in music tag @@ -658,7 +554,7 @@ // 3) if lyric in music database else if (!lyricText.Equals("")) { - LyricFound = new Object[] { lyricText, m_artist, m_title, "lyric database" }; + LyricFound = new Object[] { lyricText, m_artist, m_title, "lyrics database" }; } // 4) if no lyric found, search the Internet for it using the LyricEngine @@ -684,56 +580,143 @@ else { m_TrackText = ""; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBTrack, m_StatusText); m_StatusText = "The music tag isn't complete"; - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus, m_StatusText); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); return; } } + private void tagLine() + { + if (alreadyValidLRC == false && selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) + { + string time = "[" + min.ToString() + ":" + (sec.ToString().Length == 2 ? sec.ToString() : "0" + sec.ToString()) + "." + (stopwatch.ElapsedMilliseconds.ToString().Length == 3 ? stopwatch.ElapsedMilliseconds.ToString() : stopwatch.ElapsedMilliseconds.ToString() + "0") + "]"; + lines[LRCLinesTotal] = time + lines[LRCLinesTotal]; + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + currentLRCLine, time); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + currentLRCLine); + + if (++LRCLinesTotal < lines.Length) + { + + // If a new round has to start + if (++currentLRCLine == TAG_IN_ROUND) + { + currentLRCLine = 0; + ++tagRoundFinished; + + try + { + for (int i = 0; i < TAG_IN_ROUND && LRCLinesTotal + i < lines.Length; i++) + { + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i, ""); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i, lines[tagRoundFinished * TAG_IN_ROUND + i]); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i, lines[tagRoundFinished * TAG_IN_ROUND + i]); + } + } + catch { ;} + } + } + else + { + MessageBox.Show("The lyric has now completely been converted into a lrc!"); + StringBuilder lyric = new StringBuilder(); + for (int i = 0; i < lines.Length; i++) + { + lyric.Append(lines[i] + "\n"); + } + lyric.Replace("\r", ""); + + string artist = LyricUtil.capatalizeString(m_artist); + string title = LyricUtil.capatalizeString(m_title); + string lyricAsString = lyric.ToString(); + + int lastLineShift = lyricAsString.LastIndexOf("\n"); + lyricAsString = lyricAsString.Substring(0, lastLineShift); + + LyricsItem item = new LyricsItem(artist, title, lyricAsString, "LRC-editor screen"); + LyricsDB[DatabaseUtil.CorrectKeyFormat(artist, title)] = item; + + string path = MediaPortal.Configuration.Config.GetFile(MediaPortal.Configuration.Config.Dir.Database, LyricsDBName); + using (FileStream fs = new FileStream(path, FileMode.Open)) + { + BinaryFormatter bf = new BinaryFormatter(); + LyricsDB.SetLastModified(); + bf.Serialize(fs, LyricsDB); + fs.Close(); + } + } + } + } + public void OnTimerEvent(object source, EventArgs e) { - // If the max number of lyrics on screen has been added, then reset the counter and start over again - if (++lineCounter > SHIFT_WHEN_HIT) + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + currentLRCLine); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + currentLRCLine); + + if (++LRCLinesTotal < lines.Length) { - lineCounter = 0; - m_LyricText = ""; - GUIControl.ClearControl(GetID, (int)LyricGUI_Controls.CONTROL_Lyric); + + // If a new round has to start + if (++currentLRCLine == TAG_IN_ROUND) + { + currentLRCLine = 0; + ++tagRoundFinished; + + try + { + resetGUI(selectedScreen); + for (int i = 0; i < TAG_IN_ROUND; i++) + { + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i, lines[tagRoundFinished * TAG_IN_ROUND + i]); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, lines[tagRoundFinished * TAG_IN_ROUND + i]); + } + } + catch {;}; + } } - m_LyricText += (nextLineToShow); - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_Lyric, m_LyricText); + calculateNextInterval(); } private void calculateNextInterval() { - if (enumerator.MoveNext()) + if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_BASIC || selectedScreen == (int)MyLyricsSettings.Screen.LRC_WIDE) { - LRC.SimpleLRCTimeAndLine currentLine = (LRC.SimpleLRCTimeAndLine)enumerator.Current; - while (currentLine.Time == 0) + if (enumerator.MoveNext()) { - m_LyricText += (currentLine.Line); - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_Lyric, m_LyricText); + LRC.SimpleLRCTimeAndLine currentLine = (LRC.SimpleLRCTimeAndLine)enumerator.Current; + while (currentLine.Time == 0) + { + m_LyricText += (currentLine.Line); + GUIControl.SetControlLabel(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric, m_LyricText); - ++lineCounter; - enumerator.MoveNext(); - currentLine = (LRC.SimpleLRCTimeAndLine)enumerator.Current; - } + ++currentLRCLine; + enumerator.MoveNext(); + currentLine = (LRC.SimpleLRCTimeAndLine)enumerator.Current; + } - nextTimeToShow = currentLine.TimeString; - nextLineToShow = currentLine.Line; - //MessageBox.Show(g_Player.CurrentPosition.ToString()); - int temp = (int)(currentLine.Time - (int)(g_Player.CurrentPosition * 1000)); - if (temp > 0) - { - timer.Interval = temp; + nextTimeToShow = currentLine.TimeString; + nextLineToShow = currentLine.Line; + + int temp = (int)(currentLine.Time - (int)(g_Player.CurrentPosition * 1000)); + if (temp > 0) + { + timer.Interval = temp; + } + else + { + //MessageBox.Show("temp: " + temp); + } } else { - //MessageBox.Show("temp: " + temp); + timer.Stop(); + stopwatch.Stop(); + timer.Dispose(); } - - // lbTestSecondsLeft.Text = ((long)(stopwatch.ElapsedMilliseconds / 1000)).ToString(); } else { @@ -752,9 +735,17 @@ m_LyricText = lyricText; m_StatusText = ""; + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, m_StatusText); - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_LBStatus, m_StatusText); - GUIControl.SetControlLabel(GetID, (int)LyricGUI_Controls.CONTROL_Lyric, m_LyricText); + if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) + { + showLRCtoEdit(); + } + else + { + resetGUI((int)MyLyricsSettings.Screen.LYRICS_BASIC); + GUIControl.SetControlLabel(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric, m_LyricText); + } } private void SaveLyricToDatabase(string site) @@ -797,7 +788,6 @@ { if (m_LyricControllerThread != null && m_LyricControllerThread.IsAlive) // thread is active { - //GUIControl.SetControlLabel(GetID, (int)Controls.CONTROL_LBStatus, m_StatusText); // set event "Stop" m_EventStopThread.Set(); @@ -806,6 +796,240 @@ } } + + private void resetAll() + { + + //deregister the handler! + //GUIPropertyManager.OnPropertyChanged -= this.trackChangeHandler; + + newTrack = false; + exitingMyLyrics = false; + m_artist = ""; + m_title = ""; + m_TrackText = ""; + m_StatusText = ""; + m_LyricText = ""; + lyricsFound = false; + m_LyricControllerThread = null; + lc = null; + + resetLrcFields(); + } + + private void resetLrcFields() + { + if (timer != null) + timer.Dispose(); + if (stopwatch != null) + stopwatch.Reset(); + nextTimeToShow = ""; + nextLineToShow = ""; + currentLRCLine = 0; + LRCLinesTotal = 0; + tagRoundFinished = 0; + min = 0; + sec = 0; + msec = 0; + lines = null; + times = null; + } + + private void resetGUI(int screenID) + { + selectedScreen = screenID; + + GUIPropertyManager.OnPropertyChanged -= new GUIPropertyManager.OnPropertyChangedHandler(trackChangeHandler); + GUIPropertyManager.OnPropertyChanged -= new GUIPropertyManager.OnPropertyChangedHandler(timeHandler); + timer.Tick -= new System.EventHandler(OnTimerEvent); + + if (selectedScreen == (int)MyLyricsSettings.Screen.LYRICS_BASIC) + { + GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(trackChangeHandler); + times = new ArrayList(); + + // Reset general and lyrics controls + GUIControl.ShowControl(GetID, (int)GUI_General_Controls.CONTROL_LBStatus); + GUIControl.ShowControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); + GUIControl.SetControlLabel(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric, ""); + + // album art only visible for basic screen + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_CURRENTLY); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_DURATION); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUM); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_YEAR); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_NOWPLAYINGBACK); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUMART); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESS); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESSIMAGE); + + // Hide LRC controls + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_TAGBUTTON); + + for (int i = 0; i < TAG_IN_ROUND; i++) + { + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i); + + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); + } + } + + else if (selectedScreen == (int)MyLyricsSettings.Screen.LYRICS_WIDE) + { + GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(trackChangeHandler); + times = new ArrayList(); + + // Reset general and lyrics controls + GUIControl.ShowControl(GetID, (int)GUI_General_Controls.CONTROL_LBStatus); + //GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, ""); + GUIControl.ShowControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); + GUIControl.SetControlLabel(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric, ""); + + // album art only visible for lyrics_basic screen + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_CURRENTLY); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_DURATION); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUM); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_YEAR); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_NOWPLAYINGBACK); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUMART); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESS); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESSIMAGE); + + // Hide LRC controls + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_TAGBUTTON); + + for (int i = 0; i < TAG_IN_ROUND; i++) + { + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i); + + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); + } + } + + else if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_BASIC) + { + if (alreadyValidLRC == false) + { + GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(trackChangeHandler); + GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(timeHandler); + timer.Tick += new System.EventHandler(OnTimerEvent); + } + + // Lyrics controls + GUIControl.ShowControl(GetID, (int)GUI_General_Controls.CONTROL_LBStatus); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, ""); + GUIControl.HideControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); + + // album art only visible for basic screen + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_CURRENTLY); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_DURATION); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUM); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_YEAR); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_NOWPLAYINGBACK); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUMART); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESS); + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESSIMAGE); + + // LRC controls + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_TAGBUTTON); + + for (int i = 0; i < TAG_IN_ROUND; i++) + { + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i); + + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i, ""); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, ""); + } + } + + else if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_WIDE) + { + if (alreadyValidLRC == false) + { + GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(trackChangeHandler); + GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(timeHandler); + timer.Tick += new System.EventHandler(OnTimerEvent); + } + + // Lyrics controls + GUIControl.ShowControl(GetID, (int)GUI_General_Controls.CONTROL_LBStatus); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, ""); + GUIControl.HideControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); + + // album art only visible for basic screen + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_CURRENTLY); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_DURATION); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUM); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_YEAR); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_NOWPLAYINGBACK); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUMART); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESS); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESSIMAGE); + + // LRC controls + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_TAGBUTTON); + + for (int i = 0; i < TAG_IN_ROUND; i++) + { + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE + i); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_LINE_DONE + i); + + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE + i, ""); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i); + GUIControl.SetControlLabel(GetID, (int)GUI_LRC_Controls.CONTROL_VIEW_LINE_DONE + i, ""); + } + } + + else if (selectedScreen == (int)MyLyricsSettings.Screen.LRC_EDITOR) + { + GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(trackChangeHandler); + GUIPropertyManager.OnPropertyChanged += new GUIPropertyManager.OnPropertyChangedHandler(timeHandler); + + // Lyrics controls + GUIControl.ShowControl(GetID, (int)GUI_General_Controls.CONTROL_LBStatus); + GUIControl.SetControlLabel(GetID, (int)GUI_General_Controls.CONTROL_LBStatus, ""); + GUIControl.HideControl(GetID, (int)GUI_Lyrics_Controls.CONTROL_Lyric); + + // album art only visible for lyrics_basic screen + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_CURRENTLY); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_DURATION); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUM); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_YEAR); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_NOWPLAYINGBACK); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_ALBUMART); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESS); + GUIControl.HideControl(GetID, (int)GUI_LRC_Controls.CONTROL_ART_PROGRESSIMAGE); + + // LRC controls + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_TAGBUTTON); + + for (int i = 0; i < TAG_IN_ROUND; i++) + { + GUIControl.ShowControl(GetID, (int)GUI_LRC_Controls.CONTROL_EDIT_TIME + i); +... [truncated message content] |