AlphaTab.Rendering.Glyphs.NumberGlyph.DoLayout C# (CSharp) Method

DoLayout() public method

public DoLayout ( ) : void
return void
        public override void DoLayout()
        {
            var i = _number;
            while (i > 0)
            {
                var num = i % 10;
                var gl = new DigitGlyph(0, 0, num);
                AddGlyph(gl);
                i = i / 10;
            }
            Glyphs.Reverse();

            var cx = 0f;
            for (int j = 0, k = Glyphs.Count; j < k; j++)
            {
                var g = Glyphs[j];
                g.X = cx;
                g.Y = 0;
                g.Renderer = Renderer;
                g.DoLayout();
                cx += g.Width;
            }
            Width = cx;
        }

Usage Example

Beispiel #1
0
        public override void Paint(float cx, float cy, ICanvas canvas)
        {
            base.Paint(cx, cy, canvas);
            NumberGlyph numberGlyph;
            bool        top = false;

            switch (_clefOttavia)
            {
            case ClefOttavia._15ma:
                numberGlyph = new NumberGlyph(Width / 2, 0, 15, 0.5f);
                top         = true;
                break;

            case ClefOttavia._8va:
                numberGlyph = new NumberGlyph(0, 0, 8, 0.5f);
                top         = true;
                break;

            case ClefOttavia._8vb:
                numberGlyph = new NumberGlyph(0, 0, 8, 0.5f);
                break;

            case ClefOttavia._15mb:
                numberGlyph = new NumberGlyph(0, 0, 15, 0.5f);
                break;

            default:
                return;
            }

            int offset;

            switch (_clef)
            {
            case Clef.Neutral:
                offset = top ? -25 : 10;
                break;

            case Clef.C3:
                offset = top ? -30 : 20;
                break;

            case Clef.C4:
                offset = top ? -30 : 20;
                break;

            case Clef.F4:
                offset = top ? -25 : 20;
                break;

            case Clef.G2:
                offset = top ? -50 : 25;
                break;

            default:
                return;
            }

            numberGlyph.Renderer = Renderer;
            numberGlyph.DoLayout();

            var x = (Width - numberGlyph.Width) / 2;

            numberGlyph.Paint(cx + X + x, cy + Y + offset * Scale, canvas);
        }