/// <summary> /// draws the per verse notes /// </summary> /// <param name="index"></param> /// <param name="startPos"></param> void drawNotes(SongVerse songVerse, float startPos, bool firstHalfOfPage) { if (!displaySettings.ShowNotes.Value) { return; //just stop if we must not display notes } float notesPos = startPos; float leftPosition; if (firstHalfOfPage) { leftPosition = displaySettings.pageWidth / 2 - displaySettings.rightPageMargin; } else { leftPosition = displaySettings.pageWidth - displaySettings.rightPageMargin; } var noteWidth = displaySettings.NoteWidth.Value; var noteRectangle = new RectangleF(leftPosition - noteWidth, notesPos, noteWidth, displaySettings.pageHeight); StringFormat strFormat = new StringFormat(); strFormat.Alignment = StringAlignment.Far; graphicsObj.DrawString(songVerse.Notes, notesFormattor.Font, notesFormattor.Brush, noteRectangle, strFormat); }
void drawVerseContents(SongVerse songVerse, bool firstHalfOfPage) { float leftMargin = 0; if (firstHalfOfPage) { leftMargin = displaySettings.leftPageMargin; } else { leftMargin = displaySettings.pageWidth / 2 + displaySettings.leftPageMargin; } for (int j = 0; j < songVerse.Lyrics.Count; j++) { if (songVerse.IsChord[j] && displaySettings.ShowChords.Value) { graphicsObj.DrawString(songVerse.Lyrics[j], chordsFormattor.Font, chordsFormattor.Brush, leftMargin, heightPosition); newLine(); } else if (!songVerse.IsChord[j] && displaySettings.ShowLyrics.Value) { graphicsObj.DrawString(songVerse.Lyrics[j], lyricsFormattor.Font, lyricsFormattor.Brush, leftMargin, heightPosition); newLine(); } } }
/// <summary> /// returns true if the verse fits on the page /// </summary> /// <param name="index"></param> /// <returns></returns> bool verseFits(SongVerse verse) { var linesForVerse = 0; var linesThatFit = numberOfLinesThatFit(); if (displaySettings.ShowChords.Value && displaySettings.ShowLyrics.Value) { linesForVerse = verse.VerseLinesCount; } else if (displaySettings.ShowChords.Value == false && displaySettings.ShowLyrics.Value == true) { linesForVerse = verse.LyricsLinesCount; } else if (displaySettings.ShowChords.Value == true && displaySettings.ShowLyrics.Value == false) { linesForVerse = verse.ChordLinesCount; } if (linesForVerse <= linesThatFit) { return(true); } else { return(false); } }
/// <summary> /// draw first 2 lines of indicated verse /// </summary> /// <param name="index"></param> void drawPartialVerseContents(SongVerse songVerse, bool firstHalfOfPage) { float currentPosition = heightPosition; float spaceSize = displaySettings.LyricsFormat.FontSize + displaySettings.contentLineSpacing; int linesToFit = numberOfLinesThatFit(); int currentLinesDrawn = 0; float leftPosition; if (firstHalfOfPage) { leftPosition = displaySettings.leftPageMargin; } else { leftPosition = displaySettings.pageWidth / 2 + displaySettings.leftPageMargin; } writeToDebug(String.Format("currentPosition: {0}", currentPosition)); writeToDebug(String.Format("linesToFit: {0}", linesToFit)); for (int j = 0; j < songVerse.Lyrics.Count && currentLinesDrawn <= linesToFit; j++) { if (songVerse.IsChord[j] && displaySettings.ShowChords.Value) { graphicsObj.DrawString(songVerse.Lyrics[j], chordsFormattor.Font, chordsFormattor.Brush, leftPosition, heightPosition); newLine(); currentLinesDrawn++; } else if (!songVerse.IsChord[j] && displaySettings.ShowLyrics.Value) { graphicsObj.DrawString(songVerse.Lyrics[j], lyricsFormattor.Font, lyricsFormattor.Brush, leftPosition, heightPosition); newLine(); currentLinesDrawn++; } } graphicsObj.DrawString(".......PTO.......", lyricsFormattor.Font, lyricsFormattor.Brush, leftPosition, heightPosition); }
/// <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(); }
/// <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(); }
void drawVerseHeader(SongVerse songVerse, bool firstHalfOfPage) { float leftPosition; if (!firstHalfOfPage) { leftPosition = displaySettings.pageWidth / 2 + displaySettings.leftPageMargin; } else { leftPosition = displaySettings.leftPageMargin; } graphicsObj.DrawString(songVerse.FullHeaderName, headingFormattor.Font, headingFormattor.Brush, leftPosition, heightPosition); newLine(); }