Esempio n. 1
0
        /// <summary>
        /// This function only writes the staff name and barnumber to the SVG file (if they are present).
        /// The barline itself is drawn when the system (and staff edges) is complete.
        /// </summary>
        public override void WriteSVG(SvgWriter w, bool staffIsVisible)
        {
            BarlineMetrics barlineMetrics = Metrics as BarlineMetrics;

            if (barlineMetrics != null && staffIsVisible)
            {
                barlineMetrics.WriteSVG(w);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds all the staff's metrics, except for the top or bottom staffline.
        /// </summary>
        /// <param name="staff"></param>
        protected void AddStaffMetrics(Staff staff)
        {
            foreach (Voice voice in staff.Voices)
            {
                foreach (NoteObject noteObject in voice.NoteObjects)
                {
                    OutputChordSymbol chordSymbol = noteObject as OutputChordSymbol;
                    ClefSymbol        clef        = noteObject as ClefSymbol;

                    if (chordSymbol != null)
                    {
                        chordSymbol.ChordMetrics.AddToEdge(this);
                    }
                    else if (clef != null && clef.ClefType != "n")
                    {
                        Add(clef.Metrics);
                    }
                    else
                    {
                        Add(noteObject.Metrics);
                    }

                    Barline barline = noteObject as Barline;
                    if (barline != null)
                    {
                        BarlineMetrics barlineMetrics = barline.Metrics as BarlineMetrics;
                        if (barlineMetrics.BarnumberMetrics != null)
                        {
                            Add(barlineMetrics.BarnumberMetrics);
                        }
                        if (barlineMetrics.StaffNameMetrics != null)
                        {
                            Add(barlineMetrics.StaffNameMetrics);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public override Metrics NoteObjectMetrics(Graphics graphics, NoteObject noteObject, VerticalDir voiceStemDirection, float gap, float strokeWidth)
        {
            Metrics               returnMetrics         = null;
            ClefSymbol            clef                  = noteObject as ClefSymbol;
            Barline               barline               = noteObject as Barline;
            CautionaryChordSymbol cautionaryChordSymbol = noteObject as CautionaryChordSymbol;
            ChordSymbol           chord                 = noteObject as ChordSymbol;
            RestSymbol            rest                  = noteObject as RestSymbol;

            if (barline != null)
            {
                returnMetrics = new BarlineMetrics(graphics, barline, gap);
            }
            else if (clef != null)
            {
                if (clef.ClefType != "n")
                {
                    returnMetrics = new ClefMetrics(clef, gap);
                }
            }
            else if (cautionaryChordSymbol != null)
            {
                returnMetrics = new ChordMetrics(graphics, cautionaryChordSymbol, voiceStemDirection, gap, strokeWidth);
            }
            else if (chord != null)
            {
                returnMetrics = new ChordMetrics(graphics, chord, voiceStemDirection, gap, strokeWidth);
            }
            else if (rest != null)
            {
                // All rests are originally created on the centre line.
                // They are moved vertically later, if they are on a 2-Voice staff.
                returnMetrics = new RestMetrics(graphics, rest, gap, noteObject.Voice.Staff.NumberOfStafflines, strokeWidth);
            }

            return(returnMetrics);
        }
Esempio n. 4
0
        public override Metrics NoteObjectMetrics(Graphics graphics, NoteObject noteObject, VerticalDir voiceStemDirection, float gap, float strokeWidth)
        {
            Metrics returnMetrics = null;
            ClefSymbol clef = noteObject as ClefSymbol;
            Barline barline = noteObject as Barline;
            CautionaryOutputChordSymbol cautionaryOutputChordSymbol = noteObject as CautionaryOutputChordSymbol;
            CautionaryInputChordSymbol cautionaryInputChordSymbol = noteObject as CautionaryInputChordSymbol;
            ChordSymbol chord = noteObject as ChordSymbol;
            RestSymbol rest = noteObject as RestSymbol;
            if(barline != null)
            {
                returnMetrics = new BarlineMetrics(graphics, barline, gap);
            }
            else if(clef != null)
            {
                if(clef.ClefType != "n")
                    returnMetrics = new ClefMetrics(clef, gap);
            }
            else if(cautionaryOutputChordSymbol != null)
            {
                returnMetrics = new ChordMetrics(graphics, cautionaryOutputChordSymbol, voiceStemDirection, gap, strokeWidth);
            }
            else if(cautionaryInputChordSymbol != null)
            {
                returnMetrics = new ChordMetrics(graphics, cautionaryInputChordSymbol, voiceStemDirection, gap, strokeWidth);
            }
            else if(chord != null)
            {
                returnMetrics = new ChordMetrics(graphics, chord, voiceStemDirection, gap, strokeWidth);
            }
            else if(rest != null)
            {
                // All rests are originally created on the centre line.
                // They are moved vertically later, if they are on a 2-Voice staff.
                returnMetrics = new RestMetrics(graphics, rest, gap, noteObject.Voice.Staff.NumberOfStafflines, strokeWidth);
            }

            return returnMetrics;
        }
Esempio n. 5
0
        /// <summary>
        /// the returned barlineWidths dictionary contains
        ///     key: the msPosition of a system moment
        ///     value: the distance between the left edge of the barline and the moment's AlignmentX.
        /// </summary>
        /// <param name="moments"></param>
        /// <param name="gap"></param>
        /// <returns></returns>
        private Dictionary<int, float> GetBarlineWidths(List<NoteObjectMoment> moments, float gap)
        {
            Dictionary<int, float> barlineWidths = new Dictionary<int, float>();

            BarlineMetrics singleBarline = new BarlineMetrics(null, new Barline(Staves[0].Voices[0], BarlineType.single), gap);
            float singleBarlineLeftMargin = singleBarline.OriginX - singleBarline.Left;
            BarlineMetrics endBarline = new BarlineMetrics(null, new Barline(Staves[0].Voices[0], BarlineType.end), gap);
            float endBarlineLeftMargin = endBarline.OriginX - endBarline.Left;

            Barline barline = null;
            int absMsPos = 0;
            for(int i = 1; i < moments.Count; i++)
            {
                absMsPos = moments[i].AbsMsPosition;
                float barlineWidth = 0F;
                Debug.Assert(moments.Count > 1);

                barline = moments[i].Barline;
                if(barline != null && barline.Metrics != null)
                {
                    barlineWidth = moments[i].AlignmentX - barline.Metrics.Left;
                    barlineWidths.Add(absMsPos, barlineWidth);
                }
            }
            return barlineWidths;
        }