/// <summary> /// Implements the IComparable interface. Allows arrays of LyricsItem's to be sorted. /// </summary> /// <param name="obj">The type of this object can be another LyricsItem or a LyricsSequenceItem</param> /// <returns>-1, 0, or 1 if "this" is less, equal, or greater than "obj"</returns> public int CompareTo(object obj) { // Return -1 if "this" is less than "other/obj" if (obj is LyricsItem) { LyricsItem other = obj as LyricsItem; if (this.Type == other.Type) { return(this.Number - other.Number); } else { return(this.Type - other.Type); } } else { LyricsSequenceItem other = obj as LyricsSequenceItem; if (this.Type == other.Type) { return(this.Number - other.Number); } else { return(this.Type - other.Type); } } }
private void UpdateAvailableLyrics() { Song s = this.ReadControls(); Sequence.ListEx_Available.Items.Clear(); if (s.SongLyrics == null) { return; } // s.SongLyrics.Sort(); // is this really necessaray? this.sequenceAvailable.Clear(); if (Sequence.AutoSequence.Checked) { Sequence.ListEx_Sequence.Items.Clear(); } foreach (LyricsItem l in s.SongLyrics) { LyricsSequenceItem item = new LyricsSequenceItem(l.Type, l.Number); Sequence.ListEx_Available.Add(item.ToString(), 0); if (Sequence.AutoSequence.Checked) { Sequence.ListEx_Sequence.Add(item.ToString(), 1); } this.sequenceAvailable.Add(item); } // TODO: Update the sequence list as well, in case the user removed a verse that was part of the sequence. }
/// <summary> /// Returns the words of a single verse/chorus. /// </summary> /// <param name="Item"></param> /// <returns></returns> public string GetLyrics(LyricsSequenceItem Item) { foreach (LyricsItem l in this.SongLyrics) { if (l.CompareTo(Item) == 0) { return(SanitizeLyrics(l.Lyrics)); } } return(""); }
public LyricsItem GetLyrics(int seq) { if (seq >= this.Sequence.Count) { return(null); } LyricsSequenceItem current = (LyricsSequenceItem)this.Sequence[seq]; foreach (LyricsItem item in this.SongLyrics) { if (item.CompareTo(current) == 0) { return(item); } } return(null); }
public LyricsSequenceItem(LyricsSequenceItem item) : this(item.Type, item.Number) { }