Пример #1
0
        public void Render()
        {
            var renderHelper = new RenderHelper(scorePanel);
            double currentNoteTime = 0;
            double currentDevisions = 0;

            var staffs = new Staffs(renderHelper);

            staffs.Add(new Staff(renderHelper, ScoreLayoutDetails.LineSpacing_Y, ScoreLayoutDetails.Staff1_FristLineY));
            staffs.Add(new Staff(renderHelper, ScoreLayoutDetails.LineSpacing_Y, ScoreLayoutDetails.Staff2_FristLineY));
            staffs.AddBarLine(currentNoteTime);

            foreach (Part part in score.Parts)
                foreach (Measure measure in part.Measures)
                {
                    MeasureAttributes attributes = measure.Attributes;
                    if (attributes != null)
                    {
                        if (attributes.Divisions != -1) currentDevisions = attributes.Divisions;

                        UpdateMeasureAttributes(attributes, staffs, currentNoteTime);
                    }

                    double lastNoteDuration = 0;

                    foreach (Note note in measure.Notes)
                    {
                        //If the current note is part of a chord, we need to revert to the previous NoteTime
                        if (note.IsChord) currentNoteTime -= lastNoteDuration / currentDevisions;

                        Staff staff = GetStaffFromNote(staffs, note);
                        if (staff != null && note.IsDrawableEntity)
                        {
                            staff.AddNote(note, currentDevisions, currentNoteTime);
                        }

                        //After current note drawn, handle keeping track of noteTime in the piece
                        switch (note.NoteType)
                        {
                            case Note.NoteTypes.Backup: currentNoteTime -= note.Duration / currentDevisions;
                                break;
                            case Note.NoteTypes.Forward: currentNoteTime += note.Duration / currentDevisions;
                                break;
                            default: currentNoteTime += note.Duration / currentDevisions;
                                break;
                        }

                        lastNoteDuration = note.Duration;
                    }

                    staffs.AddBarLine(currentNoteTime);
                }

            double finalX = renderHelper.RenderItems(ScoreLayoutDetails.DefaultMargin_X);
            foreach (var staff in staffs) staff.DrawStaffLines(ScoreLayoutDetails.DefaultMargin_X, finalX);
        }
Пример #2
0
        public Staff(RenderHelper renderHelper, double lineSpacing, double lowestLine_Y)
        {
            _renderHelper = renderHelper;
            LineSpacing = lineSpacing;
            LowestLine_Y = lowestLine_Y;
            RestYCoords = new RestYCoords(LowestLine_Y, LineSpacing);

            _noteRenderHelper = new NoteRenderHelper(_renderHelper, RestYCoords);

            //Set some values that will never occur in practice, so when we first check to see if the attributes
            //in the xml are different to our staff, we'll always update the first time around
            StaffClef = new StaffCleff
            {
                Sign = 'x',
                Line = -1,
                OctaveChange = -1,
            };
            Timing = new Timing
            {
                Numerator = -1,
                Denominator = -1
            };
        }
Пример #3
0
 public NoteRenderHelper(RenderHelper renderHelper,RestYCoords restYCoords)
 {
     _renderHelper = renderHelper;
     _restYCoords = restYCoords;
 }