Ejemplo n.º 1
0
        private void CreateGlyphs(Tuning tuning)
        {
            // Name
            AddGlyph(new TextGlyph(0, 0, tuning.Name, _resources.EffectFont));
            Height += 15 * _scale;

            if (!tuning.IsStandard)
            {
                // Strings
                var stringsPerColumn = (int)Math.Ceiling(tuning.Tunings.Length / 2.0);

                var currentX = 0f;
                var currentY = Height;
                for (int i = 0, j = tuning.Tunings.Length; i < j; i++)
                {
                    var str = "(" + (i + 1) + ") = " + Tuning.GetTextForTuning(tuning.Tunings[i], false);
                    AddGlyph(new TextGlyph(currentX, currentY, str, _resources.EffectFont));
                    currentY += Height;
                    if (i == stringsPerColumn - 1)
                    {
                        currentY  = Height;
                        currentX += (43 * _scale);
                    }
                }

                Height += (stringsPerColumn * (15 * _scale));
            }
        }
Ejemplo n.º 2
0
        public void TestStandard()
        {
            var standard   = Tuning.GetDefaultTuningFor(6);
            var tuningText = new[] { "E4", "B3", "G3", "D3", "A2", "E2" };

            var tuning      = new int[tuningText.Length];
            var tuningText2 = new string[tuningText.Length];

            for (int i = 0; i < tuningText.Length; i++)
            {
                tuning[i]      = TuningParser.GetTuningForText(tuningText[i]);
                tuningText2[i] = Tuning.GetTextForTuning(tuning[i], true);
            }

            Assert.AreEqual(string.Join(",", standard.Tunings), string.Join(",", tuning));
            Assert.AreEqual(string.Join(",", tuningText), string.Join(",", tuningText2));
        }
Ejemplo n.º 3
0
        private void MetaData(Track track)
        {
            var score = track.Score;

            StringMetaData("title", score.Title);
            StringMetaData("subtitle", score.SubTitle);
            StringMetaData("artist", score.Artist);
            StringMetaData("album", score.Album);
            StringMetaData("words", score.Words);
            StringMetaData("music", score.Music);
            StringMetaData("copyright", score.Copyright);

            _builder.Append("\\tempo ");
            _builder.Append(score.Tempo);
            _builder.AppendLine();

            var staff = track.Staves[0];

            if (staff.Capo > 0)
            {
                _builder.Append("\\capo ");
                _builder.Append(staff.Capo);
                _builder.AppendLine();
            }

            _builder.Append("\\tuning");
            for (int i = 0; i < staff.Tuning.Length; i++)
            {
                _builder.Append(" ");
                _builder.Append(Tuning.GetTextForTuning(staff.Tuning[i], true));
            }

            _builder.Append("\\instrument ");
            _builder.Append(track.PlaybackInfo.Program);
            _builder.AppendLine();

            _builder.Append(".");
            _builder.AppendLine();
        }
Ejemplo n.º 4
0
        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);
        }