Пример #1
0
        /// <summary>
        /// Adds the staff name to the first barline of each visible staff in the score.
        /// </summary>
        private void SetStaffNames()
        {
            foreach (SvgSystem system in Systems)
            {
                for (int staffIndex = 0; staffIndex < system.Staves.Count; staffIndex++)
                {
                    Staff staff = system.Staves[staffIndex];
                    if (!(staff is InvisibleOutputStaff))
                    {
                        foreach (NoteObject noteObject in staff.Voices[0].NoteObjects)
                        {
                            Barline firstBarline = noteObject as Barline;
                            if (firstBarline != null)
                            {
                                float fontHeight = _pageFormat.StaffNameFontHeight;

                                if (staff is InputStaff)
                                {
                                    fontHeight *= _pageFormat.InputStavesSizeFactor;
                                }
                                StaffNameText staffNameText = new StaffNameText(firstBarline, staff.Staffname, fontHeight);
                                firstBarline.DrawObjects.Add(staffNameText);
                                break;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private float GetLeftMarginPos(SvgSystem system, Graphics graphics, PageFormat pageFormat)
        {
            float leftMarginPos = pageFormat.LeftMarginPos;
            float maxNameWidth  = 0;

            foreach (Staff staff in system.Staves)
            {
                foreach (NoteObject noteObject in staff.Voices[0].NoteObjects)
                {
                    Barline firstBarline = noteObject as Barline;
                    if (firstBarline != null)
                    {
                        foreach (DrawObject drawObject in firstBarline.DrawObjects)
                        {
                            StaffNameText staffName = drawObject as StaffNameText;
                            if (staffName != null)
                            {
                                Debug.Assert(staffName.TextInfo != null);

                                TextMetrics staffNameMetrics = new TextMetrics(graphics, null, staffName.TextInfo);
                                float       nameWidth        = staffNameMetrics.Right - staffNameMetrics.Left;
                                maxNameWidth = (maxNameWidth > nameWidth) ? maxNameWidth : nameWidth;
                            }
                        }
                        break;
                    }
                }
            }
            leftMarginPos = maxNameWidth + (pageFormat.Gap * 2.0F);
            leftMarginPos = (leftMarginPos > pageFormat.LeftMarginPos) ? leftMarginPos : pageFormat.LeftMarginPos;

            return(leftMarginPos);
        }
Пример #3
0
        /// <summary>
        /// Adds the staff name to the first barline of each visible staff in the score.
        /// </summary>
        private void SetStaffNames()
        {
            foreach(SvgSystem system in Systems)
            {
                for(int staffIndex = 0; staffIndex < system.Staves.Count; staffIndex++)
                {
                    Staff staff = system.Staves[staffIndex];
                    if(!(staff is HiddenOutputStaff))
                    {
                        foreach(NoteObject noteObject in staff.Voices[0].NoteObjects)
                        {
                            Barline firstBarline = noteObject as Barline;
                            if(firstBarline != null)
                            {
                                float fontHeight = _pageFormat.StaffNameFontHeight;

                                if(staff is InputStaff)
                                {
                                    fontHeight *= _pageFormat.InputStavesSizeFactor;
                                }
                                StaffNameText staffNameText = new StaffNameText(firstBarline, staff.Staffname, fontHeight);
                                firstBarline.DrawObjects.Add(staffNameText);
                                break;
                            }
                        }
                    }
                }
            }
        }