private OctaveShift CreateContinuedOctavaLine(OctaveShift octaveShift, double gap, System.Drawing.Graphics graphics) { OctaveShift continuedOctaveShiftContinues = null; OctaveShiftExtender octaveShiftExtender = null; foreach (var voice in Voices) { double yMax = Metrics.StafflinesBottom; double yMin = Metrics.StafflinesTop; var noteObjects = voice.NoteObjects; for (var noteObjectIndex = 0; noteObjectIndex < noteObjects.Count; noteObjectIndex++) { if (noteObjects[noteObjectIndex] is OutputChordSymbol chord) { yMax = (yMax > chord.ChordMetrics.Bottom) ? yMax : chord.ChordMetrics.Bottom; yMin = (yMin < chord.ChordMetrics.Top) ? yMin : chord.ChordMetrics.Top; if (chord.EndOctaveShift != null) { // a continuation octaveShiftExtender with endmarker in this staff (= voice). var y = (chord.EndOctaveShift.Orient == Orientation.up) ? yMin : yMax; octaveShiftExtender = new OctaveShiftExtender(chord.EndOctaveShift, graphics, this.Metrics.Left, chord.ChordMetrics.Right, y, gap, true, true); this.Metrics.MetricsList.Add(octaveShiftExtender.Metrics); this.Extenders.Add(octaveShiftExtender); // so that extender.Metrics.WriteSvg(w) will be called correctly continuedOctaveShiftContinues = null; break; } } } if (octaveShiftExtender == null) { // a continuation octaveShiftExtender, with no endmarker, that continues beyond the end of this staff (= voice). var y = (octaveShift.Orient == Orientation.up) ? yMin : yMax; octaveShiftExtender = new OctaveShiftExtender(null, graphics, this.Metrics.Left, Metrics.Right + (gap * 1.1), y, gap, true, false); this.Metrics.MetricsList.Add(octaveShiftExtender.Metrics); this.Extenders.Add(octaveShiftExtender); // so that extender.Metrics.WriteSvg(w) will be called correctly continuedOctaveShiftContinues = octaveShift; } } return(continuedOctaveShiftContinues); }
internal OctaveShift CreateOctaveShiftExtenders(System.Drawing.Graphics graphics, OctaveShift firstExtenderIsContinuation) { double gap = M.PageFormat.GapVBPX; OctaveShift extenderContinuesOnNextSystem = null; if (firstExtenderIsContinuation != null) { extenderContinuesOnNextSystem = CreateContinuedOctavaLine(firstExtenderIsContinuation, gap, graphics); } if (extenderContinuesOnNextSystem == null) { foreach (var voice in Voices) { var noteObjects = voice.NoteObjects; for (var noteObjectIndex = 0; noteObjectIndex < noteObjects.Count; noteObjectIndex++) { double yMax = Metrics.StafflinesBottom; double yMin = Metrics.StafflinesTop; if (noteObjects[noteObjectIndex] is OutputChordSymbol leftChord && leftChord.OctaveShift != null) { yMax = (yMax > leftChord.ChordMetrics.Bottom) ? yMax : leftChord.ChordMetrics.Bottom; yMin = (yMin < leftChord.ChordMetrics.Top) ? yMin : leftChord.ChordMetrics.Top; OctaveShiftExtender octaveShiftExtender = null; var octaveShift = leftChord.OctaveShift; for (var rightNOIndex = noteObjectIndex; rightNOIndex < noteObjects.Count; rightNOIndex++) { if (noteObjects[rightNOIndex] is OutputChordSymbol rightChord) { yMax = (yMax > rightChord.ChordMetrics.Bottom) ? yMax : rightChord.ChordMetrics.Bottom; yMin = (yMin < rightChord.ChordMetrics.Top) ? yMin : rightChord.ChordMetrics.Top; if (rightChord.EventID == leftChord.OctaveShift.TargetID) { var y = (leftChord.OctaveShift.Orient == Orientation.up) ? yMin : yMax; // an octaveShiftExtender with endmarker, that ends in this voice. octaveShiftExtender = new OctaveShiftExtender(octaveShift, graphics, leftChord.ChordMetrics.Left, rightChord.ChordMetrics.Right, y, gap, false, true); extenderContinuesOnNextSystem = leftChord.OctaveShift; break; } } } if (octaveShiftExtender == null) { var y = (leftChord.OctaveShift.Orient == Orientation.up) ? yMin : yMax; // an octaveShiftExtender, without endmarker, that extends to the right of the system. octaveShiftExtender = new OctaveShiftExtender(octaveShift, graphics, leftChord.ChordMetrics.Left, Metrics.Right + (gap * 1.1), y, gap, false, false); extenderContinuesOnNextSystem = leftChord.OctaveShift; } this.Metrics.MetricsList.Add(octaveShiftExtender.Metrics); // so that the extender will be moved vertically correctly this.Extenders.Add(octaveShiftExtender); // so that extender.Metrics.WriteSvg(w) will be called correctly } } } } return(extenderContinuesOnNextSystem); }