Пример #1
0
//		private const bool		_debug		= false;
        #endregion

        private void LayoutNotes(Graphics g, int widthStave)
        {
            DebugWrite(string.Format("Layout({0}/{1}): ", _isLayoutDirty, widthStave != _oldWidth));
            if (_tune != null && _tune.Count > 0 &&
                (_isLayoutDirty || widthStave != _oldWidth))
            {
                _isLayoutDirty = false;
                int x = widthStave;
                g.ScaleTransform(_scale, _scale);

                _score = new Score(widthStave);
                MusicPaths.StartUp(new Size(widthStave - 10, 0));
                ScoreLine  scoreLine = null;
                IAwareNote note      = null;
                for (int iNote = 0; iNote < _tune.Count; iNote++)
                {
                    if (iNote == 0)
                    {
                        scoreLine = new ScoreLine(_score.Count, g.Transform, iNote);
                        x         = 35;
                    }
                    if (widthStave < x + 24)
                    {
                        scoreLine.MaxNoteNo       = iNote;
                        scoreLine.MaxNotePosition = note.SpanPosition;
                        _score += scoreLine;
                        g.TranslateTransform(0F, _height);

                        scoreLine = new ScoreLine(_score.Count, g.Transform, iNote);
                        x         = 35;
                    }

                    note = _tune[iNote];
                    int y = 32;
                    if (note.PianoKey != PianoKey.Rest)
                    {
                        y += 18 - 3 * (note.NoteLetter.NoteIndex() - NoteLetter.C.NoteIndex())
                             - 21 * (note.PianoKey.Octave() - PianoKey.C_4.Octave());
                    }
                    var width   = 20 + Math.Abs((int)note.SharpFlat) * 7 + note.Length.DotCount * 4;
                    var notePos = new ScoreNotePosition(x, y, width, note.SpanPosition, note.SpanLength, iNote);
                    scoreLine += notePos;
                    x         += width;
                }
                scoreLine.MaxNoteNo       = _tune.Count - 1;
                scoreLine.MaxNotePosition = note.SpanPosition;
                _score   += scoreLine;
                _oldWidth = widthStave;
                Panel2.AutoScrollMinSize = new SizeF(_oldWidth,
                                                     75 + _height + (int)g.Transform.Elements[5]).ToSize();
                DebugWrite(" done");
            }
            else if (_tune == null || _tune.Count == 0)
            {
                Panel2.AutoScrollMinSize = g.VisibleClipBounds.Size.ToSize();
                DebugWrite(" skipped");
            }
            DebugWriteLine();
        }
Пример #2
0
 public static MusicPaths StartUp(Size size)
 {
     if (_singleton != null)
     {
         ShutDown();
     }
     return(_singleton = new MusicPaths(size));
 }
Пример #3
0
 public static void ShutDown()
 {
     _singleton.Dispose(); _singleton = null;
 }