コード例 #1
0
ファイル: SvgPage.cs プロジェクト: suvjunmd/Moritz
        private int GetNewBottomVBPX(List <SvgSystem> pageSystems)
        {
            int frameHeight = _pageFormat.TopMarginPage1 + 20;

            foreach (SvgSystem system in pageSystems)
            {
                SystemMetrics sm = system.Metrics;
                frameHeight += (int)((sm.Bottom - sm.Top) + _pageFormat.DefaultDistanceBetweenSystems);
            }

            return(frameHeight);
        }
コード例 #2
0
ファイル: SvgSystem.cs プロジェクト: notator/Moritz
        private void JustifyVertically(float pageWidth, float gap)
        {
            int barnumberStaffIndex = BarnumberStaffIndex();
            float stafflinesTop = Staves[barnumberStaffIndex].Metrics.StafflinesTop;
            if(stafflinesTop != 0)
            {
                for(int i = barnumberStaffIndex; i < Staves.Count; ++i)
                {
                    Staff staff = Staves[i];
                    if(staff.Metrics != null)
                    {
                        staff.Metrics.Move(0, stafflinesTop * -1);
                    }
                }
            }

            Debug.Assert(Staves[barnumberStaffIndex].Metrics.StafflinesTop == 0);
            if((barnumberStaffIndex + 1) < Staves.Count)// There must be at least one visible staff (an InputStaff).
            {
                for(int i = (barnumberStaffIndex + 1); i < Staves.Count; ++i)
                {
                    if(Staves[i].Metrics != null)
                    {
                        //BottomEdge bottomEdge = new BottomEdge(Staves[i - 1], 0F, pageWidth, gap);
                        BottomEdge bottomEdge = GetBottomEdge(i - 1, barnumberStaffIndex, pageWidth, gap);
                        if(bottomEdge != null)
                        {
                            TopEdge topEdge = new TopEdge(Staves[i], 0F, pageWidth);
                            float separation = topEdge.DistanceToEdgeAbove(bottomEdge);
                            float dy = gap - separation;
                            // limit stafflineHeight to multiples of pageFormat.Gap so that stafflines
                            // are not displayed as thick grey lines.
                            dy = dy - (dy % gap) + gap; // the minimum space bewteen stafflines is gap pixels.
                            if(dy > 0F)
                            {
                                for(int j = i; j < Staves.Count; ++j)
                                {
                                    if(Staves[j].Metrics != null)
                                    {
                                        Staves[j].Metrics.Move(0F, dy);
                                    }
                                }
                                this.Metrics.StafflinesBottom += dy;
                            }
                        }
                    }
                }
            }
            this.Metrics = new SystemMetrics();
            foreach(Staff staff in Staves)
            {
                if(!(staff is HiddenOutputStaff) && staff.Metrics != null)
                {
                    this.Metrics.Add(staff.Metrics);
                }
            }
            Debug.Assert(this.Metrics.StafflinesTop == 0);
        }
コード例 #3
0
ファイル: SvgSystem.cs プロジェクト: notator/Moritz
        private float CreateMetrics(Graphics graphics, PageFormat pageFormat, float leftMarginPos)
        {
            this.Metrics = new SystemMetrics();
            List<NoteObject> NoteObjectsToRemove = new List<NoteObject>();
            int topUnHiddenStaffIndex = TopUnHiddenStaffIndex();
            for(int staffIndex = topUnHiddenStaffIndex; staffIndex < Staves.Count; ++staffIndex)
            {
                Staff staff = Staves[staffIndex];
                Debug.Assert(!(staff is HiddenOutputStaff));

                // Staves that contain no chords will be invisible. Their Metrics attribute is null.
                if(staff.ContainsAChordSymbol)
                {
                    float staffHeight = staff.Gap * (staff.NumberOfStafflines - 1);
                    staff.Metrics = new StaffMetrics(leftMarginPos, pageFormat.RightMarginPos, staffHeight);

                    for(int voiceIndex = 0; voiceIndex < staff.Voices.Count; ++voiceIndex)
                    {
                        Voice voice = staff.Voices[voiceIndex];

                        voice.SetChordStemDirectionsAndCreateBeamBlocks(pageFormat);

                        for(int nIndex = 0; nIndex < staff.Voices[voiceIndex].NoteObjects.Count; nIndex++)
                        {
                            NoteObject noteObject = staff.Voices[voiceIndex].NoteObjects[nIndex];
                            noteObject.Metrics = Score.Notator.SymbolSet.NoteObjectMetrics(graphics, noteObject, voice.StemDirection, staff.Gap, staff.StafflineStemStrokeWidth);

                            if(noteObject.Metrics != null)
                                staff.Metrics.Add(noteObject.Metrics);
                            else
                                NoteObjectsToRemove.Add(noteObject);
                        }

                        foreach(NoteObject noteObject in NoteObjectsToRemove)
                            staff.Voices[voiceIndex].NoteObjects.Remove(noteObject);
                        NoteObjectsToRemove.Clear();
                    }

                    if(staff.Voices.Count > 1)
                    {
                        Debug.Assert(Score.Notator.SymbolSet is StandardSymbolSet);
                        // Other symbol sets do not support multi voice staves.
                        staff.AdjustTwoPartChords();
                    }

                    staff.Metrics.Move(0f, pageFormat.DefaultDistanceBetweenStaves * (staffIndex - topUnHiddenStaffIndex));
                    this.Metrics.Add(staff.Metrics);
                }
            }

            return (this.Metrics.Bottom - this.Metrics.Top);
        }