private void CreateScoreInfoGlyphs() { Logger.Info("ScoreLayout", "Creating score info glyphs"); var flags = Renderer.Settings.Layout.Get("hideInfo", false) ? HeaderFooterElements.None : HeaderFooterElements.All; var score = Renderer.Score; var res = Renderer.RenderingResources; ScoreInfoGlyphs = new FastDictionary <HeaderFooterElements, TextGlyph>(); if (!string.IsNullOrEmpty(score.Title) && (flags & HeaderFooterElements.Title) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Title] = new TextGlyph(0, 0, score.Title, res.TitleFont, TextAlign.Center); } if (!string.IsNullOrEmpty(score.SubTitle) && (flags & HeaderFooterElements.SubTitle) != 0) { ScoreInfoGlyphs[HeaderFooterElements.SubTitle] = new TextGlyph(0, 0, score.SubTitle, res.SubTitleFont, TextAlign.Center); } if (!string.IsNullOrEmpty(score.Artist) && (flags & HeaderFooterElements.Artist) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Artist] = new TextGlyph(0, 0, score.Artist, res.SubTitleFont, TextAlign.Center); } if (!string.IsNullOrEmpty(score.Album) && (flags & HeaderFooterElements.Album) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Album] = new TextGlyph(0, 0, score.Album, res.SubTitleFont, TextAlign.Center); } if (!string.IsNullOrEmpty(score.Music) && score.Music == score.Words && (flags & HeaderFooterElements.WordsAndMusic) != 0) { ScoreInfoGlyphs[HeaderFooterElements.WordsAndMusic] = new TextGlyph(0, 0, "Music and Words by " + score.Words, res.WordsFont, TextAlign.Center); } else { if (!string.IsNullOrEmpty(score.Music) && (flags & HeaderFooterElements.Music) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Music] = new TextGlyph(0, 0, "Music by " + score.Music, res.WordsFont, TextAlign.Right); } if (!string.IsNullOrEmpty(score.Words) && (flags & HeaderFooterElements.Words) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Words] = new TextGlyph(0, 0, "Words by " + score.Music, res.WordsFont, TextAlign.Left); } } // tuning info if (Renderer.Tracks.Length == 1 && !Renderer.Tracks[0].IsPercussion) { var tuning = Tuning.FindTuning(Renderer.Tracks[0].Tuning); if (tuning != null) { TuningGlyph = new TuningGlyph(0, 0, Scale, Renderer.RenderingResources, tuning); } } }
private float LayoutAndRenderScoreInfo(float x, float y) { HeaderFooterElements flags = Renderer.Settings.Layout.Get("hideInfo", false) ? HeaderFooterElements.None : HeaderFooterElements.All; var score = Renderer.Score; var scale = Scale; var canvas = Renderer.Canvas; var res = Renderer.RenderingResources; var glyphs = new FastList <TextGlyph>(); string str; if (!string.IsNullOrEmpty(score.Title) && (flags & HeaderFooterElements.Title) != 0) { glyphs.Add(new TextGlyph(Width / 2f, y, score.Title, res.TitleFont, TextAlign.Center)); y += (35 * scale); } if (!string.IsNullOrEmpty(score.SubTitle) && (flags & HeaderFooterElements.SubTitle) != 0) { glyphs.Add(new TextGlyph(Width / 2f, y, score.SubTitle, res.SubTitleFont, TextAlign.Center)); y += (20 * scale); } if (!string.IsNullOrEmpty(score.Artist) && (flags & HeaderFooterElements.Artist) != 0) { glyphs.Add(new TextGlyph(Width / 2f, y, score.Artist, res.SubTitleFont, TextAlign.Center)); y += (20 * scale); } if (!string.IsNullOrEmpty(score.Album) && (flags & HeaderFooterElements.Album) != 0) { glyphs.Add(new TextGlyph(Width / 2f, y, score.Album, res.SubTitleFont, TextAlign.Center)); y += (20 * scale); } if (!string.IsNullOrEmpty(score.Music) && score.Music == score.Words && (flags & HeaderFooterElements.WordsAndMusic) != 0) { glyphs.Add(new TextGlyph(Width / 2f, y, "Music and Words by " + score.Words, res.WordsFont, TextAlign.Center)); y += (20 * scale); } else { if (!string.IsNullOrEmpty(score.Music) && (flags & HeaderFooterElements.Music) != 0) { glyphs.Add(new TextGlyph(Width - PagePadding[2], y, "Music by " + score.Music, res.WordsFont, TextAlign.Right)); } if (!string.IsNullOrEmpty(score.Words) && (flags & HeaderFooterElements.Words) != 0) { glyphs.Add(new TextGlyph(x, y, "Words by " + score.Music, res.WordsFont, TextAlign.Left)); } y += (20 * scale); } y += (20 * scale); // tuning info if (Renderer.Tracks.Length == 1 && !Renderer.Tracks[0].IsPercussion) { var tuning = Tuning.FindTuning(Renderer.Tracks[0].Tuning); if (tuning != null) { // Name glyphs.Add(new TextGlyph(x, y, tuning.Name, res.EffectFont, TextAlign.Left)); y += (15 * scale); if (!tuning.IsStandard) { // Strings var stringsPerColumn = (int)Math.Ceiling(Renderer.Tracks[0].Tuning.Length / 2.0); var currentX = x; var currentY = y; for (int i = 0, j = Renderer.Tracks[0].Tuning.Length; i < j; i++) { str = "(" + (i + 1) + ") = " + Tuning.GetTextForTuning(Renderer.Tracks[0].Tuning[i], false); glyphs.Add(new TextGlyph(currentX, currentY, str, res.EffectFont, TextAlign.Left)); currentY += (15 * scale); if (i == stringsPerColumn - 1) { currentY = y; currentX += (43 * scale); } } y += (stringsPerColumn * (15 * scale)); } } } y += 25 * scale; canvas.BeginRender(Width, y); canvas.Color = res.ScoreInfoColor; canvas.TextAlign = TextAlign.Center; for (int i = 0; i < glyphs.Count; i++) { glyphs[i].Paint(0, 0, canvas); } var result = canvas.EndRender(); OnPartialRenderFinished(new RenderFinishedEventArgs { Width = Width, Height = y, RenderResult = result, TotalWidth = Width, TotalHeight = y }); return(y); }
private void CreateScoreInfoGlyphs() { Logger.Info("ScoreLayout", "Creating score info glyphs"); var flags = Renderer.Settings.Layout.Get("hideInfo", false) ? HeaderFooterElements.None : HeaderFooterElements.All; var score = Renderer.Score; var res = Renderer.RenderingResources; ScoreInfoGlyphs = new FastDictionary <HeaderFooterElements, TextGlyph>(); if (!string.IsNullOrEmpty(score.Title) && (flags & HeaderFooterElements.Title) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Title] = new TextGlyph(0, 0, score.Title, res.TitleFont, TextAlign.Center); } if (!string.IsNullOrEmpty(score.SubTitle) && (flags & HeaderFooterElements.SubTitle) != 0) { ScoreInfoGlyphs[HeaderFooterElements.SubTitle] = new TextGlyph(0, 0, score.SubTitle, res.SubTitleFont, TextAlign.Center); } if (!string.IsNullOrEmpty(score.Artist) && (flags & HeaderFooterElements.Artist) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Artist] = new TextGlyph(0, 0, score.Artist, res.SubTitleFont, TextAlign.Center); } if (!string.IsNullOrEmpty(score.Album) && (flags & HeaderFooterElements.Album) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Album] = new TextGlyph(0, 0, score.Album, res.SubTitleFont, TextAlign.Center); } if (!string.IsNullOrEmpty(score.Music) && score.Music == score.Words && (flags & HeaderFooterElements.WordsAndMusic) != 0) { ScoreInfoGlyphs[HeaderFooterElements.WordsAndMusic] = new TextGlyph(0, 0, "Music and Words by " + score.Words, res.WordsFont, TextAlign.Center); } else { if (!string.IsNullOrEmpty(score.Music) && (flags & HeaderFooterElements.Music) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Music] = new TextGlyph(0, 0, "Music by " + score.Music, res.WordsFont, TextAlign.Right); } if (!string.IsNullOrEmpty(score.Words) && (flags & HeaderFooterElements.Words) != 0) { ScoreInfoGlyphs[HeaderFooterElements.Words] = new TextGlyph(0, 0, "Words by " + score.Words, res.WordsFont, TextAlign.Left); } } if (!Renderer.Settings.Layout.Get("hideTuning", false)) { Model.Staff staffWithTuning = null; foreach (var track in Renderer.Tracks) { foreach (var staff in track.Staves) { if (staff.StaffKind != StaffKind.Percussion && staff.IsStringed && staff.Tuning.Length > 0) { staffWithTuning = staff; break; } } if (staffWithTuning != null) { break; } } // tuning info if (staffWithTuning != null) { var tuning = Tuning.FindTuning(staffWithTuning.Tuning); if (tuning != null) { TuningGlyph = new TuningGlyph(0, 0, Scale, Renderer.RenderingResources, tuning); } } } }