コード例 #1
0
        /// <summary>
        /// attempt to fix the formatting of the song
        /// </summary>
        /// <param name="song"></param>
        public static void fixFormatting(Song song)
        {
            //check if one or more lines has lines that dont start with [, ' ' or .
            rebuildLyricsIfNeeded(song);

            //get song in split form
            var verses = SongVerse.getSongVersesNoOrder(song);

            //fix headers, chord and lyric indicators and rebuild the lyrics string
            var tempLyrics = new StringBuilder();

            for (int i = 0; i < verses.Count; i++)
            {
                var verse = verses[i];
                verse.Header = fixHeader(verse.Header);
                tempLyrics.AppendFormat("[{0}]\n", verse.Header);
                for (int j = 0; j < verse.VerseLinesCount; j++)
                {
                    verse.IsChord[j] = CheckIfChordsLine(verse.Lyrics[j]);
                    if (verse.IsChord[j])
                    {
                        tempLyrics.AppendFormat(".{0}\n", verse.Lyrics[j].TrimEnd());
                    }
                    else
                    {
                        tempLyrics.AppendFormat(" {0}\n", verse.Lyrics[j].TrimEnd());
                    }
                }
                tempLyrics.Append("\n");
                replaceMsWordQuotes(tempLyrics);
            }
            song.lyrics = tempLyrics.ToString().Trim();

            //format the notes
            song.notes = formatNotes(song);

            //get rid of trailing spaces
            song.title  = song.title.TrimEnd();
            song.author = song.author.TrimEnd();
            song.key    = song.key.TrimEnd();
        }
コード例 #2
0
        /// <summary>
        /// transpose the entire song up by a semitone
        /// </summary>
        /// <param name="song"></param>
        /// <returns></returns>
        public static void transposeKeyUp(Song song)
        {
            var  songVerses  = SongVerse.getSongVersesNoOrder(song);
            bool preferFlats = Settings.GlobalApplicationSettings.PreferFlats;

            //transpose each chord line
            foreach (var songVerse in songVerses)
            {
                for (int i = 0; i < songVerse.VerseLinesCount; i++)
                {
                    var isChord = songVerse.IsChord[i];
                    if (isChord)
                    {
                        songVerse.Lyrics[i] = tranposeLine(songVerse.Lyrics[i], preferFlats);
                    }
                }
            }

            //rewrite the lyrics
            StringBuilder lyrics = new StringBuilder();

            foreach (var songVerse in songVerses)
            {
                lyrics.AppendFormat("[{0}]\n", songVerse.Header);
                for (int i = 0; i < songVerse.VerseLinesCount; i++)
                {
                    var isChord = songVerse.IsChord[i];
                    if (isChord)
                    {
                        lyrics.AppendFormat(".{0}\n", songVerse.Lyrics[i].TrimEnd());
                    }
                    else
                    {
                        lyrics.AppendFormat(" {0}\n", songVerse.Lyrics[i].TrimEnd());
                    }
                }
                lyrics.Append("\n");
            }
            song.lyrics = lyrics.ToString();
        }